diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:39 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:39 -0400 |
commit | de699ad595fb45022d1b049ed91ffd06fdd16c13 (patch) | |
tree | 9fc467c912faafb4d1bd5e16de5fbf537ef2c2f6 /drivers/ide | |
parent | 0c8a6c7aead1d3be85ce53e3aaacd52e38ede03e (diff) |
ide: add ide_do_test_unit_ready() helper
* Add ide_do_test_unit_ready() helper and convert ide-{floppy,tape}.c
to use it.
* Remove no longer used idetape_create_test_unit_ready_cmd().
There should be no functional changes caused by this patch.
Acked-by: Borislav Petkov <petkovbb@gmail.com>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/ide-atapi.c | 11 | ||||
-rw-r--r-- | drivers/ide/ide-floppy.c | 6 | ||||
-rw-r--r-- | drivers/ide/ide-tape.c | 10 |
3 files changed, 13 insertions, 14 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c index 58411591edf3..608c5bade929 100644 --- a/drivers/ide/ide-atapi.c +++ b/drivers/ide/ide-atapi.c | |||
@@ -162,6 +162,17 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk, | |||
162 | } | 162 | } |
163 | EXPORT_SYMBOL_GPL(ide_queue_pc_tail); | 163 | EXPORT_SYMBOL_GPL(ide_queue_pc_tail); |
164 | 164 | ||
165 | int ide_do_test_unit_ready(ide_drive_t *drive, struct gendisk *disk) | ||
166 | { | ||
167 | struct ide_atapi_pc pc; | ||
168 | |||
169 | ide_init_pc(&pc); | ||
170 | pc.c[0] = TEST_UNIT_READY; | ||
171 | |||
172 | return ide_queue_pc_tail(drive, disk, &pc); | ||
173 | } | ||
174 | EXPORT_SYMBOL_GPL(ide_do_test_unit_ready); | ||
175 | |||
165 | int ide_do_start_stop(ide_drive_t *drive, struct gendisk *disk, int start) | 176 | int ide_do_start_stop(ide_drive_t *drive, struct gendisk *disk, int start) |
166 | { | 177 | { |
167 | struct ide_atapi_pc pc; | 178 | struct ide_atapi_pc pc; |
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index b221a456e535..4d7e9ef82425 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -773,7 +773,6 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
773 | struct gendisk *disk = inode->i_bdev->bd_disk; | 773 | struct gendisk *disk = inode->i_bdev->bd_disk; |
774 | struct ide_floppy_obj *floppy; | 774 | struct ide_floppy_obj *floppy; |
775 | ide_drive_t *drive; | 775 | ide_drive_t *drive; |
776 | struct ide_atapi_pc pc; | ||
777 | int ret = 0; | 776 | int ret = 0; |
778 | 777 | ||
779 | debug_log("Reached %s\n", __func__); | 778 | debug_log("Reached %s\n", __func__); |
@@ -790,10 +789,7 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
790 | drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; | 789 | drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; |
791 | /* Just in case */ | 790 | /* Just in case */ |
792 | 791 | ||
793 | ide_init_pc(&pc); | 792 | if (ide_do_test_unit_ready(drive, disk)) |
794 | pc.c[0] = GPCMD_TEST_UNIT_READY; | ||
795 | |||
796 | if (ide_queue_pc_tail(drive, disk, &pc)) | ||
797 | ide_do_start_stop(drive, disk, 1); | 793 | ide_do_start_stop(drive, disk, 1); |
798 | 794 | ||
799 | if (ide_floppy_get_capacity(drive) | 795 | if (ide_floppy_get_capacity(drive) |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 5204bef4a21c..737dd7db6bb7 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -1119,25 +1119,17 @@ static void idetape_create_write_filemark_cmd(ide_drive_t *drive, | |||
1119 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; | 1119 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | static void idetape_create_test_unit_ready_cmd(struct ide_atapi_pc *pc) | ||
1123 | { | ||
1124 | ide_init_pc(pc); | ||
1125 | pc->c[0] = TEST_UNIT_READY; | ||
1126 | } | ||
1127 | |||
1128 | static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) | 1122 | static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) |
1129 | { | 1123 | { |
1130 | idetape_tape_t *tape = drive->driver_data; | 1124 | idetape_tape_t *tape = drive->driver_data; |
1131 | struct gendisk *disk = tape->disk; | 1125 | struct gendisk *disk = tape->disk; |
1132 | struct ide_atapi_pc pc; | ||
1133 | int load_attempted = 0; | 1126 | int load_attempted = 0; |
1134 | 1127 | ||
1135 | /* Wait for the tape to become ready */ | 1128 | /* Wait for the tape to become ready */ |
1136 | set_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags); | 1129 | set_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags); |
1137 | timeout += jiffies; | 1130 | timeout += jiffies; |
1138 | while (time_before(jiffies, timeout)) { | 1131 | while (time_before(jiffies, timeout)) { |
1139 | idetape_create_test_unit_ready_cmd(&pc); | 1132 | if (ide_do_test_unit_ready(drive, disk) == 0) |
1140 | if (!ide_queue_pc_tail(drive, disk, &pc)) | ||
1141 | return 0; | 1133 | return 0; |
1142 | if ((tape->sense_key == 2 && tape->asc == 4 && tape->ascq == 2) | 1134 | if ((tape->sense_key == 2 && tape->asc == 4 && tape->ascq == 2) |
1143 | || (tape->asc == 0x3A)) { | 1135 | || (tape->asc == 0x3A)) { |