Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 29478
b: refs/heads/master
c: ab5b3a5
h: refs/heads/master
v: v3
  • Loading branch information
Tejun Heo committed May 31, 2006
1 parent 6320e5c commit d6ea6be
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 72fa4b742b327bd1b07985d79a61c61dbd9fd4e6
refs/heads/master: ab5b3a5b2d887ce63f8c6a7fcb9f5c07ca4b4d43
40 changes: 25 additions & 15 deletions trunk/drivers/scsi/libata-scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@
#define SECTOR_SIZE 512

typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd);
static struct ata_device *
ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev);

static struct ata_device * __ata_scsi_find_dev(struct ata_port *ap,
const struct scsi_device *scsidev);
static struct ata_device * ata_scsi_find_dev(struct ata_port *ap,
const struct scsi_device *scsidev);


#define RW_RECOVERY_MPAGE 0x1
#define RW_RECOVERY_MPAGE_LEN 12
Expand Down Expand Up @@ -2308,6 +2312,23 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd)
return 0;
}

static struct ata_device * ata_find_dev(struct ata_port *ap, int id)
{
if (likely(id < ATA_MAX_DEVICES))
return &ap->device[id];
return NULL;
}

static struct ata_device * __ata_scsi_find_dev(struct ata_port *ap,
const struct scsi_device *scsidev)
{
/* skip commands not addressed to targets we simulate */
if (unlikely(scsidev->channel || scsidev->lun))
return NULL;

return ata_find_dev(ap, scsidev->id);
}

/**
* ata_scsi_find_dev - lookup ata_device from scsi_cmnd
* @ap: ATA port to which the device is attached
Expand All @@ -2324,23 +2345,12 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd)
* RETURNS:
* Associated ATA device, or %NULL if not found.
*/

static struct ata_device *
ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev)
{
struct ata_device *dev;

/* skip commands not addressed to targets we simulate */
if (likely(scsidev->id < ATA_MAX_DEVICES))
dev = &ap->device[scsidev->id];
else
return NULL;

if (unlikely((scsidev->channel != 0) ||
(scsidev->lun != 0)))
return NULL;
struct ata_device *dev = __ata_scsi_find_dev(ap, scsidev);

if (unlikely(!ata_dev_enabled(dev)))
if (unlikely(!dev || !ata_dev_enabled(dev)))
return NULL;

if (!atapi_enabled || (ap->flags & ATA_FLAG_NO_ATAPI)) {
Expand Down

0 comments on commit d6ea6be

Please sign in to comment.