Commit fe30911b authored by Tejun Heo's avatar Tejun Heo Committed by Jeff Garzik

libata: separate out ata_dev_reread_id()

Separate out ata_dev_reread_id() from ata_dev_revalidate().
ata_dev_reread_id() reads IDENTIFY page and determines whether the
same device is still there.  ata_dev_revalidate() reconfigures after
reread completes.  This will be used by ACPI update.
Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent d1c68fa6
...@@ -3675,8 +3675,8 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class, ...@@ -3675,8 +3675,8 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
} }
/** /**
* ata_dev_revalidate - Revalidate ATA device * ata_dev_reread_id - Re-read IDENTIFY data
* @dev: device to revalidate * @adev: target ATA device
* @readid_flags: read ID flags * @readid_flags: read ID flags
* *
* Re-read IDENTIFY page and make sure @dev is still attached to * Re-read IDENTIFY page and make sure @dev is still attached to
...@@ -3688,29 +3688,50 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class, ...@@ -3688,29 +3688,50 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
* RETURNS: * RETURNS:
* 0 on success, negative errno otherwise * 0 on success, negative errno otherwise
*/ */
int ata_dev_revalidate(struct ata_device *dev, unsigned int readid_flags) int ata_dev_reread_id(struct ata_device *dev, unsigned int readid_flags)
{ {
unsigned int class = dev->class; unsigned int class = dev->class;
u16 *id = (void *)dev->ap->sector_buf; u16 *id = (void *)dev->ap->sector_buf;
int rc; int rc;
if (!ata_dev_enabled(dev)) {
rc = -ENODEV;
goto fail;
}
/* read ID data */ /* read ID data */
rc = ata_dev_read_id(dev, &class, readid_flags, id); rc = ata_dev_read_id(dev, &class, readid_flags, id);
if (rc) if (rc)
goto fail; return rc;
/* is the device still there? */ /* is the device still there? */
if (!ata_dev_same_device(dev, class, id)) { if (!ata_dev_same_device(dev, class, id))
rc = -ENODEV; return -ENODEV;
goto fail;
}
memcpy(dev->id, id, sizeof(id[0]) * ATA_ID_WORDS); memcpy(dev->id, id, sizeof(id[0]) * ATA_ID_WORDS);
return 0;
}
/**
* ata_dev_revalidate - Revalidate ATA device
* @dev: device to revalidate
* @readid_flags: read ID flags
*
* Re-read IDENTIFY page, make sure @dev is still attached to the
* port and reconfigure it according to the new IDENTIFY page.
*
* LOCKING:
* Kernel thread context (may sleep)
*
* RETURNS:
* 0 on success, negative errno otherwise
*/
int ata_dev_revalidate(struct ata_device *dev, unsigned int readid_flags)
{
int rc;
if (!ata_dev_enabled(dev))
return -ENODEV;
/* re-read ID */
rc = ata_dev_reread_id(dev, readid_flags);
if (rc)
goto fail;
/* configure device according to the new ID */ /* configure device according to the new ID */
rc = ata_dev_configure(dev); rc = ata_dev_configure(dev);
......
...@@ -76,7 +76,8 @@ extern unsigned ata_exec_internal_sg(struct ata_device *dev, ...@@ -76,7 +76,8 @@ extern unsigned ata_exec_internal_sg(struct ata_device *dev,
extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd); extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd);
extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
unsigned int flags, u16 *id); unsigned int flags, u16 *id);
extern int ata_dev_revalidate(struct ata_device *dev, unsigned int flags); extern int ata_dev_reread_id(struct ata_device *dev, unsigned int readid_flags);
extern int ata_dev_revalidate(struct ata_device *dev, unsigned int readid_flags);
extern int ata_dev_configure(struct ata_device *dev); extern int ata_dev_configure(struct ata_device *dev);
extern int sata_down_spd_limit(struct ata_port *ap); extern int sata_down_spd_limit(struct ata_port *ap);
extern int sata_set_spd_needed(struct ata_port *ap); extern int sata_set_spd_needed(struct ata_port *ap);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment