Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: mii: Rename mii_stat1000_to_linkmode_lpa_t

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>

authored by

Andrew Lunn and committed by
David S. Miller
78a24df3 5f15eed2

+23 -14
+1 -1
drivers/net/phy/marvell.c
··· 1138 1138 1139 1139 if (!fiber) { 1140 1140 mii_lpa_to_linkmode_lpa_t(phydev->lp_advertising, lpa); 1141 - mii_stat1000_to_linkmode_lpa_t(phydev->lp_advertising, lpagb); 1141 + mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, lpagb); 1142 1142 1143 1143 if (phydev->duplex == DUPLEX_FULL) { 1144 1144 phydev->pause = lpa & LPA_PAUSE_CAP ? 1 : 0;
+1 -1
drivers/net/phy/marvell10g.c
··· 490 490 if (val < 0) 491 491 return val; 492 492 493 - mii_stat1000_to_linkmode_lpa_t(phydev->lp_advertising, val); 493 + mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val); 494 494 495 495 if (phydev->autoneg == AUTONEG_ENABLE) 496 496 phy_resolve_aneg_linkmode(phydev);
+2 -2
drivers/net/phy/phy_device.c
··· 1739 1739 return -ENOLINK; 1740 1740 } 1741 1741 1742 - mii_stat1000_to_linkmode_lpa_t(phydev->lp_advertising, 1743 - lpagb); 1742 + mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, 1743 + lpagb); 1744 1744 common_adv_gb = lpagb & adv << 2; 1745 1745 } 1746 1746
+9
include/linux/linkmode.h
··· 57 57 __clear_bit(nr, addr); 58 58 } 59 59 60 + static inline void linkmode_mod_bit(int nr, volatile unsigned long *addr, 61 + int set) 62 + { 63 + if (set) 64 + linkmode_set_bit(nr, addr); 65 + else 66 + linkmode_clear_bit(nr, addr); 67 + } 68 + 60 69 static inline void linkmode_change_bit(int nr, volatile unsigned long *addr) 61 70 { 62 71 __change_bit(nr, addr);
+10 -10
include/linux/mii.h
··· 288 288 } 289 289 290 290 /** 291 - * mii_stat1000_to_linkmode_lpa_t 291 + * mii_stat1000_mod_linkmode_lpa_t 292 292 * @advertising: target the linkmode advertisement settings 293 293 * @adv: value of the MII_STAT1000 register 294 294 * 295 295 * A small helper function that translates MII_STAT1000 bits, when in 296 - * 1000Base-T mode, to linkmode advertisement settings. 296 + * 1000Base-T mode, to linkmode advertisement settings. Other bits in 297 + * advertising are not changes. 297 298 */ 298 - static inline void mii_stat1000_to_linkmode_lpa_t(unsigned long *advertising, 299 - u32 lpa) 299 + static inline void mii_stat1000_mod_linkmode_lpa_t(unsigned long *advertising, 300 + u32 lpa) 300 301 { 301 - if (lpa & LPA_1000HALF) 302 - linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT, 303 - advertising); 304 - if (lpa & LPA_1000FULL) 305 - linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, 306 - advertising); 302 + linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT, 303 + advertising, lpa & LPA_1000HALF); 304 + 305 + linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, 306 + advertising, lpa & LPA_1000FULL); 307 307 } 308 308 309 309 /**