net: mvmdio: orion_mdio_ready: remove manual poll

Replace manual poll of MVMDIO_SMI_READ_VALID with a call to
orion_mdio_wait_ready.  This ensures a consistent timeout,
eliminates a busy loop, and allows for use of interrupts on
systems that support them.

Signed-off-by: Leigh Brown <leigh@solinno.co.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Leigh Brown 2013-10-29 09:33:32 +00:00 committed by David S. Miller
parent b70cd1c1a9
commit 839f46bb4c

View file

@ -110,43 +110,35 @@ static int orion_mdio_read(struct mii_bus *bus, int mii_id,
int regnum) int regnum)
{ {
struct orion_mdio_dev *dev = bus->priv; struct orion_mdio_dev *dev = bus->priv;
int count;
u32 val; u32 val;
int ret; int ret;
mutex_lock(&dev->lock); mutex_lock(&dev->lock);
ret = orion_mdio_wait_ready(bus); ret = orion_mdio_wait_ready(bus);
if (ret < 0) { if (ret < 0)
mutex_unlock(&dev->lock); goto out;
return ret;
}
writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) | writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
(regnum << MVMDIO_SMI_PHY_REG_SHIFT) | (regnum << MVMDIO_SMI_PHY_REG_SHIFT) |
MVMDIO_SMI_READ_OPERATION), MVMDIO_SMI_READ_OPERATION),
dev->regs); dev->regs);
/* Wait for the value to become available */ ret = orion_mdio_wait_ready(bus);
count = 0; if (ret < 0)
while (1) { goto out;
val = readl(dev->regs);
if (val & MVMDIO_SMI_READ_VALID)
break;
if (count > 100) { val = readl(dev->regs);
dev_err(bus->parent, "Timeout when reading PHY\n"); if (!(val & MVMDIO_SMI_READ_VALID)) {
mutex_unlock(&dev->lock); dev_err(bus->parent, "SMI bus read not valid\n");
return -ETIMEDOUT; ret = -ENODEV;
} goto out;
udelay(10);
count++;
} }
ret = val & 0xFFFF;
out:
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
return ret;
return val & 0xFFFF;
} }
static int orion_mdio_write(struct mii_bus *bus, int mii_id, static int orion_mdio_write(struct mii_bus *bus, int mii_id,