aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/scsi.c')
-rw-r--r--drivers/scsi/scsi.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index a5de1a829a76..192948822455 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -59,6 +59,7 @@
59#include <scsi/scsi_cmnd.h> 59#include <scsi/scsi_cmnd.h>
60#include <scsi/scsi_dbg.h> 60#include <scsi/scsi_dbg.h>
61#include <scsi/scsi_device.h> 61#include <scsi/scsi_device.h>
62#include <scsi/scsi_driver.h>
62#include <scsi/scsi_eh.h> 63#include <scsi/scsi_eh.h>
63#include <scsi/scsi_host.h> 64#include <scsi/scsi_host.h>
64#include <scsi/scsi_tcq.h> 65#include <scsi/scsi_tcq.h>
@@ -367,9 +368,8 @@ void scsi_log_send(struct scsi_cmnd *cmd)
367 scsi_print_command(cmd); 368 scsi_print_command(cmd);
368 if (level > 3) { 369 if (level > 3) {
369 printk(KERN_INFO "buffer = 0x%p, bufflen = %d," 370 printk(KERN_INFO "buffer = 0x%p, bufflen = %d,"
370 " done = 0x%p, queuecommand 0x%p\n", 371 " queuecommand 0x%p\n",
371 scsi_sglist(cmd), scsi_bufflen(cmd), 372 scsi_sglist(cmd), scsi_bufflen(cmd),
372 cmd->done,
373 cmd->device->host->hostt->queuecommand); 373 cmd->device->host->hostt->queuecommand);
374 374
375 } 375 }
@@ -442,7 +442,7 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
442#endif 442#endif
443 443
444/* 444/*
445 * Assign a serial number and pid to the request for error recovery 445 * Assign a serial number to the request for error recovery
446 * and debugging purposes. Protected by the Host_Lock of host. 446 * and debugging purposes. Protected by the Host_Lock of host.
447 */ 447 */
448static inline void scsi_cmd_get_serial(struct Scsi_Host *host, struct scsi_cmnd *cmd) 448static inline void scsi_cmd_get_serial(struct Scsi_Host *host, struct scsi_cmnd *cmd)
@@ -450,10 +450,6 @@ static inline void scsi_cmd_get_serial(struct Scsi_Host *host, struct scsi_cmnd
450 cmd->serial_number = host->cmd_serial_number++; 450 cmd->serial_number = host->cmd_serial_number++;
451 if (cmd->serial_number == 0) 451 if (cmd->serial_number == 0)
452 cmd->serial_number = host->cmd_serial_number++; 452 cmd->serial_number = host->cmd_serial_number++;
453
454 cmd->pid = host->cmd_pid++;
455 if (cmd->pid == 0)
456 cmd->pid = host->cmd_pid++;
457} 453}
458 454
459/* 455/*
@@ -658,6 +654,12 @@ void __scsi_done(struct scsi_cmnd *cmd)
658 blk_complete_request(rq); 654 blk_complete_request(rq);
659} 655}
660 656
657/* Move this to a header if it becomes more generally useful */
658static struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
659{
660 return *(struct scsi_driver **)cmd->request->rq_disk->private_data;
661}
662
661/* 663/*
662 * Function: scsi_finish_command 664 * Function: scsi_finish_command
663 * 665 *
@@ -669,6 +671,8 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
669{ 671{
670 struct scsi_device *sdev = cmd->device; 672 struct scsi_device *sdev = cmd->device;
671 struct Scsi_Host *shost = sdev->host; 673 struct Scsi_Host *shost = sdev->host;
674 struct scsi_driver *drv;
675 unsigned int good_bytes;
672 676
673 scsi_device_unbusy(sdev); 677 scsi_device_unbusy(sdev);
674 678
@@ -694,7 +698,13 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
694 "Notifying upper driver of completion " 698 "Notifying upper driver of completion "
695 "(result %x)\n", cmd->result)); 699 "(result %x)\n", cmd->result));
696 700
697 cmd->done(cmd); 701 good_bytes = cmd->request_bufflen;
702 if (cmd->request->cmd_type != REQ_TYPE_BLOCK_PC) {
703 drv = scsi_cmd_to_driver(cmd);
704 if (drv->done)
705 good_bytes = drv->done(cmd);
706 }
707 scsi_io_completion(cmd, good_bytes);
698} 708}
699EXPORT_SYMBOL(scsi_finish_command); 709EXPORT_SYMBOL(scsi_finish_command);
700 710