Skip to content

Commit 9cff441

Browse files
Ondrej Zarydavem330
authored andcommitted
tlan: Add PHY reset timeout
Add a timeout to prevent infinite loop waiting for PHY to reset. Signed-off-by: Ondrej Zary <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 278e48b commit 9cff441

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/net/ethernet/ti/tlan.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2568,16 +2568,21 @@ static void tlan_phy_reset(struct net_device *dev)
25682568
struct tlan_priv *priv = netdev_priv(dev);
25692569
u16 phy;
25702570
u16 value;
2571+
unsigned long timeout = jiffies + HZ;
25712572

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

25742575
TLAN_DBG(TLAN_DEBUG_GNRL, "%s: Resetting PHY.\n", dev->name);
25752576
tlan_mii_sync(dev->base_addr);
25762577
value = MII_GC_LOOPBK | MII_GC_RESET;
25772578
tlan_mii_write_reg(dev, phy, MII_GEN_CTL, value);
2578-
tlan_mii_read_reg(dev, phy, MII_GEN_CTL, &value);
2579-
while (value & MII_GC_RESET)
2579+
do {
25802580
tlan_mii_read_reg(dev, phy, MII_GEN_CTL, &value);
2581+
if (time_after(jiffies, timeout)) {
2582+
netdev_err(dev, "PHY reset timeout\n");
2583+
return;
2584+
}
2585+
} while (value & MII_GC_RESET);
25812586

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

0 commit comments

Comments
 (0)