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