net: phy: bcm84881: clear settings on link down
authorRussell King <rmk+kernel@armlinux.org.uk>
Thu, 23 Apr 2020 07:57:42 +0000 (08:57 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 23 Apr 2020 22:55:35 +0000 (15:55 -0700)
Clear the link partner advertisement, speed, duplex and pause when
the link goes down, as other phylib drivers do.  This avoids the
stale link partner, speed and duplex settings being reported via
ethtool.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/bcm84881.c

index 3840d2adbbb9a4eea910c31224ba4c00f51f3b7b..9717a1626f3fa1c4a1daea0e96858afc13472d95 100644 (file)
@@ -155,9 +155,6 @@ static int bcm84881_read_status(struct phy_device *phydev)
        if (phydev->autoneg == AUTONEG_ENABLE && !phydev->autoneg_complete)
                phydev->link = false;
 
-       if (!phydev->link)
-               return 0;
-
        linkmode_zero(phydev->lp_advertising);
        phydev->speed = SPEED_UNKNOWN;
        phydev->duplex = DUPLEX_UNKNOWN;
@@ -165,6 +162,9 @@ static int bcm84881_read_status(struct phy_device *phydev)
        phydev->asym_pause = 0;
        phydev->mdix = 0;
 
+       if (!phydev->link)
+               return 0;
+
        if (phydev->autoneg_complete) {
                val = genphy_c45_read_lpa(phydev);
                if (val < 0)