diff options
-rw-r--r-- | drivers/scsi/libata-scsi.c | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index 9e5cb9f748e6..b45b8b34c0ca 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -52,8 +52,12 @@ | |||
52 | #define SECTOR_SIZE 512 | 52 | #define SECTOR_SIZE 512 |
53 | 53 | ||
54 | typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd); | 54 | typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd); |
55 | static struct ata_device * | 55 | |
56 | ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev); | 56 | static struct ata_device * __ata_scsi_find_dev(struct ata_port *ap, |
57 | const struct scsi_device *scsidev); | ||
58 | static struct ata_device * ata_scsi_find_dev(struct ata_port *ap, | ||
59 | const struct scsi_device *scsidev); | ||
60 | |||
57 | 61 | ||
58 | #define RW_RECOVERY_MPAGE 0x1 | 62 | #define RW_RECOVERY_MPAGE 0x1 |
59 | #define RW_RECOVERY_MPAGE_LEN 12 | 63 | #define RW_RECOVERY_MPAGE_LEN 12 |
@@ -2308,6 +2312,23 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd) | |||
2308 | return 0; | 2312 | return 0; |
2309 | } | 2313 | } |
2310 | 2314 | ||
2315 | static struct ata_device * ata_find_dev(struct ata_port *ap, int id) | ||
2316 | { | ||
2317 | if (likely(id < ATA_MAX_DEVICES)) | ||
2318 | return &ap->device[id]; | ||
2319 | return NULL; | ||
2320 | } | ||
2321 | |||
2322 | static struct ata_device * __ata_scsi_find_dev(struct ata_port *ap, | ||
2323 | const struct scsi_device *scsidev) | ||
2324 | { | ||
2325 | /* skip commands not addressed to targets we simulate */ | ||
2326 | if (unlikely(scsidev->channel || scsidev->lun)) | ||
2327 | return NULL; | ||
2328 | |||
2329 | return ata_find_dev(ap, scsidev->id); | ||
2330 | } | ||
2331 | |||
2311 | /** | 2332 | /** |
2312 | * ata_scsi_find_dev - lookup ata_device from scsi_cmnd | 2333 | * ata_scsi_find_dev - lookup ata_device from scsi_cmnd |
2313 | * @ap: ATA port to which the device is attached | 2334 | * @ap: ATA port to which the device is attached |
@@ -2324,23 +2345,12 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd) | |||
2324 | * RETURNS: | 2345 | * RETURNS: |
2325 | * Associated ATA device, or %NULL if not found. | 2346 | * Associated ATA device, or %NULL if not found. |
2326 | */ | 2347 | */ |
2327 | |||
2328 | static struct ata_device * | 2348 | static struct ata_device * |
2329 | ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev) | 2349 | ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev) |
2330 | { | 2350 | { |
2331 | struct ata_device *dev; | 2351 | struct ata_device *dev = __ata_scsi_find_dev(ap, scsidev); |
2332 | |||
2333 | /* skip commands not addressed to targets we simulate */ | ||
2334 | if (likely(scsidev->id < ATA_MAX_DEVICES)) | ||
2335 | dev = &ap->device[scsidev->id]; | ||
2336 | else | ||
2337 | return NULL; | ||
2338 | |||
2339 | if (unlikely((scsidev->channel != 0) || | ||
2340 | (scsidev->lun != 0))) | ||
2341 | return NULL; | ||
2342 | 2352 | ||
2343 | if (unlikely(!ata_dev_enabled(dev))) | 2353 | if (unlikely(!dev || !ata_dev_enabled(dev))) |
2344 | return NULL; | 2354 | return NULL; |
2345 | 2355 | ||
2346 | if (!atapi_enabled || (ap->flags & ATA_FLAG_NO_ATAPI)) { | 2356 | if (!atapi_enabled || (ap->flags & ATA_FLAG_NO_ATAPI)) { |