Commit 6b0da28b2d0f4f4e2c55689fc062db569075ff60

Authored by Bartlomiej Zolnierkiewicz
1 parent 67c56364df

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>

Showing 7 changed files with 41 additions and 62 deletions Side-by-side Diff

drivers/ide/ide-atapi.c
... ... @@ -124,8 +124,8 @@
124 124 * the current request, so that it will be processed immediately, on the next
125 125 * pass through the driver.
126 126 */
127   -void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk,
128   - struct ide_atapi_pc *pc, struct request *rq)
  127 +static void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk,
  128 + struct ide_atapi_pc *pc, struct request *rq)
129 129 {
130 130 blk_rq_init(NULL, rq);
131 131 rq->cmd_type = REQ_TYPE_SPECIAL;
... ... @@ -137,7 +137,6 @@
137 137 rq->cmd[13] = REQ_IDETAPE_PC1;
138 138 ide_do_drive_cmd(drive, rq);
139 139 }
140   -EXPORT_SYMBOL_GPL(ide_queue_pc_head);
141 140  
142 141 /*
143 142 * Add a special packet command request to the tail of the request queue,
... ... @@ -203,6 +202,37 @@
203 202 }
204 203 EXPORT_SYMBOL_GPL(ide_set_media_lock);
205 204  
  205 +void 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 +}
  217 +EXPORT_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 + */
  223 +void 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 +}
  234 +EXPORT_SYMBOL_GPL(ide_retry_pc);
  235 +
206 236 int ide_scsi_expiry(ide_drive_t *drive)
207 237 {
208 238 struct ide_atapi_pc *pc = drive->pc;
... ... @@ -219,7 +249,6 @@
219 249 /* TODO: unify the code thus making some arguments go away */
220 250 ide_startstop_t ide_pc_intr(ide_drive_t *drive, ide_handler_t *handler,
221 251 void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *),
222   - void (*retry_pc)(ide_drive_t *),
223 252 int (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int))
224 253 {
225 254 struct ide_atapi_pc *pc = drive->pc;
... ... @@ -299,7 +328,7 @@
299 328 debug_log("[cmd %x]: check condition\n", rq->cmd[0]);
300 329  
301 330 /* Retry operation */
302   - retry_pc(drive);
  331 + ide_retry_pc(drive, rq->rq_disk);
303 332  
304 333 /* queued, but not started */
305 334 return ide_stopped;
drivers/ide/ide-floppy.c
... ... @@ -193,34 +193,11 @@
193 193 idefloppy_end_request(drive, uptodate, 0);
194 194 }
195 195  
196   -void 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   - */
208   -static 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 196 /* The usual interrupt handler called during a packet command. */
220 197 static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
221 198 {
222 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 /*
drivers/ide/ide-floppy.h
... ... @@ -49,7 +49,6 @@
49 49 /* ide-floppy.c */
50 50 void ide_floppy_create_mode_sense_cmd(struct ide_atapi_pc *, u8);
51 51 void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *);
52   -void ide_floppy_create_request_sense_cmd(struct ide_atapi_pc *);
53 52  
54 53 /* ide-floppy_ioctl.c */
55 54 int ide_floppy_format_ioctl(ide_drive_t *, struct file *, unsigned int,
drivers/ide/ide-floppy_ioctl.c
... ... @@ -195,7 +195,7 @@
195 195 int progress_indication = 0x10000;
196 196  
197 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 199 if (ide_queue_pc_tail(drive, floppy->disk, &pc))
200 200 return -EIO;
201 201  
drivers/ide/ide-tape.c
... ... @@ -581,32 +581,7 @@
581 581 idetape_end_request(drive, uptodate, 0);
582 582 }
583 583  
584   -static 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 584 /*
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   - */
597   -static 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   -/*
610 585 * Postpone the current request so that ide.c will be able to service requests
611 586 * from another device on the same hwgroup while we are polling for DSC.
612 587 */
... ... @@ -653,7 +628,7 @@
653 628 static ide_startstop_t idetape_pc_intr(ide_drive_t *drive)
654 629 {
655 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 @@
789 764 printk(KERN_ERR "ide-tape: %s: I/O error, ",
790 765 tape->name);
791 766 /* Retry operation */
792   - idetape_retry_pc(drive);
  767 + ide_retry_pc(drive, tape->disk);
793 768 return ide_stopped;
794 769 }
795 770 pc->error = 0;
drivers/scsi/ide-scsi.c
... ... @@ -275,7 +275,7 @@
275 275 */
276 276 static 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  
281 281 static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive)
... ... @@ -1169,13 +1169,13 @@
1169 1169 REQ_IDETAPE_WRITE = (1 << 3),
1170 1170 };
1171 1171  
1172   -void ide_queue_pc_head(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *,
1173   - struct request *);
1174 1172 int ide_queue_pc_tail(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *);
1175 1173  
1176 1174 int ide_do_test_unit_ready(ide_drive_t *, struct gendisk *);
1177 1175 int ide_do_start_stop(ide_drive_t *, struct gendisk *, int);
1178 1176 int ide_set_media_lock(ide_drive_t *, struct gendisk *, int);
  1177 +void ide_create_request_sense_cmd(ide_drive_t *, struct ide_atapi_pc *);
  1178 +void ide_retry_pc(ide_drive_t *, struct gendisk *);
1179 1179  
1180 1180 static inline unsigned long ide_scsi_get_timeout(struct ide_atapi_pc *pc)
1181 1181 {
... ... @@ -1186,7 +1186,6 @@
1186 1186  
1187 1187 ide_startstop_t ide_pc_intr(ide_drive_t *drive, ide_handler_t *handler,
1188 1188 void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *),
1189   - void (*retry_pc)(ide_drive_t *),
1190 1189 int (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned int,
1191 1190 int));
1192 1191 ide_startstop_t ide_transfer_pc(ide_drive_t *,