Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 82604
b: refs/heads/master
c: 3cffb9c
h: refs/heads/master
v: v3
  • Loading branch information
Borislav Petkov authored and Bartlomiej Zolnierkiewicz committed Feb 2, 2008
1 parent 22281f2 commit 0f1823a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 41 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 496b92e65d8158bbcb978e3f746478cfa4c8542c
refs/heads/master: 3cffb9ce476f492bab194892decc7bf1834ff96b
66 changes: 26 additions & 40 deletions trunk/drivers/ide/ide-tape.c
Original file line number Diff line number Diff line change
Expand Up @@ -677,18 +677,6 @@ typedef struct {
#define IDETAPE_BLOCK_SIZE_PAGE 0x30
#define IDETAPE_BUFFER_FILLING_PAGE 0x33

/*
* Mode Parameter Block Descriptor the MODE SENSE packet command
*
* Support for block descriptors is optional.
*/
typedef struct {
__u8 density_code; /* Medium density code */
__u8 blocks[3]; /* Number of blocks */
__u8 reserved4; /* Reserved */
__u8 length[3]; /* Block Length */
} idetape_parameter_block_descriptor_t;

/*
* Run time configurable parameters.
*/
Expand Down Expand Up @@ -3503,7 +3491,30 @@ static int idetape_chrdev_ioctl (struct inode *inode, struct file *file, unsigne
}
}

static void idetape_get_blocksize_from_block_descriptor(ide_drive_t *drive);
/*
* Do a mode sense page 0 with block descriptor and if it succeeds set the tape
* block size with the reported value.
*/
static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive)
{
idetape_tape_t *tape = drive->driver_data;
idetape_pc_t pc;

idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR);
if (idetape_queue_pc_tail(drive, &pc)) {
printk(KERN_ERR "ide-tape: Can't get block descriptor\n");
if (tape->tape_block_size == 0) {
printk(KERN_WARNING "ide-tape: Cannot deal with zero "
"block size, assuming 32k\n");
tape->tape_block_size = 32768;
}
return;
}
tape->tape_block_size = (pc.buffer[4 + 5] << 16) +
(pc.buffer[4 + 6] << 8) +
pc.buffer[4 + 7];
tape->drv_write_prot = (pc.buffer[2] & 0x80) >> 7;
}

/*
* Our character device open function.
Expand Down Expand Up @@ -3557,7 +3568,7 @@ static int idetape_chrdev_open (struct inode *inode, struct file *filp)
clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags);

/* Read block size and write protect status from drive. */
idetape_get_blocksize_from_block_descriptor(drive);
ide_tape_get_bsize_from_bdesc(drive);

/* Set write protect flag if device is opened as read-only. */
if ((filp->f_flags & O_ACCMODE) == O_RDONLY)
Expand Down Expand Up @@ -3771,31 +3782,6 @@ static void idetape_get_mode_sense_results (ide_drive_t *drive)
tape->tape_block_size = 1024;
}

/*
* ide_get_blocksize_from_block_descriptor does a mode sense page 0 with block descriptor
* and if it succeeds sets the tape block size with the reported value
*/
static void idetape_get_blocksize_from_block_descriptor(ide_drive_t *drive)
{

idetape_tape_t *tape = drive->driver_data;
idetape_pc_t pc;
idetape_parameter_block_descriptor_t *block_descrp;

idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR);
if (idetape_queue_pc_tail(drive, &pc)) {
printk(KERN_ERR "ide-tape: Can't get block descriptor\n");
if (tape->tape_block_size == 0) {
printk(KERN_WARNING "ide-tape: Cannot deal with zero block size, assume 32k\n");
tape->tape_block_size = 32768;
}
return;
}
block_descrp = (idetape_parameter_block_descriptor_t *)(pc.buffer + 4);
tape->tape_block_size =( block_descrp->length[0]<<16) + (block_descrp->length[1]<<8) + block_descrp->length[2];
tape->drv_write_prot = (pc.buffer[2] & 0x80) >> 7;
}

#ifdef CONFIG_IDE_PROC_FS
static void idetape_add_settings (ide_drive_t *drive)
{
Expand Down Expand Up @@ -3872,7 +3858,7 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor)

idetape_get_inquiry_results(drive);
idetape_get_mode_sense_results(drive);
idetape_get_blocksize_from_block_descriptor(drive);
ide_tape_get_bsize_from_bdesc(drive);
tape->user_bs_factor = 1;
tape->stage_size = *ctl * tape->tape_block_size;
while (tape->stage_size > 0xffff) {
Expand Down

0 comments on commit 0f1823a

Please sign in to comment.