Skip to content

Commit

Permalink
tlan: Add PHY reset timeout
Browse files Browse the repository at this point in the history
Add a timeout to prevent infinite loop waiting for PHY to reset.

Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ondrej Zary authored and David S. Miller committed Jul 8, 2014
1 parent 278e48b commit 9cff441
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/net/ethernet/ti/tlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -2568,16 +2568,21 @@ static void tlan_phy_reset(struct net_device *dev)
struct tlan_priv *priv = netdev_priv(dev);
u16 phy;
u16 value;
unsigned long timeout = jiffies + HZ;

phy = priv->phy[priv->phy_num];

TLAN_DBG(TLAN_DEBUG_GNRL, "%s: Resetting PHY.\n", dev->name);
tlan_mii_sync(dev->base_addr);
value = MII_GC_LOOPBK | MII_GC_RESET;
tlan_mii_write_reg(dev, phy, MII_GEN_CTL, value);
tlan_mii_read_reg(dev, phy, MII_GEN_CTL, &value);
while (value & MII_GC_RESET)
do {
tlan_mii_read_reg(dev, phy, MII_GEN_CTL, &value);
if (time_after(jiffies, timeout)) {
netdev_err(dev, "PHY reset timeout\n");
return;
}
} while (value & MII_GC_RESET);

/* Wait for 500 ms and initialize.
* I don't remember why I wait this long.
Expand Down

0 comments on commit 9cff441

Please sign in to comment.