net: phy: don't double-read link status register if link is up
authorHeiner Kallweit <hkallweit1@gmail.com>
Thu, 7 Feb 2019 19:22:20 +0000 (20:22 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sat, 9 Feb 2019 07:01:49 +0000 (23:01 -0800)
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 <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phy-c45.c
drivers/net/phy/phy_device.c

index 706a92a8c1b29e09bc9e1cb0593248c14ab8e90a..eff9e5a4d831ca31ad4836b1426f2ae547b628f6 100644 (file)
@@ -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);
index d490cd2a8962b9acecc754e809eb9fdbffeed81e..9369e1323c396a6e0d8443967bcf358280de6ad9 100644 (file)
@@ -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 */