summaryrefslogtreecommitdiff
path: root/drivers/scsi
diff options
context:
space:
mode:
authorBrian King <brking@us.ibm.com>2006-03-23 17:30:02 -0600
committerJeff Garzik <jeff@garzik.org>2006-03-24 10:18:43 -0500
commiteb3f0f9c6c3416016565c8b91644d7386889e565 (patch)
tree2b9d7baee57bcae271f5708fc5c09cc71a8698a4 /drivers/scsi
parent2e9edbf815e42f93dd29a9981f27bd421acc47df (diff)
[PATCH] libata: ata_scsi_queuecmd cleanup
Encapsulate part of ata_scsi_queuecmd so that it can be reused by future SAS patches. Signed-off-by: Brian King <brking@us.ibm.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/libata-scsi.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index b7df37ed4393..8192ddd62974 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -2597,6 +2597,21 @@ static inline void ata_scsi_dump_cdb(struct ata_port *ap,
#endif
}
+static inline void __ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *),
+ struct ata_port *ap, struct ata_device *dev)
+{
+ if (dev->class == ATA_DEV_ATA) {
+ ata_xlat_func_t xlat_func = ata_get_xlat_func(dev,
+ cmd->cmnd[0]);
+
+ if (xlat_func)
+ ata_scsi_translate(ap, dev, cmd, done, xlat_func);
+ else
+ ata_scsi_simulate(ap, dev, cmd, done);
+ } else
+ ata_scsi_translate(ap, dev, cmd, done, atapi_xlat);
+}
+
/**
* ata_scsi_queuecmd - Issue SCSI cdb to libata-managed device
* @cmd: SCSI command to be sent
@@ -2631,24 +2646,13 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
ata_scsi_dump_cdb(ap, cmd);
dev = ata_scsi_find_dev(ap, scsidev);
- if (unlikely(!dev)) {
+ if (likely(dev))
+ __ata_scsi_queuecmd(cmd, done, ap, dev);
+ else {
cmd->result = (DID_BAD_TARGET << 16);
done(cmd);
- goto out_unlock;
}
- if (dev->class == ATA_DEV_ATA) {
- ata_xlat_func_t xlat_func = ata_get_xlat_func(dev,
- cmd->cmnd[0]);
-
- if (xlat_func)
- ata_scsi_translate(ap, dev, cmd, done, xlat_func);
- else
- ata_scsi_simulate(ap, dev, cmd, done);
- } else
- ata_scsi_translate(ap, dev, cmd, done, atapi_xlat);
-
-out_unlock:
spin_unlock(&ap->host_set->lock);
spin_lock(shost->host_lock);
return 0;