]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: phy: marvell: use phy_modify_changed()
authorRussell King <rmk+kernel@armlinux.org.uk>
Tue, 17 Dec 2019 13:39:47 +0000 (13:39 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 19 Dec 2019 20:52:34 +0000 (12:52 -0800)
Use phy_modify_changed() to change the fiber advertisement register
rather than open coding this functionality.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
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/marvell.c

index c6c7cde84c1c2308db6e5f62de547a8929b43fc5..7da64208365bd9a6475cdaee67d88affc4359773 100644 (file)
@@ -513,7 +513,7 @@ static int marvell_config_aneg_fiber(struct phy_device *phydev)
 {
        int changed = 0;
        int err;
-       int adv, oldadv;
+       u16 adv;
 
        if (phydev->autoneg != AUTONEG_ENABLE)
                return genphy_setup_forced(phydev);
@@ -522,23 +522,17 @@ static int marvell_config_aneg_fiber(struct phy_device *phydev)
        linkmode_and(phydev->advertising, phydev->advertising,
                     phydev->supported);
 
-       /* Setup fiber advertisement */
-       adv = phy_read(phydev, MII_ADVERTISE);
-       if (adv < 0)
-               return adv;
-
-       oldadv = adv;
-       adv &= ~(ADVERTISE_1000XHALF | ADVERTISE_1000XFULL |
-                ADVERTISE_1000XPAUSE | ADVERTISE_1000XPSE_ASYM);
-       adv |= linkmode_adv_to_fiber_adv_t(phydev->advertising);
-
-       if (adv != oldadv) {
-               err = phy_write(phydev, MII_ADVERTISE, adv);
-               if (err < 0)
-                       return err;
+       adv = linkmode_adv_to_fiber_adv_t(phydev->advertising);
 
+       /* Setup fiber advertisement */
+       err = phy_modify_changed(phydev, MII_ADVERTISE,
+                                ADVERTISE_1000XHALF | ADVERTISE_1000XFULL |
+                                ADVERTISE_1000XPAUSE | ADVERTISE_1000XPSE_ASYM,
+                                adv);
+       if (err < 0)
+               return err;
+       if (err > 0)
                changed = 1;
-       }
 
        if (changed == 0) {
                /* Advertisement hasn't changed, but maybe aneg was never on to