From: Heiner Kallweit Date: Thu, 7 Feb 2019 19:22:20 +0000 (+0100) Subject: net: phy: don't double-read link status register if link is up X-Git-Tag: v5.1-rc1~178^2~295 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c397ab21ba362d5c5215e53f36685a9fffc45f66;p=thirdparty%2Fkernel%2Flinux.git net: phy: don't double-read link status register if link is up The link status register latches link-down events. Therefore, if link is reported as being up, there's no need for a second read. Signed-off-by: Heiner Kallweit Signed-off-by: David S. Miller --- diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index 706a92a8c1b29..eff9e5a4d831c 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -148,6 +148,8 @@ int genphy_c45_read_link(struct phy_device *phydev) val = phy_read_mmd(phydev, devad, MDIO_STAT1); if (val < 0) return val; + else if (val & MDIO_STAT1_LSTATUS) + continue; } val = phy_read_mmd(phydev, devad, MDIO_STAT1); diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index d490cd2a8962b..9369e1323c396 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1735,8 +1735,12 @@ int genphy_update_link(struct phy_device *phydev) */ if (!phy_polling_mode(phydev)) { status = phy_read(phydev, MII_BMSR); - if (status < 0) + if (status < 0) { return status; + } else if (status & BMSR_LSTATUS) { + phydev->link = 1; + return 0; + } } /* Read link and autonegotiation status */