net: phy: read MII_CTRL1000 in genphy_read_status only if needed
authorHeiner Kallweit <hkallweit1@gmail.com>
Thu, 15 Aug 2019 11:15:19 +0000 (13:15 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 15 Aug 2019 18:41:49 +0000 (11:41 -0700)
Value of MII_CTRL1000 is needed only if LPA_1000MSFAIL is set.
Therefore move reading this register.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phy_device.c

index b039632de73a04c61a3b5aa4f2a3e774710491ab..9c546bae9ec9bca172c14f2da00b4034a1cb4378 100644 (file)
@@ -1784,7 +1784,7 @@ EXPORT_SYMBOL(genphy_update_link);
  */
 int genphy_read_status(struct phy_device *phydev)
 {
-       int adv, lpa, lpagb, err, old_link = phydev->link;
+       int lpa, lpagb, err, old_link = phydev->link;
 
        /* Update the link, but return if there was an error */
        err = genphy_update_link(phydev);
@@ -1806,11 +1806,12 @@ int genphy_read_status(struct phy_device *phydev)
                        if (lpagb < 0)
                                return lpagb;
 
-                       adv = phy_read(phydev, MII_CTRL1000);
-                       if (adv < 0)
-                               return adv;
-
                        if (lpagb & LPA_1000MSFAIL) {
+                               int adv = phy_read(phydev, MII_CTRL1000);
+
+                               if (adv < 0)
+                                       return adv;
+
                                if (adv & CTL1000_ENABLE_MASTER)
                                        phydev_err(phydev, "Master/Slave resolution failed, maybe conflicting manual settings?\n");
                                else