From 9956226fbbc6fda84dcd5298723ad4827b037c58 Mon Sep 17 00:00:00 2001 From: Anton Bondarenko Date: Wed, 4 Nov 2015 22:23:04 +0100 Subject: net: phy: wait for link OK after successfull autonegotiation It may take some time for PHY to indicate link OK status after autonegotiation completed. This change addresses this case and prevent network commands fails due to the delay. Signed-off-by: Anton Bondarenko Signed-off-by: Sascha Hauer --- drivers/net/phy/phy.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 2b3c5e2e02..25c999c550 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -502,13 +502,16 @@ int phy_wait_aneg_done(struct phy_device *phydev) return 0; while (!is_timeout(start, PHY_AN_TIMEOUT * SECOND)) { - if (phy_aneg_done(phydev) > 0) { - phydev->link = 1; - return 0; - } + if (phy_aneg_done(phydev) > 0) + break; } - phydev->link = 0; + do { + genphy_update_link(phydev); + if (phydev->link == 1) + return 0; + } while (!is_timeout(start, PHY_AN_TIMEOUT * SECOND)); + return -ETIMEDOUT; } -- cgit v1.2.3