]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: phylink: use mdiobus_modify_changed() helper
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Wed, 6 Oct 2021 12:19:25 +0000 (13:19 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 7 Oct 2021 00:49:21 +0000 (17:49 -0700)
Use the mdiobus_modify_changed() helper in the C22 PCS advertisement
helper.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/phylink.c

index b32774fd65f858e7370b2477466f1a444c6b7189..16240f2dd161d224de5fbc7f842df7f00a026eb7 100644 (file)
@@ -2596,7 +2596,6 @@ int phylink_mii_c22_pcs_set_advertisement(struct mdio_device *pcs,
 {
        struct mii_bus *bus = pcs->bus;
        int addr = pcs->addr;
-       int val, ret;
        u16 adv;
 
        switch (interface) {
@@ -2610,32 +2609,12 @@ int phylink_mii_c22_pcs_set_advertisement(struct mdio_device *pcs,
                                      advertising))
                        adv |= ADVERTISE_1000XPSE_ASYM;
 
-               val = mdiobus_read(bus, addr, MII_ADVERTISE);
-               if (val < 0)
-                       return val;
-
-               if (val == adv)
-                       return 0;
-
-               ret = mdiobus_write(bus, addr, MII_ADVERTISE, adv);
-               if (ret < 0)
-                       return ret;
-
-               return 1;
+               return mdiobus_modify_changed(bus, addr, MII_ADVERTISE,
+                                             0xffff, adv);
 
        case PHY_INTERFACE_MODE_SGMII:
-               val = mdiobus_read(bus, addr, MII_ADVERTISE);
-               if (val < 0)
-                       return val;
-
-               if (val == 0x0001)
-                       return 0;
-
-               ret = mdiobus_write(bus, addr, MII_ADVERTISE, 0x0001);
-               if (ret < 0)
-                       return ret;
-
-               return 1;
+               return mdiobus_modify_changed(bus, addr, MII_ADVERTISE,
+                                             0xffff, 0x0001);
 
        default:
                /* Nothing to do for other modes */