Commit 2b9efba48283f34083df6bc53f6752fba4e4d409

Authored by Bartlomiej Zolnierkiewicz
1 parent b14c72127f

ide: add pointer to the current packet command to ide_drive_t

* Add pointer to the current packet command (struct ide_atapi_pc *pc)
  to ide_drive_t and use it instead of the pointer in struct ide_*_obj.

* Use drive->pc in ide_{issue,transfer}_pc() and ide_pc_intr()
  instead of 'pc' argument.

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 6 changed files with 60 additions and 70 deletions Side-by-side Diff

drivers/ide/ide-atapi.c
... ... @@ -204,12 +204,13 @@
204 204 EXPORT_SYMBOL_GPL(ide_set_media_lock);
205 205  
206 206 /* TODO: unify the code thus making some arguments go away */
207   -ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
  207 +ide_startstop_t ide_pc_intr(ide_drive_t *drive,
208 208 ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry,
209 209 void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *),
210 210 void (*retry_pc)(ide_drive_t *),
211 211 int (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int))
212 212 {
  213 + struct ide_atapi_pc *pc = drive->pc;
213 214 ide_hwif_t *hwif = drive->hwif;
214 215 struct request *rq = hwif->hwgroup->rq;
215 216 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
216 217  
... ... @@ -416,10 +417,11 @@
416 417 return ireason;
417 418 }
418 419  
419   -ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc,
  420 +ide_startstop_t ide_transfer_pc(ide_drive_t *drive,
420 421 ide_handler_t *handler, unsigned int timeout,
421 422 ide_expiry_t *expiry)
422 423 {
  424 + struct ide_atapi_pc *pc = drive->pc;
423 425 ide_hwif_t *hwif = drive->hwif;
424 426 struct request *rq = hwif->hwgroup->rq;
425 427 ide_startstop_t startstop;
426 428  
... ... @@ -458,10 +460,11 @@
458 460 }
459 461 EXPORT_SYMBOL_GPL(ide_transfer_pc);
460 462  
461   -ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_atapi_pc *pc,
  463 +ide_startstop_t ide_issue_pc(ide_drive_t *drive,
462 464 ide_handler_t *handler, unsigned int timeout,
463 465 ide_expiry_t *expiry)
464 466 {
  467 + struct ide_atapi_pc *pc = drive->pc;
465 468 ide_hwif_t *hwif = drive->hwif;
466 469 u16 bcount;
467 470 u8 dma = 0;
drivers/ide/ide-floppy.c
... ... @@ -159,7 +159,7 @@
159 159 static void ide_floppy_callback(ide_drive_t *drive, int dsc)
160 160 {
161 161 idefloppy_floppy_t *floppy = drive->driver_data;
162   - struct ide_atapi_pc *pc = floppy->pc;
  162 + struct ide_atapi_pc *pc = drive->pc;
163 163 int uptodate = pc->error ? 0 : 1;
164 164  
165 165 debug_log("Reached %s\n", __func__);
... ... @@ -171,7 +171,7 @@
171 171 (pc->rq && blk_pc_request(pc->rq)))
172 172 uptodate = 1; /* FIXME */
173 173 else if (pc->c[0] == GPCMD_REQUEST_SENSE) {
174   - u8 *buf = floppy->pc->buf;
  174 + u8 *buf = pc->buf;
175 175  
176 176 if (!pc->error) {
177 177 floppy->sense_key = buf[2] & 0x0F;
... ... @@ -219,9 +219,7 @@
219 219 /* The usual interrupt handler called during a packet command. */
220 220 static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
221 221 {
222   - idefloppy_floppy_t *floppy = drive->driver_data;
223   -
224   - return ide_pc_intr(drive, floppy->pc, idefloppy_pc_intr,
  222 + return ide_pc_intr(drive, idefloppy_pc_intr,
225 223 WAIT_FLOPPY_CMD, NULL, idefloppy_update_buffers,
226 224 idefloppy_retry_pc, ide_io_buffers);
227 225 }
228 226  
... ... @@ -234,10 +232,8 @@
234 232 */
235 233 static int idefloppy_transfer_pc(ide_drive_t *drive)
236 234 {
237   - idefloppy_floppy_t *floppy = drive->driver_data;
238   -
239 235 /* Send the actual packet */
240   - drive->hwif->tp_ops->output_data(drive, NULL, floppy->pc->c, 12);
  236 + drive->hwif->tp_ops->output_data(drive, NULL, drive->pc->c, 12);
241 237  
242 238 /* Timeout for the packet command */
243 239 return WAIT_FLOPPY_CMD;
... ... @@ -251,7 +247,6 @@
251 247 static ide_startstop_t idefloppy_start_pc_transfer(ide_drive_t *drive)
252 248 {
253 249 idefloppy_floppy_t *floppy = drive->driver_data;
254   - struct ide_atapi_pc *pc = floppy->pc;
255 250 ide_expiry_t *expiry;
256 251 unsigned int timeout;
257 252  
... ... @@ -271,7 +266,7 @@
271 266 expiry = NULL;
272 267 }
273 268  
274   - return ide_transfer_pc(drive, pc, idefloppy_pc_intr, timeout, expiry);
  269 + return ide_transfer_pc(drive, idefloppy_pc_intr, timeout, expiry);
275 270 }
276 271  
277 272 static void ide_floppy_report_error(idefloppy_floppy_t *floppy,
278 273  
... ... @@ -298,8 +293,9 @@
298 293 if (floppy->failed_pc == NULL &&
299 294 pc->c[0] != GPCMD_REQUEST_SENSE)
300 295 floppy->failed_pc = pc;
  296 +
301 297 /* Set the current packet command */
302   - floppy->pc = pc;
  298 + drive->pc = pc;
303 299  
304 300 if (pc->retries > IDEFLOPPY_MAX_PC_RETRIES) {
305 301 if (!(pc->flags & PC_FLAG_SUPPRESS_ERROR))
... ... @@ -316,7 +312,7 @@
316 312  
317 313 pc->retries++;
318 314  
319   - return ide_issue_pc(drive, pc, idefloppy_start_pc_transfer,
  315 + return ide_issue_pc(drive, idefloppy_start_pc_transfer,
320 316 WAIT_FLOPPY_CMD, NULL);
321 317 }
322 318  
drivers/ide/ide-floppy.h
... ... @@ -13,8 +13,6 @@
13 13 struct kref kref;
14 14 unsigned int openers; /* protected by BKL for now */
15 15  
16   - /* Current packet command */
17   - struct ide_atapi_pc *pc;
18 16 /* Last failed packet command */
19 17 struct ide_atapi_pc *failed_pc;
20 18 /* used for blk_{fs,pc}_request() requests */
drivers/ide/ide-tape.c
... ... @@ -172,15 +172,11 @@
172 172 struct kref kref;
173 173  
174 174 /*
175   - * pc points to the current processed packet command.
176   - *
177 175 * failed_pc points to the last failed packet command, or contains
178 176 * NULL if we do not need to retry any packet command. This is
179 177 * required since an additional packet command is needed before the
180 178 * retry, to get detailed information on what went wrong.
181 179 */
182   - /* Current packet command */
183   - struct ide_atapi_pc *pc;
184 180 /* Last failed packet command */
185 181 struct ide_atapi_pc *failed_pc;
186 182 /* used by REQ_IDETAPE_{READ,WRITE} requests */
... ... @@ -527,7 +523,7 @@
527 523 static void ide_tape_callback(ide_drive_t *drive, int dsc)
528 524 {
529 525 idetape_tape_t *tape = drive->driver_data;
530   - struct ide_atapi_pc *pc = tape->pc;
  526 + struct ide_atapi_pc *pc = drive->pc;
531 527 int uptodate = pc->error ? 0 : 1;
532 528  
533 529 debug_log(DBG_PROCS, "Enter %s\n", __func__);
... ... @@ -563,7 +559,7 @@
563 559 if (pc->error)
564 560 uptodate = pc->error;
565 561 } else if (pc->c[0] == READ_POSITION && uptodate) {
566   - u8 *readpos = tape->pc->buf;
  562 + u8 *readpos = pc->buf;
567 563  
568 564 debug_log(DBG_SENSE, "BOP - %s\n",
569 565 (readpos[0] & 0x80) ? "Yes" : "No");
... ... @@ -659,9 +655,7 @@
659 655 */
660 656 static ide_startstop_t idetape_pc_intr(ide_drive_t *drive)
661 657 {
662   - idetape_tape_t *tape = drive->driver_data;
663   -
664   - return ide_pc_intr(drive, tape->pc, idetape_pc_intr, WAIT_TAPE_CMD,
  658 + return ide_pc_intr(drive, idetape_pc_intr, WAIT_TAPE_CMD,
665 659 NULL, idetape_update_buffers, idetape_retry_pc,
666 660 ide_tape_io_buffers);
667 661 }
... ... @@ -669,7 +663,7 @@
669 663 /*
670 664 * Packet Command Interface
671 665 *
672   - * The current Packet Command is available in tape->pc, and will not change
  666 + * The current Packet Command is available in drive->pc, and will not change
673 667 * until we finish handling it. Each packet command is associated with a
674 668 * callback function that will be called when the command is finished.
675 669 *
... ... @@ -704,10 +698,7 @@
704 698 */
705 699 static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive)
706 700 {
707   - idetape_tape_t *tape = drive->driver_data;
708   -
709   - return ide_transfer_pc(drive, tape->pc, idetape_pc_intr,
710   - WAIT_TAPE_CMD, NULL);
  701 + return ide_transfer_pc(drive, idetape_pc_intr, WAIT_TAPE_CMD, NULL);
711 702 }
712 703  
713 704 static ide_startstop_t idetape_issue_pc(ide_drive_t *drive,
... ... @@ -715,7 +706,7 @@
715 706 {
716 707 idetape_tape_t *tape = drive->driver_data;
717 708  
718   - if (tape->pc->c[0] == REQUEST_SENSE &&
  709 + if (drive->pc->c[0] == REQUEST_SENSE &&
719 710 pc->c[0] == REQUEST_SENSE) {
720 711 printk(KERN_ERR "ide-tape: possible ide-tape.c bug - "
721 712 "Two request sense in serial were issued\n");
722 713  
... ... @@ -723,8 +714,9 @@
723 714  
724 715 if (tape->failed_pc == NULL && pc->c[0] != REQUEST_SENSE)
725 716 tape->failed_pc = pc;
  717 +
726 718 /* Set the current packet command */
727   - tape->pc = pc;
  719 + drive->pc = pc;
728 720  
729 721 if (pc->retries > IDETAPE_MAX_PC_RETRIES ||
730 722 (pc->flags & PC_FLAG_ABORT)) {
... ... @@ -755,8 +747,7 @@
755 747  
756 748 pc->retries++;
757 749  
758   - return ide_issue_pc(drive, pc, idetape_transfer_pc,
759   - WAIT_TAPE_CMD, NULL);
  750 + return ide_issue_pc(drive, idetape_transfer_pc, WAIT_TAPE_CMD, NULL);
760 751 }
761 752  
762 753 /* A mode sense command is used to "sense" tape parameters. */
... ... @@ -790,7 +781,7 @@
790 781 {
791 782 ide_hwif_t *hwif = drive->hwif;
792 783 idetape_tape_t *tape = drive->driver_data;
793   - struct ide_atapi_pc *pc = tape->pc;
  784 + struct ide_atapi_pc *pc = drive->pc;
794 785 u8 stat;
795 786  
796 787 stat = hwif->tp_ops->read_status(hwif);
... ... @@ -867,7 +858,7 @@
867 858 }
868 859  
869 860 /* Retry a failed packet command */
870   - if (tape->failed_pc && tape->pc->c[0] == REQUEST_SENSE) {
  861 + if (tape->failed_pc && drive->pc->c[0] == REQUEST_SENSE) {
871 862 pc = tape->failed_pc;
872 863 goto out;
873 864 }
drivers/scsi/ide-scsi.c
... ... @@ -82,7 +82,6 @@
82 82 struct gendisk *disk;
83 83 struct Scsi_Host *host;
84 84  
85   - struct ide_atapi_pc *pc; /* Current packet command */
86 85 unsigned long transform; /* SCSI cmd translation layer */
87 86 unsigned long log; /* log flags */
88 87 } idescsi_scsi_t;
... ... @@ -140,7 +139,7 @@
140 139 static void ide_scsi_callback(ide_drive_t *drive, int dsc)
141 140 {
142 141 idescsi_scsi_t *scsi = drive_to_idescsi(drive);
143   - struct ide_atapi_pc *pc = scsi->pc;
  142 + struct ide_atapi_pc *pc = drive->pc;
144 143  
145 144 if (pc->flags & PC_FLAG_TIMEDOUT)
146 145 debug_log("%s: got timed out packet %lu at %lu\n", __func__,
... ... @@ -267,7 +266,7 @@
267 266 spin_unlock_irqrestore(host->host_lock, flags);
268 267 kfree(pc);
269 268 blk_put_request(rq);
270   - scsi->pc = NULL;
  269 + drive->pc = NULL;
271 270 return 0;
272 271 }
273 272  
... ... @@ -278,8 +277,7 @@
278 277  
279 278 static int idescsi_expiry(ide_drive_t *drive)
280 279 {
281   - idescsi_scsi_t *scsi = drive_to_idescsi(drive);
282   - struct ide_atapi_pc *pc = scsi->pc;
  280 + struct ide_atapi_pc *pc = drive->pc;
283 281  
284 282 debug_log("%s called for %lu at %lu\n", __func__,
285 283 pc->scsi_cmd->serial_number, jiffies);
286 284  
... ... @@ -294,19 +292,14 @@
294 292 */
295 293 static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
296 294 {
297   - idescsi_scsi_t *scsi = drive_to_idescsi(drive);
298   - struct ide_atapi_pc *pc = scsi->pc;
299   -
300   - return ide_pc_intr(drive, pc, idescsi_pc_intr, get_timeout(pc),
  295 + return ide_pc_intr(drive, idescsi_pc_intr, get_timeout(drive->pc),
301 296 idescsi_expiry, NULL, NULL, ide_io_buffers);
302 297 }
303 298  
304 299 static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive)
305 300 {
306   - idescsi_scsi_t *scsi = drive_to_idescsi(drive);
307   -
308   - return ide_transfer_pc(drive, scsi->pc, idescsi_pc_intr,
309   - get_timeout(scsi->pc), idescsi_expiry);
  301 + return ide_transfer_pc(drive, idescsi_pc_intr,
  302 + get_timeout(drive->pc), idescsi_expiry);
310 303 }
311 304  
312 305 static inline int idescsi_set_direction(struct ide_atapi_pc *pc)
313 306  
314 307  
... ... @@ -351,12 +344,10 @@
351 344 static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive,
352 345 struct ide_atapi_pc *pc)
353 346 {
354   - idescsi_scsi_t *scsi = drive_to_idescsi(drive);
355   -
356 347 /* Set the current packet command */
357   - scsi->pc = pc;
  348 + drive->pc = pc;
358 349  
359   - return ide_issue_pc(drive, pc, idescsi_transfer_pc,
  350 + return ide_issue_pc(drive, idescsi_transfer_pc,
360 351 get_timeout(pc), idescsi_expiry);
361 352 }
362 353  
... ... @@ -621,6 +612,8 @@
621 612 int busy;
622 613 int ret = FAILED;
623 614  
  615 + struct ide_atapi_pc *pc;
  616 +
624 617 /* In idescsi_eh_abort we try to gently pry our command from the ide subsystem */
625 618  
626 619 if (test_bit(IDESCSI_LOG_CMD, &scsi->log))
627 620  
628 621  
629 622  
... ... @@ -641,26 +634,27 @@
641 634 spin_lock_irq(&ide_lock);
642 635  
643 636 /* If there is no pc running we're done (our interrupt took care of it) */
644   - if (!scsi->pc) {
  637 + pc = drive->pc;
  638 + if (pc == NULL) {
645 639 ret = SUCCESS;
646 640 goto ide_unlock;
647 641 }
648 642  
649 643 /* It's somewhere in flight. Does ide subsystem agree? */
650   - if (scsi->pc->scsi_cmd->serial_number == cmd->serial_number && !busy &&
651   - elv_queue_empty(drive->queue) && HWGROUP(drive)->rq != scsi->pc->rq) {
  644 + if (pc->scsi_cmd->serial_number == cmd->serial_number && !busy &&
  645 + elv_queue_empty(drive->queue) && HWGROUP(drive)->rq != pc->rq) {
652 646 /*
653 647 * FIXME - not sure this condition can ever occur
654 648 */
655 649 printk (KERN_ERR "ide-scsi: cmd aborted!\n");
656 650  
657   - if (blk_sense_request(scsi->pc->rq))
658   - kfree(scsi->pc->buf);
  651 + if (blk_sense_request(pc->rq))
  652 + kfree(pc->buf);
659 653 /* we need to call blk_put_request twice. */
660   - blk_put_request(scsi->pc->rq);
661   - blk_put_request(scsi->pc->rq);
662   - kfree(scsi->pc);
663   - scsi->pc = NULL;
  654 + blk_put_request(pc->rq);
  655 + blk_put_request(pc->rq);
  656 + kfree(pc);
  657 + drive->pc = NULL;
664 658  
665 659 ret = SUCCESS;
666 660 }
... ... @@ -682,6 +676,8 @@
682 676 int ready = 0;
683 677 int ret = SUCCESS;
684 678  
  679 + struct ide_atapi_pc *pc;
  680 +
685 681 /* In idescsi_eh_reset we forcefully remove the command from the ide subsystem and reset the device. */
686 682  
687 683 if (test_bit(IDESCSI_LOG_CMD, &scsi->log))
... ... @@ -696,7 +692,9 @@
696 692 spin_lock_irq(cmd->device->host->host_lock);
697 693 spin_lock(&ide_lock);
698 694  
699   - if (!scsi->pc || (req = scsi->pc->rq) != HWGROUP(drive)->rq || !HWGROUP(drive)->handler) {
  695 + pc = drive->pc;
  696 +
  697 + if (pc == NULL || (req = pc->rq) != HWGROUP(drive)->rq || !HWGROUP(drive)->handler) {
700 698 printk (KERN_WARNING "ide-scsi: No active request in idescsi_eh_reset\n");
701 699 spin_unlock(&ide_lock);
702 700 spin_unlock_irq(cmd->device->host->host_lock);
... ... @@ -707,9 +705,9 @@
707 705 if (__blk_end_request(req, -EIO, 0))
708 706 BUG();
709 707 if (blk_sense_request(req))
710   - kfree(scsi->pc->buf);
711   - kfree(scsi->pc);
712   - scsi->pc = NULL;
  708 + kfree(pc->buf);
  709 + kfree(pc);
  710 + drive->pc = NULL;
713 711 blk_put_request(req);
714 712  
715 713 /* now nuke the drive queue */
... ... @@ -322,6 +322,7 @@
322 322 ide_started, /* a drive operation was started, handler was set */
323 323 } ide_startstop_t;
324 324  
  325 +struct ide_atapi_pc;
325 326 struct ide_devset;
326 327 struct ide_driver_s;
327 328  
... ... @@ -484,6 +485,9 @@
484 485 struct device gendev;
485 486 struct completion gendev_rel_comp; /* to deal with device release() */
486 487  
  488 + /* current packet command */
  489 + struct ide_atapi_pc *pc;
  490 +
487 491 /* callback for packet commands */
488 492 void (*pc_callback)(struct ide_drive_s *, int);
489 493  
490 494  
491 495  
... ... @@ -1171,15 +1175,15 @@
1171 1175 int ide_do_start_stop(ide_drive_t *, struct gendisk *, int);
1172 1176 int ide_set_media_lock(ide_drive_t *, struct gendisk *, int);
1173 1177  
1174   -ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
  1178 +ide_startstop_t ide_pc_intr(ide_drive_t *drive,
1175 1179 ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry,
1176 1180 void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *),
1177 1181 void (*retry_pc)(ide_drive_t *),
1178 1182 int (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned int,
1179 1183 int));
1180   -ide_startstop_t ide_transfer_pc(ide_drive_t *, struct ide_atapi_pc *,
  1184 +ide_startstop_t ide_transfer_pc(ide_drive_t *,
1181 1185 ide_handler_t *, unsigned int, ide_expiry_t *);
1182   -ide_startstop_t ide_issue_pc(ide_drive_t *, struct ide_atapi_pc *,
  1186 +ide_startstop_t ide_issue_pc(ide_drive_t *,
1183 1187 ide_handler_t *, unsigned int, ide_expiry_t *);
1184 1188  
1185 1189 ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *);