Commit 9cff441e authored by Ondrej Zary's avatar Ondrej Zary Committed by David S. Miller

tlan: Add PHY reset timeout

Add a timeout to prevent infinite loop waiting for PHY to reset.
Signed-off-by: default avatarOndrej Zary <linux@rainbow-software.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 278e48b0
...@@ -2568,6 +2568,7 @@ static void tlan_phy_reset(struct net_device *dev) ...@@ -2568,6 +2568,7 @@ static void tlan_phy_reset(struct net_device *dev)
struct tlan_priv *priv = netdev_priv(dev); struct tlan_priv *priv = netdev_priv(dev);
u16 phy; u16 phy;
u16 value; u16 value;
unsigned long timeout = jiffies + HZ;
phy = priv->phy[priv->phy_num]; phy = priv->phy[priv->phy_num];
...@@ -2575,9 +2576,13 @@ static void tlan_phy_reset(struct net_device *dev) ...@@ -2575,9 +2576,13 @@ static void tlan_phy_reset(struct net_device *dev)
tlan_mii_sync(dev->base_addr); tlan_mii_sync(dev->base_addr);
value = MII_GC_LOOPBK | MII_GC_RESET; value = MII_GC_LOOPBK | MII_GC_RESET;
tlan_mii_write_reg(dev, phy, MII_GEN_CTL, value); tlan_mii_write_reg(dev, phy, MII_GEN_CTL, value);
do {
tlan_mii_read_reg(dev, phy, MII_GEN_CTL, &value); tlan_mii_read_reg(dev, phy, MII_GEN_CTL, &value);
while (value & MII_GC_RESET) if (time_after(jiffies, timeout)) {
tlan_mii_read_reg(dev, phy, MII_GEN_CTL, &value); netdev_err(dev, "PHY reset timeout\n");
return;
}
} while (value & MII_GC_RESET);
/* Wait for 500 ms and initialize. /* Wait for 500 ms and initialize.
* I don't remember why I wait this long. * I don't remember why I wait this long.
......
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