net: mii: Rename mii_stat1000_to_linkmode_lpa_t
authorAndrew Lunn <andrew@lunn.ch>
Wed, 5 Dec 2018 20:49:41 +0000 (21:49 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 6 Dec 2018 00:26:16 +0000 (16:26 -0800)
Rename mii_stat1000_to_linkmode_lpa_t to
mii_stat1000_mod_linkmode_lpa_t to indicate it modifies the passed
linkmode bitmap, without clearing any other bits.

Add a helper to set/clear bits in a linkmode.

Use this helper to ensure bit are clear which the stat1000 indicates
should not be set.

Fixes: c0ec3c273677 ("net: phy: Convert u32 phydev->lp_advertising to linkmode")
Suggested-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/marvell.c
drivers/net/phy/marvell10g.c
drivers/net/phy/phy_device.c
include/linux/linkmode.h
include/linux/mii.h

index 6a9881942e531a3af52ce637c6c043b3cae1d35c..03dafe0e68a2a384fbf571a9711170a139a5e190 100644 (file)
@@ -1138,7 +1138,7 @@ static int marvell_read_status_page_an(struct phy_device *phydev,
 
        if (!fiber) {
                mii_lpa_to_linkmode_lpa_t(phydev->lp_advertising, lpa);
-               mii_stat1000_to_linkmode_lpa_t(phydev->lp_advertising, lpagb);
+               mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, lpagb);
 
                if (phydev->duplex == DUPLEX_FULL) {
                        phydev->pause = lpa & LPA_PAUSE_CAP ? 1 : 0;
index 6f6e886fc836117299c51e6d1c0825f2596e30eb..82ab6ed3b74ee5b6f3229d62fa276901c53df454 100644 (file)
@@ -490,7 +490,7 @@ static int mv3310_read_status(struct phy_device *phydev)
                if (val < 0)
                        return val;
 
-               mii_stat1000_to_linkmode_lpa_t(phydev->lp_advertising, val);
+               mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val);
 
                if (phydev->autoneg == AUTONEG_ENABLE)
                        phy_resolve_aneg_linkmode(phydev);
index e6720e2a2da6e14da77739bf547cf42f47b18e14..c20b5ecc0f4be30cf7934cdf4e9465ef2f8d97cb 100644 (file)
@@ -1739,8 +1739,8 @@ int genphy_read_status(struct phy_device *phydev)
                                return -ENOLINK;
                        }
 
-                       mii_stat1000_to_linkmode_lpa_t(phydev->lp_advertising,
-                                                      lpagb);
+                       mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising,
+                                                       lpagb);
                        common_adv_gb = lpagb & adv << 2;
                }
 
index 22443d7fb5cd617dacb30e10348a4749c24aebb8..a99c58866860e2e418f342a87f6372330d7f1045 100644 (file)
@@ -57,6 +57,15 @@ static inline void linkmode_clear_bit(int nr, volatile unsigned long *addr)
        __clear_bit(nr, addr);
 }
 
+static inline void linkmode_mod_bit(int nr, volatile unsigned long *addr,
+                                   int set)
+{
+       if (set)
+               linkmode_set_bit(nr, addr);
+       else
+               linkmode_clear_bit(nr, addr);
+}
+
 static inline void linkmode_change_bit(int nr, volatile unsigned long *addr)
 {
        __change_bit(nr, addr);
index 57365224306ce7004f7f93df9c8c689da69fb59d..b915ef6c36925421bd04c480a3705a3eedefacf0 100644 (file)
@@ -288,22 +288,22 @@ static inline u32 mii_stat1000_to_ethtool_lpa_t(u32 lpa)
 }
 
 /**
- * mii_stat1000_to_linkmode_lpa_t
+ * mii_stat1000_mod_linkmode_lpa_t
  * @advertising: target the linkmode advertisement settings
  * @adv: value of the MII_STAT1000 register
  *
  * A small helper function that translates MII_STAT1000 bits, when in
- * 1000Base-T mode, to linkmode advertisement settings.
+ * 1000Base-T mode, to linkmode advertisement settings. Other bits in
+ * advertising are not changes.
  */
-static inline void mii_stat1000_to_linkmode_lpa_t(unsigned long *advertising,
-                                                 u32 lpa)
+static inline void mii_stat1000_mod_linkmode_lpa_t(unsigned long *advertising,
+                                                  u32 lpa)
 {
-       if (lpa & LPA_1000HALF)
-               linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT,
-                                advertising);
-       if (lpa & LPA_1000FULL)
-               linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
-                                advertising);
+       linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT,
+                        advertising, lpa & LPA_1000HALF);
+
+       linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
+                        advertising, lpa & LPA_1000FULL);
 }
 
 /**