提交 4fc5f0aa 编写于 作者: S Sergey Shtylyov 提交者: Damien Le Moal

ata: libata-sff: refactor ata_sff_set_devctl()

Commit 41dec29b ("libata: introduce sff_set_devctl() method") left some
clumsy checks surrounding calls to ata_sff_set_devctl() which Jeff Garzik
suggested to factor out...  and I never followed up. :-(

At last, refactor ata_sff_set_devctl() to include the repetitive checks and
return a 'bool' result indicating if the device control register exists or
not.

While at it, further update the 'kernel-doc' comment -- the device control
register has never been a part of the taskfile, despite what Jeff and co.
think! :-)
Signed-off-by: NSergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: NDamien Le Moal <damien.lemoal@opensource.wdc.com>
上级 b51aa532
...@@ -265,20 +265,26 @@ EXPORT_SYMBOL_GPL(ata_sff_wait_ready); ...@@ -265,20 +265,26 @@ EXPORT_SYMBOL_GPL(ata_sff_wait_ready);
* @ap: port where the device is * @ap: port where the device is
* @ctl: value to write * @ctl: value to write
* *
* Writes ATA taskfile device control register. * Writes ATA device control register.
* *
* Note: may NOT be used as the sff_set_devctl() entry in * RETURN:
* ata_port_operations. * true if the register exists, false if not.
* *
* LOCKING: * LOCKING:
* Inherited from caller. * Inherited from caller.
*/ */
static void ata_sff_set_devctl(struct ata_port *ap, u8 ctl) static bool ata_sff_set_devctl(struct ata_port *ap, u8 ctl)
{ {
if (ap->ops->sff_set_devctl) if (ap->ops->sff_set_devctl) {
ap->ops->sff_set_devctl(ap, ctl); ap->ops->sff_set_devctl(ap, ctl);
else return true;
}
if (ap->ioaddr.ctl_addr) {
iowrite8(ctl, ap->ioaddr.ctl_addr); iowrite8(ctl, ap->ioaddr.ctl_addr);
return true;
}
return false;
} }
/** /**
...@@ -357,8 +363,6 @@ static void ata_dev_select(struct ata_port *ap, unsigned int device, ...@@ -357,8 +363,6 @@ static void ata_dev_select(struct ata_port *ap, unsigned int device,
*/ */
void ata_sff_irq_on(struct ata_port *ap) void ata_sff_irq_on(struct ata_port *ap)
{ {
struct ata_ioports *ioaddr = &ap->ioaddr;
if (ap->ops->sff_irq_on) { if (ap->ops->sff_irq_on) {
ap->ops->sff_irq_on(ap); ap->ops->sff_irq_on(ap);
return; return;
...@@ -367,8 +371,7 @@ void ata_sff_irq_on(struct ata_port *ap) ...@@ -367,8 +371,7 @@ void ata_sff_irq_on(struct ata_port *ap)
ap->ctl &= ~ATA_NIEN; ap->ctl &= ~ATA_NIEN;
ap->last_ctl = ap->ctl; ap->last_ctl = ap->ctl;
if (ap->ops->sff_set_devctl || ioaddr->ctl_addr) ata_sff_set_devctl(ap, ap->ctl);
ata_sff_set_devctl(ap, ap->ctl);
ata_wait_idle(ap); ata_wait_idle(ap);
if (ap->ops->sff_irq_clear) if (ap->ops->sff_irq_clear)
...@@ -1662,8 +1665,7 @@ void ata_sff_freeze(struct ata_port *ap) ...@@ -1662,8 +1665,7 @@ void ata_sff_freeze(struct ata_port *ap)
ap->ctl |= ATA_NIEN; ap->ctl |= ATA_NIEN;
ap->last_ctl = ap->ctl; ap->last_ctl = ap->ctl;
if (ap->ops->sff_set_devctl || ap->ioaddr.ctl_addr) ata_sff_set_devctl(ap, ap->ctl);
ata_sff_set_devctl(ap, ap->ctl);
/* Under certain circumstances, some controllers raise IRQ on /* Under certain circumstances, some controllers raise IRQ on
* ATA_NIEN manipulation. Also, many controllers fail to mask * ATA_NIEN manipulation. Also, many controllers fail to mask
...@@ -2061,10 +2063,8 @@ void ata_sff_postreset(struct ata_link *link, unsigned int *classes) ...@@ -2061,10 +2063,8 @@ void ata_sff_postreset(struct ata_link *link, unsigned int *classes)
return; return;
/* set up device control */ /* set up device control */
if (ap->ops->sff_set_devctl || ap->ioaddr.ctl_addr) { if (ata_sff_set_devctl(ap, ap->ctl))
ata_sff_set_devctl(ap, ap->ctl);
ap->last_ctl = ap->ctl; ap->last_ctl = ap->ctl;
}
} }
EXPORT_SYMBOL_GPL(ata_sff_postreset); EXPORT_SYMBOL_GPL(ata_sff_postreset);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册