aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-13 15:39:31 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-13 15:39:31 -0400
commit2b9efba48283f34083df6bc53f6752fba4e4d409 (patch)
tree215d86f1934c896f8ec609ab033b69bf5b99e217 /drivers/scsi
parentb14c72127fbe8f97e49de7437520175673f7306a (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>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/ide-scsi.c58
1 files changed, 28 insertions, 30 deletions
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index b9bfec24e91..bb8b3b123c7 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);
140static void ide_scsi_callback(ide_drive_t *drive, int dsc) 139static 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
279static int idescsi_expiry(ide_drive_t *drive) 278static 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 */
295static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) 293static 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
304static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive) 299static 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
312static inline int idescsi_set_direction(struct ide_atapi_pc *pc) 305static 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)
351static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive, 344static 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 */