Commit 09e7fae9 authored by Florian Fainelli's avatar Florian Fainelli Committed by David S. Miller

r6040: check MDIO register busy waiting result

We are currently busy waiting for MDIO registers to complete their
operation but we did not propagate the result back to the caller.
Update r6040_phy_{read,write} to report the busy waiting result
accordingly.
Signed-off-by: default avatarFlorian Fainelli <florian@openwrt.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7a674200
...@@ -224,11 +224,14 @@ static int r6040_phy_read(void __iomem *ioaddr, int phy_addr, int reg) ...@@ -224,11 +224,14 @@ static int r6040_phy_read(void __iomem *ioaddr, int phy_addr, int reg)
break; break;
} }
if (limit < 0)
return -ETIMEDOUT;
return ioread16(ioaddr + MMRD); return ioread16(ioaddr + MMRD);
} }
/* Write a word data from PHY Chip */ /* Write a word data from PHY Chip */
static void r6040_phy_write(void __iomem *ioaddr, static int r6040_phy_write(void __iomem *ioaddr,
int phy_addr, int reg, u16 val) int phy_addr, int reg, u16 val)
{ {
int limit = MAC_DEF_TIMEOUT; int limit = MAC_DEF_TIMEOUT;
...@@ -243,6 +246,8 @@ static void r6040_phy_write(void __iomem *ioaddr, ...@@ -243,6 +246,8 @@ static void r6040_phy_write(void __iomem *ioaddr,
if (!(cmd & MDIO_WRITE)) if (!(cmd & MDIO_WRITE))
break; break;
} }
return (limit < 0) ? -ETIMEDOUT : 0;
} }
static int r6040_mdiobus_read(struct mii_bus *bus, int phy_addr, int reg) static int r6040_mdiobus_read(struct mii_bus *bus, int phy_addr, int reg)
...@@ -261,9 +266,7 @@ static int r6040_mdiobus_write(struct mii_bus *bus, int phy_addr, ...@@ -261,9 +266,7 @@ static int r6040_mdiobus_write(struct mii_bus *bus, int phy_addr,
struct r6040_private *lp = netdev_priv(dev); struct r6040_private *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->base; void __iomem *ioaddr = lp->base;
r6040_phy_write(ioaddr, phy_addr, reg, value); return r6040_phy_write(ioaddr, phy_addr, reg, value);
return 0;
} }
static int r6040_mdiobus_reset(struct mii_bus *bus) static int r6040_mdiobus_reset(struct mii_bus *bus)
......
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