diff options
Diffstat (limited to 'drivers/ide/ide-tape.c')
-rw-r--r-- | drivers/ide/ide-tape.c | 66 |
1 files changed, 26 insertions, 40 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 32f56eeb1efc..2a4a652e3083 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -678,18 +678,6 @@ typedef struct { | |||
678 | #define IDETAPE_BUFFER_FILLING_PAGE 0x33 | 678 | #define IDETAPE_BUFFER_FILLING_PAGE 0x33 |
679 | 679 | ||
680 | /* | 680 | /* |
681 | * Mode Parameter Block Descriptor the MODE SENSE packet command | ||
682 | * | ||
683 | * Support for block descriptors is optional. | ||
684 | */ | ||
685 | typedef struct { | ||
686 | __u8 density_code; /* Medium density code */ | ||
687 | __u8 blocks[3]; /* Number of blocks */ | ||
688 | __u8 reserved4; /* Reserved */ | ||
689 | __u8 length[3]; /* Block Length */ | ||
690 | } idetape_parameter_block_descriptor_t; | ||
691 | |||
692 | /* | ||
693 | * Run time configurable parameters. | 681 | * Run time configurable parameters. |
694 | */ | 682 | */ |
695 | typedef struct { | 683 | typedef struct { |
@@ -3503,7 +3491,30 @@ static int idetape_chrdev_ioctl (struct inode *inode, struct file *file, unsigne | |||
3503 | } | 3491 | } |
3504 | } | 3492 | } |
3505 | 3493 | ||
3506 | static void idetape_get_blocksize_from_block_descriptor(ide_drive_t *drive); | 3494 | /* |
3495 | * Do a mode sense page 0 with block descriptor and if it succeeds set the tape | ||
3496 | * block size with the reported value. | ||
3497 | */ | ||
3498 | static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive) | ||
3499 | { | ||
3500 | idetape_tape_t *tape = drive->driver_data; | ||
3501 | idetape_pc_t pc; | ||
3502 | |||
3503 | idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR); | ||
3504 | if (idetape_queue_pc_tail(drive, &pc)) { | ||
3505 | printk(KERN_ERR "ide-tape: Can't get block descriptor\n"); | ||
3506 | if (tape->tape_block_size == 0) { | ||
3507 | printk(KERN_WARNING "ide-tape: Cannot deal with zero " | ||
3508 | "block size, assuming 32k\n"); | ||
3509 | tape->tape_block_size = 32768; | ||
3510 | } | ||
3511 | return; | ||
3512 | } | ||
3513 | tape->tape_block_size = (pc.buffer[4 + 5] << 16) + | ||
3514 | (pc.buffer[4 + 6] << 8) + | ||
3515 | pc.buffer[4 + 7]; | ||
3516 | tape->drv_write_prot = (pc.buffer[2] & 0x80) >> 7; | ||
3517 | } | ||
3507 | 3518 | ||
3508 | /* | 3519 | /* |
3509 | * Our character device open function. | 3520 | * Our character device open function. |
@@ -3557,7 +3568,7 @@ static int idetape_chrdev_open (struct inode *inode, struct file *filp) | |||
3557 | clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); | 3568 | clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); |
3558 | 3569 | ||
3559 | /* Read block size and write protect status from drive. */ | 3570 | /* Read block size and write protect status from drive. */ |
3560 | idetape_get_blocksize_from_block_descriptor(drive); | 3571 | ide_tape_get_bsize_from_bdesc(drive); |
3561 | 3572 | ||
3562 | /* Set write protect flag if device is opened as read-only. */ | 3573 | /* Set write protect flag if device is opened as read-only. */ |
3563 | if ((filp->f_flags & O_ACCMODE) == O_RDONLY) | 3574 | if ((filp->f_flags & O_ACCMODE) == O_RDONLY) |
@@ -3771,31 +3782,6 @@ static void idetape_get_mode_sense_results (ide_drive_t *drive) | |||
3771 | tape->tape_block_size = 1024; | 3782 | tape->tape_block_size = 1024; |
3772 | } | 3783 | } |
3773 | 3784 | ||
3774 | /* | ||
3775 | * ide_get_blocksize_from_block_descriptor does a mode sense page 0 with block descriptor | ||
3776 | * and if it succeeds sets the tape block size with the reported value | ||
3777 | */ | ||
3778 | static void idetape_get_blocksize_from_block_descriptor(ide_drive_t *drive) | ||
3779 | { | ||
3780 | |||
3781 | idetape_tape_t *tape = drive->driver_data; | ||
3782 | idetape_pc_t pc; | ||
3783 | idetape_parameter_block_descriptor_t *block_descrp; | ||
3784 | |||
3785 | idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR); | ||
3786 | if (idetape_queue_pc_tail(drive, &pc)) { | ||
3787 | printk(KERN_ERR "ide-tape: Can't get block descriptor\n"); | ||
3788 | if (tape->tape_block_size == 0) { | ||
3789 | printk(KERN_WARNING "ide-tape: Cannot deal with zero block size, assume 32k\n"); | ||
3790 | tape->tape_block_size = 32768; | ||
3791 | } | ||
3792 | return; | ||
3793 | } | ||
3794 | block_descrp = (idetape_parameter_block_descriptor_t *)(pc.buffer + 4); | ||
3795 | tape->tape_block_size =( block_descrp->length[0]<<16) + (block_descrp->length[1]<<8) + block_descrp->length[2]; | ||
3796 | tape->drv_write_prot = (pc.buffer[2] & 0x80) >> 7; | ||
3797 | } | ||
3798 | |||
3799 | #ifdef CONFIG_IDE_PROC_FS | 3785 | #ifdef CONFIG_IDE_PROC_FS |
3800 | static void idetape_add_settings (ide_drive_t *drive) | 3786 | static void idetape_add_settings (ide_drive_t *drive) |
3801 | { | 3787 | { |
@@ -3872,7 +3858,7 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
3872 | 3858 | ||
3873 | idetape_get_inquiry_results(drive); | 3859 | idetape_get_inquiry_results(drive); |
3874 | idetape_get_mode_sense_results(drive); | 3860 | idetape_get_mode_sense_results(drive); |
3875 | idetape_get_blocksize_from_block_descriptor(drive); | 3861 | ide_tape_get_bsize_from_bdesc(drive); |
3876 | tape->user_bs_factor = 1; | 3862 | tape->user_bs_factor = 1; |
3877 | tape->stage_size = *ctl * tape->tape_block_size; | 3863 | tape->stage_size = *ctl * tape->tape_block_size; |
3878 | while (tape->stage_size > 0xffff) { | 3864 | while (tape->stage_size > 0xffff) { |