[PATCH] libata: implement ata_dev_enabled and disabled()
This patch renames ata_dev_present() to ata_dev_enabled() and adds ata_dev_disabled(). This is to discern the state where a device is present but disabled from not-present state. This disctinction is necessary when configuring transfer mode because device selection timing must not be violated even if a device fails to configure. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
This commit is contained in:
parent
9974e7cc6c
commit
e1211e3fa7
@ -411,7 +411,7 @@ static const char *sata_spd_string(unsigned int spd)
|
|||||||
|
|
||||||
static void ata_dev_disable(struct ata_port *ap, struct ata_device *dev)
|
static void ata_dev_disable(struct ata_port *ap, struct ata_device *dev)
|
||||||
{
|
{
|
||||||
if (ata_dev_present(dev)) {
|
if (ata_dev_enabled(dev)) {
|
||||||
printk(KERN_WARNING "ata%u: dev %u disabled\n",
|
printk(KERN_WARNING "ata%u: dev %u disabled\n",
|
||||||
ap->id, dev->devno);
|
ap->id, dev->devno);
|
||||||
dev->class++;
|
dev->class++;
|
||||||
@ -1222,7 +1222,7 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev,
|
|||||||
unsigned int xfer_mask;
|
unsigned int xfer_mask;
|
||||||
int i, rc;
|
int i, rc;
|
||||||
|
|
||||||
if (!ata_dev_present(dev)) {
|
if (!ata_dev_enabled(dev)) {
|
||||||
DPRINTK("ENTER/EXIT (host %u, dev %u) -- nodev\n",
|
DPRINTK("ENTER/EXIT (host %u, dev %u) -- nodev\n",
|
||||||
ap->id, dev->devno);
|
ap->id, dev->devno);
|
||||||
return 0;
|
return 0;
|
||||||
@ -1401,7 +1401,7 @@ static int ata_bus_probe(struct ata_port *ap)
|
|||||||
|
|
||||||
dev->class = classes[i];
|
dev->class = classes[i];
|
||||||
|
|
||||||
if (!ata_dev_present(dev))
|
if (!ata_dev_enabled(dev))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
WARN_ON(dev->id != NULL);
|
WARN_ON(dev->id != NULL);
|
||||||
@ -1565,7 +1565,7 @@ void sata_phy_reset(struct ata_port *ap)
|
|||||||
struct ata_device *ata_dev_pair(struct ata_port *ap, struct ata_device *adev)
|
struct ata_device *ata_dev_pair(struct ata_port *ap, struct ata_device *adev)
|
||||||
{
|
{
|
||||||
struct ata_device *pair = &ap->device[1 - adev->devno];
|
struct ata_device *pair = &ap->device[1 - adev->devno];
|
||||||
if (!ata_dev_present(pair))
|
if (!ata_dev_enabled(pair))
|
||||||
return NULL;
|
return NULL;
|
||||||
return pair;
|
return pair;
|
||||||
}
|
}
|
||||||
@ -1778,7 +1778,7 @@ static int ata_host_set_pio(struct ata_port *ap)
|
|||||||
for (i = 0; i < ATA_MAX_DEVICES; i++) {
|
for (i = 0; i < ATA_MAX_DEVICES; i++) {
|
||||||
struct ata_device *dev = &ap->device[i];
|
struct ata_device *dev = &ap->device[i];
|
||||||
|
|
||||||
if (!ata_dev_present(dev))
|
if (!ata_dev_enabled(dev))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!dev->pio_mode) {
|
if (!dev->pio_mode) {
|
||||||
@ -1802,7 +1802,7 @@ static void ata_host_set_dma(struct ata_port *ap)
|
|||||||
for (i = 0; i < ATA_MAX_DEVICES; i++) {
|
for (i = 0; i < ATA_MAX_DEVICES; i++) {
|
||||||
struct ata_device *dev = &ap->device[i];
|
struct ata_device *dev = &ap->device[i];
|
||||||
|
|
||||||
if (!ata_dev_present(dev) || !dev->dma_mode)
|
if (!ata_dev_enabled(dev) || !dev->dma_mode)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dev->xfer_mode = dev->dma_mode;
|
dev->xfer_mode = dev->dma_mode;
|
||||||
@ -1830,7 +1830,7 @@ static void ata_set_mode(struct ata_port *ap)
|
|||||||
struct ata_device *dev = &ap->device[i];
|
struct ata_device *dev = &ap->device[i];
|
||||||
unsigned int pio_mask, dma_mask;
|
unsigned int pio_mask, dma_mask;
|
||||||
|
|
||||||
if (!ata_dev_present(dev))
|
if (!ata_dev_enabled(dev))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ata_dev_xfermask(ap, dev);
|
ata_dev_xfermask(ap, dev);
|
||||||
@ -1858,7 +1858,7 @@ static void ata_set_mode(struct ata_port *ap)
|
|||||||
for (i = 0; i < ATA_MAX_DEVICES; i++) {
|
for (i = 0; i < ATA_MAX_DEVICES; i++) {
|
||||||
struct ata_device *dev = &ap->device[i];
|
struct ata_device *dev = &ap->device[i];
|
||||||
|
|
||||||
if (!ata_dev_present(dev))
|
if (!ata_dev_enabled(dev))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
rc = ata_dev_set_mode(ap, dev);
|
rc = ata_dev_set_mode(ap, dev);
|
||||||
@ -2550,7 +2550,7 @@ int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev,
|
|||||||
u16 *id;
|
u16 *id;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (!ata_dev_present(dev))
|
if (!ata_dev_enabled(dev))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
class = dev->class;
|
class = dev->class;
|
||||||
@ -2679,7 +2679,7 @@ static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev)
|
|||||||
/* FIXME: Use port-wide xfermask for now */
|
/* FIXME: Use port-wide xfermask for now */
|
||||||
for (i = 0; i < ATA_MAX_DEVICES; i++) {
|
for (i = 0; i < ATA_MAX_DEVICES; i++) {
|
||||||
struct ata_device *d = &ap->device[i];
|
struct ata_device *d = &ap->device[i];
|
||||||
if (!ata_dev_present(d))
|
if (!ata_dev_enabled(d))
|
||||||
continue;
|
continue;
|
||||||
xfer_mask &= ata_pack_xfermask(d->pio_mask, d->mwdma_mask,
|
xfer_mask &= ata_pack_xfermask(d->pio_mask, d->mwdma_mask,
|
||||||
d->udma_mask);
|
d->udma_mask);
|
||||||
@ -4299,7 +4299,7 @@ int ata_device_resume(struct ata_port *ap, struct ata_device *dev)
|
|||||||
ap->flags &= ~ATA_FLAG_SUSPENDED;
|
ap->flags &= ~ATA_FLAG_SUSPENDED;
|
||||||
ata_set_mode(ap);
|
ata_set_mode(ap);
|
||||||
}
|
}
|
||||||
if (!ata_dev_present(dev))
|
if (!ata_dev_enabled(dev))
|
||||||
return 0;
|
return 0;
|
||||||
if (dev->class == ATA_DEV_ATA)
|
if (dev->class == ATA_DEV_ATA)
|
||||||
ata_start_drive(ap, dev);
|
ata_start_drive(ap, dev);
|
||||||
@ -4317,7 +4317,7 @@ int ata_device_resume(struct ata_port *ap, struct ata_device *dev)
|
|||||||
*/
|
*/
|
||||||
int ata_device_suspend(struct ata_port *ap, struct ata_device *dev, pm_message_t state)
|
int ata_device_suspend(struct ata_port *ap, struct ata_device *dev, pm_message_t state)
|
||||||
{
|
{
|
||||||
if (!ata_dev_present(dev))
|
if (!ata_dev_enabled(dev))
|
||||||
return 0;
|
return 0;
|
||||||
if (dev->class == ATA_DEV_ATA)
|
if (dev->class == ATA_DEV_ATA)
|
||||||
ata_flush_cache(ap, dev);
|
ata_flush_cache(ap, dev);
|
||||||
|
@ -2349,7 +2349,7 @@ ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev)
|
|||||||
(scsidev->lun != 0)))
|
(scsidev->lun != 0)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (unlikely(!ata_dev_present(dev)))
|
if (unlikely(!ata_dev_enabled(dev)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!atapi_enabled || (ap->flags & ATA_FLAG_NO_ATAPI)) {
|
if (!atapi_enabled || (ap->flags & ATA_FLAG_NO_ATAPI)) {
|
||||||
@ -2743,7 +2743,7 @@ void ata_scsi_scan_host(struct ata_port *ap)
|
|||||||
for (i = 0; i < ATA_MAX_DEVICES; i++) {
|
for (i = 0; i < ATA_MAX_DEVICES; i++) {
|
||||||
dev = &ap->device[i];
|
dev = &ap->device[i];
|
||||||
|
|
||||||
if (ata_dev_present(dev))
|
if (ata_dev_enabled(dev))
|
||||||
scsi_scan_target(&ap->host->shost_gendev, 0, i, 0, 0);
|
scsi_scan_target(&ap->host->shost_gendev, 0, i, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1991,7 +1991,7 @@ comreset_retry:
|
|||||||
tf.nsect = readb((void __iomem *) ap->ioaddr.nsect_addr);
|
tf.nsect = readb((void __iomem *) ap->ioaddr.nsect_addr);
|
||||||
|
|
||||||
dev->class = ata_dev_classify(&tf);
|
dev->class = ata_dev_classify(&tf);
|
||||||
if (!ata_dev_present(dev)) {
|
if (!ata_dev_enabled(dev)) {
|
||||||
VPRINTK("Port disabled post-sig: No device present.\n");
|
VPRINTK("Port disabled post-sig: No device present.\n");
|
||||||
ata_port_disable(ap);
|
ata_port_disable(ap);
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ static void sil_post_set_mode (struct ata_port *ap)
|
|||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
dev = &ap->device[i];
|
dev = &ap->device[i];
|
||||||
if (!ata_dev_present(dev))
|
if (!ata_dev_enabled(dev))
|
||||||
dev_mode[i] = 0; /* PIO0/1/2 */
|
dev_mode[i] = 0; /* PIO0/1/2 */
|
||||||
else if (dev->flags & ATA_DFLAG_PIO)
|
else if (dev->flags & ATA_DFLAG_PIO)
|
||||||
dev_mode[i] = 1; /* PIO3/4 */
|
dev_mode[i] = 1; /* PIO3/4 */
|
||||||
|
@ -672,14 +672,24 @@ static inline unsigned int ata_tag_valid(unsigned int tag)
|
|||||||
return (tag < ATA_MAX_QUEUE) ? 1 : 0;
|
return (tag < ATA_MAX_QUEUE) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned int ata_class_present(unsigned int class)
|
static inline unsigned int ata_class_enabled(unsigned int class)
|
||||||
{
|
{
|
||||||
return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI;
|
return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned int ata_dev_present(const struct ata_device *dev)
|
static inline unsigned int ata_class_disabled(unsigned int class)
|
||||||
{
|
{
|
||||||
return ata_class_present(dev->class);
|
return class == ATA_DEV_ATA_UNSUP || class == ATA_DEV_ATAPI_UNSUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned int ata_dev_enabled(const struct ata_device *dev)
|
||||||
|
{
|
||||||
|
return ata_class_enabled(dev->class);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned int ata_dev_disabled(const struct ata_device *dev)
|
||||||
|
{
|
||||||
|
return ata_class_disabled(dev->class);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u8 ata_chk_status(struct ata_port *ap)
|
static inline u8 ata_chk_status(struct ata_port *ap)
|
||||||
|
Loading…
Reference in New Issue
Block a user