diff options
author | Tejun Heo <htejun@gmail.com> | 2006-05-31 05:27:34 -0400 |
---|---|---|
committer | Tejun Heo <htejun@gmail.com> | 2006-05-31 05:27:34 -0400 |
commit | ab5b3a5b2d887ce63f8c6a7fcb9f5c07ca4b4d43 (patch) | |
tree | 397504068ad90818ee6e553438e89bc429acd5fb | |
parent | 72fa4b742b327bd1b07985d79a61c61dbd9fd4e6 (diff) |
[PATCH] libata-hp-prep: update ata_scsi_find_dev() and friends
Separate out ata_find_dev() and __ata_scsi_find_dev() from
ata_scsi_find_dev(). These will be used by later hotplug
implementation.
Signed-off-by: Tejun Heo <htejun@gmail.com>
-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)) { |