aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-13 15:39:32 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-13 15:39:32 -0400
commit6b0da28b2d0f4f4e2c55689fc062db569075ff60 (patch)
treee7113f6db70fe3c2dd16bd2e7e1538fba4236c49
parent67c56364df843fb9e3ed1af014b8fbe4b22ff25d (diff)
ide: add ide_retry_pc() helper
* Add ide_create_request_sense_cmd() and ide_retry_pc() helpers and convert ide-{atapi,floppy,tape}.c to use them. * Remove no longer used ide*_create_request_sense_cmd(), ide*_retry_pc() and 'retry_pc' argument from ide_pc_intr(). * Make ide_queue_pc_head() static. There should be no functional changes caused by this patch. Cc: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r--drivers/ide/ide-atapi.c39
-rw-r--r--drivers/ide/ide-floppy.c25
-rw-r--r--drivers/ide/ide-floppy.h1
-rw-r--r--drivers/ide/ide-floppy_ioctl.c2
-rw-r--r--drivers/ide/ide-tape.c29
-rw-r--r--drivers/scsi/ide-scsi.c2
-rw-r--r--include/linux/ide.h5
7 files changed, 41 insertions, 62 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index 184835141412..d758dcd87178 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -124,8 +124,8 @@ EXPORT_SYMBOL_GPL(ide_init_pc);
124 * the current request, so that it will be processed immediately, on the next 124 * the current request, so that it will be processed immediately, on the next
125 * pass through the driver. 125 * pass through the driver.
126 */ 126 */
127void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk, 127static void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk,
128 struct ide_atapi_pc *pc, struct request *rq) 128 struct ide_atapi_pc *pc, struct request *rq)
129{ 129{
130 blk_rq_init(NULL, rq); 130 blk_rq_init(NULL, rq);
131 rq->cmd_type = REQ_TYPE_SPECIAL; 131 rq->cmd_type = REQ_TYPE_SPECIAL;
@@ -137,7 +137,6 @@ void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk,
137 rq->cmd[13] = REQ_IDETAPE_PC1; 137 rq->cmd[13] = REQ_IDETAPE_PC1;
138 ide_do_drive_cmd(drive, rq); 138 ide_do_drive_cmd(drive, rq);
139} 139}
140EXPORT_SYMBOL_GPL(ide_queue_pc_head);
141 140
142/* 141/*
143 * Add a special packet command request to the tail of the request queue, 142 * Add a special packet command request to the tail of the request queue,
@@ -203,6 +202,37 @@ int ide_set_media_lock(ide_drive_t *drive, struct gendisk *disk, int on)
203} 202}
204EXPORT_SYMBOL_GPL(ide_set_media_lock); 203EXPORT_SYMBOL_GPL(ide_set_media_lock);
205 204
205void ide_create_request_sense_cmd(ide_drive_t *drive, struct ide_atapi_pc *pc)
206{
207 ide_init_pc(pc);
208 pc->c[0] = REQUEST_SENSE;
209 if (drive->media == ide_floppy) {
210 pc->c[4] = 255;
211 pc->req_xfer = 18;
212 } else {
213 pc->c[4] = 20;
214 pc->req_xfer = 20;
215 }
216}
217EXPORT_SYMBOL_GPL(ide_create_request_sense_cmd);
218
219/*
220 * Called when an error was detected during the last packet command.
221 * We queue a request sense packet command in the head of the request list.
222 */
223void ide_retry_pc(ide_drive_t *drive, struct gendisk *disk)
224{
225 struct request *rq = &drive->request_sense_rq;
226 struct ide_atapi_pc *pc = &drive->request_sense_pc;
227
228 (void)ide_read_error(drive);
229 ide_create_request_sense_cmd(drive, pc);
230 if (drive->media == ide_tape)
231 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags);
232 ide_queue_pc_head(drive, disk, pc, rq);
233}
234EXPORT_SYMBOL_GPL(ide_retry_pc);
235
206int ide_scsi_expiry(ide_drive_t *drive) 236int ide_scsi_expiry(ide_drive_t *drive)
207{ 237{
208 struct ide_atapi_pc *pc = drive->pc; 238 struct ide_atapi_pc *pc = drive->pc;
@@ -219,7 +249,6 @@ EXPORT_SYMBOL_GPL(ide_scsi_expiry);
219/* TODO: unify the code thus making some arguments go away */ 249/* TODO: unify the code thus making some arguments go away */
220ide_startstop_t ide_pc_intr(ide_drive_t *drive, ide_handler_t *handler, 250ide_startstop_t ide_pc_intr(ide_drive_t *drive, ide_handler_t *handler,
221 void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), 251 void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *),
222 void (*retry_pc)(ide_drive_t *),
223 int (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int)) 252 int (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int))
224{ 253{
225 struct ide_atapi_pc *pc = drive->pc; 254 struct ide_atapi_pc *pc = drive->pc;
@@ -299,7 +328,7 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, ide_handler_t *handler,
299 debug_log("[cmd %x]: check condition\n", rq->cmd[0]); 328 debug_log("[cmd %x]: check condition\n", rq->cmd[0]);
300 329
301 /* Retry operation */ 330 /* Retry operation */
302 retry_pc(drive); 331 ide_retry_pc(drive, rq->rq_disk);
303 332
304 /* queued, but not started */ 333 /* queued, but not started */
305 return ide_stopped; 334 return ide_stopped;
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 6a1ade8ca9fe..6e62ffafc562 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -193,34 +193,11 @@ static void ide_floppy_callback(ide_drive_t *drive, int dsc)
193 idefloppy_end_request(drive, uptodate, 0); 193 idefloppy_end_request(drive, uptodate, 0);
194} 194}
195 195
196void ide_floppy_create_request_sense_cmd(struct ide_atapi_pc *pc)
197{
198 ide_init_pc(pc);
199 pc->c[0] = GPCMD_REQUEST_SENSE;
200 pc->c[4] = 255;
201 pc->req_xfer = 18;
202}
203
204/*
205 * Called when an error was detected during the last packet command. We queue a
206 * request sense packet command in the head of the request list.
207 */
208static void idefloppy_retry_pc(ide_drive_t *drive)
209{
210 struct ide_floppy_obj *floppy = drive->driver_data;
211 struct request *rq = &drive->request_sense_rq;
212 struct ide_atapi_pc *pc = &drive->request_sense_pc;
213
214 (void)ide_read_error(drive);
215 ide_floppy_create_request_sense_cmd(pc);
216 ide_queue_pc_head(drive, floppy->disk, pc, rq);
217}
218
219/* The usual interrupt handler called during a packet command. */ 196/* The usual interrupt handler called during a packet command. */
220static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) 197static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
221{ 198{
222 return ide_pc_intr(drive, idefloppy_pc_intr, idefloppy_update_buffers, 199 return ide_pc_intr(drive, idefloppy_pc_intr, idefloppy_update_buffers,
223 idefloppy_retry_pc, ide_io_buffers); 200 ide_io_buffers);
224} 201}
225 202
226/* 203/*
diff --git a/drivers/ide/ide-floppy.h b/drivers/ide/ide-floppy.h
index e9e14c30fed7..ced5ceb474de 100644
--- a/drivers/ide/ide-floppy.h
+++ b/drivers/ide/ide-floppy.h
@@ -49,7 +49,6 @@ typedef struct ide_floppy_obj {
49/* ide-floppy.c */ 49/* ide-floppy.c */
50void ide_floppy_create_mode_sense_cmd(struct ide_atapi_pc *, u8); 50void ide_floppy_create_mode_sense_cmd(struct ide_atapi_pc *, u8);
51void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *); 51void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *);
52void ide_floppy_create_request_sense_cmd(struct ide_atapi_pc *);
53 52
54/* ide-floppy_ioctl.c */ 53/* ide-floppy_ioctl.c */
55int ide_floppy_format_ioctl(ide_drive_t *, struct file *, unsigned int, 54int ide_floppy_format_ioctl(ide_drive_t *, struct file *, unsigned int,
diff --git a/drivers/ide/ide-floppy_ioctl.c b/drivers/ide/ide-floppy_ioctl.c
index 5ffc4512d14b..9723ed9c61b4 100644
--- a/drivers/ide/ide-floppy_ioctl.c
+++ b/drivers/ide/ide-floppy_ioctl.c
@@ -195,7 +195,7 @@ static int ide_floppy_get_format_progress(ide_drive_t *drive, int __user *arg)
195 int progress_indication = 0x10000; 195 int progress_indication = 0x10000;
196 196
197 if (drive->atapi_flags & IDE_AFLAG_SRFP) { 197 if (drive->atapi_flags & IDE_AFLAG_SRFP) {
198 ide_floppy_create_request_sense_cmd(&pc); 198 ide_create_request_sense_cmd(drive, &pc);
199 if (ide_queue_pc_tail(drive, floppy->disk, &pc)) 199 if (ide_queue_pc_tail(drive, floppy->disk, &pc))
200 return -EIO; 200 return -EIO;
201 201
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 72ecc5657db2..72caca3cb7aa 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -581,31 +581,6 @@ static void ide_tape_callback(ide_drive_t *drive, int dsc)
581 idetape_end_request(drive, uptodate, 0); 581 idetape_end_request(drive, uptodate, 0);
582} 582}
583 583
584static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc)
585{
586 ide_init_pc(pc);
587 pc->c[0] = REQUEST_SENSE;
588 pc->c[4] = 20;
589 pc->req_xfer = 20;
590}
591
592/*
593 * idetape_retry_pc is called when an error was detected during the
594 * last packet command. We queue a request sense packet command in
595 * the head of the request list.
596 */
597static void idetape_retry_pc(ide_drive_t *drive)
598{
599 struct ide_tape_obj *tape = drive->driver_data;
600 struct request *rq = &drive->request_sense_rq;
601 struct ide_atapi_pc *pc = &drive->request_sense_pc;
602
603 (void)ide_read_error(drive);
604 idetape_create_request_sense_cmd(pc);
605 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags);
606 ide_queue_pc_head(drive, tape->disk, pc, rq);
607}
608
609/* 584/*
610 * Postpone the current request so that ide.c will be able to service requests 585 * Postpone the current request so that ide.c will be able to service requests
611 * from another device on the same hwgroup while we are polling for DSC. 586 * from another device on the same hwgroup while we are polling for DSC.
@@ -653,7 +628,7 @@ static int ide_tape_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
653static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) 628static ide_startstop_t idetape_pc_intr(ide_drive_t *drive)
654{ 629{
655 return ide_pc_intr(drive, idetape_pc_intr, idetape_update_buffers, 630 return ide_pc_intr(drive, idetape_pc_intr, idetape_update_buffers,
656 idetape_retry_pc, ide_tape_io_buffers); 631 ide_tape_io_buffers);
657} 632}
658 633
659/* 634/*
@@ -789,7 +764,7 @@ static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive)
789 printk(KERN_ERR "ide-tape: %s: I/O error, ", 764 printk(KERN_ERR "ide-tape: %s: I/O error, ",
790 tape->name); 765 tape->name);
791 /* Retry operation */ 766 /* Retry operation */
792 idetape_retry_pc(drive); 767 ide_retry_pc(drive, tape->disk);
793 return ide_stopped; 768 return ide_stopped;
794 } 769 }
795 pc->error = 0; 770 pc->error = 0;
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index f71d1b34c3b1..ff2b19909838 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -275,7 +275,7 @@ static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs)
275 */ 275 */
276static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) 276static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
277{ 277{
278 return ide_pc_intr(drive, idescsi_pc_intr, NULL, NULL, ide_io_buffers); 278 return ide_pc_intr(drive, idescsi_pc_intr, NULL, ide_io_buffers);
279} 279}
280 280
281static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive) 281static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive)
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 908b4fc9772c..d88cced0d02c 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1169,13 +1169,13 @@ enum {
1169 REQ_IDETAPE_WRITE = (1 << 3), 1169 REQ_IDETAPE_WRITE = (1 << 3),
1170}; 1170};
1171 1171
1172void ide_queue_pc_head(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *,
1173 struct request *);
1174int ide_queue_pc_tail(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *); 1172int ide_queue_pc_tail(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *);
1175 1173
1176int ide_do_test_unit_ready(ide_drive_t *, struct gendisk *); 1174int ide_do_test_unit_ready(ide_drive_t *, struct gendisk *);
1177int ide_do_start_stop(ide_drive_t *, struct gendisk *, int); 1175int ide_do_start_stop(ide_drive_t *, struct gendisk *, int);
1178int ide_set_media_lock(ide_drive_t *, struct gendisk *, int); 1176int ide_set_media_lock(ide_drive_t *, struct gendisk *, int);
1177void ide_create_request_sense_cmd(ide_drive_t *, struct ide_atapi_pc *);
1178void ide_retry_pc(ide_drive_t *, struct gendisk *);
1179 1179
1180static inline unsigned long ide_scsi_get_timeout(struct ide_atapi_pc *pc) 1180static inline unsigned long ide_scsi_get_timeout(struct ide_atapi_pc *pc)
1181{ 1181{
@@ -1186,7 +1186,6 @@ int ide_scsi_expiry(ide_drive_t *);
1186 1186
1187ide_startstop_t ide_pc_intr(ide_drive_t *drive, ide_handler_t *handler, 1187ide_startstop_t ide_pc_intr(ide_drive_t *drive, ide_handler_t *handler,
1188 void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), 1188 void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *),
1189 void (*retry_pc)(ide_drive_t *),
1190 int (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned int, 1189 int (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned int,
1191 int)); 1190 int));
1192ide_startstop_t ide_transfer_pc(ide_drive_t *, 1191ide_startstop_t ide_transfer_pc(ide_drive_t *,