RE: [PATCH 7/9] net: phy: use linkmode operation return values in phy_device.c
flat view
From: Loktionov, Aleksandr <hidden>
Date: 2026-09-09 08:10:22
Also in:
intel-wired-lan, lkml, netdev
quoted hunk ↗ jump to hunk
-----Original Message----- From: Yury Norov <yury.norov@gmail.com> Sent: Monday, September 7, 2026 11:55 PM To: Andrew Lunn <andrew@lunn.ch>; Heiner Kallweit [off-list ref]; Russell King [off-list ref]; Raju Rangoju [off-list ref]; Prashanth Kumar K R [off-list ref]; Nguyen, Anthony L [off-list ref]; Kitszel, Przemyslaw [off-list ref]; Jian Shen [off-list ref]; Jijie Shao [off-list ref]; David S. Miller [off-list ref]; Eric Dumazet [off-list ref]; Jakub Kicinski [off-list ref]; Paolo Abeni [off-list ref]; linux- kernel@vger.kernel.org; netdev@vger.kernel.org; intel-wired- lan@lists.osuosl.org; linux-usb@vger.kernel.org Cc: Yury Norov <redacted>; Yury Norov <yury.norov@gmail.com>; Rasmus Villemoes [off-list ref]; Andrew Morton [off-list ref] Subject: [PATCH 7/9] net: phy: use linkmode operation return values in phy_device.c Use the return value of linkmode_and() where the resulting mask was previously scanned for emptiness. In phy_probe(), combine the AND and AND-NOT operations and use the return value of linkmode_and_andnot(). Signed-off-by: Yury Norov <redacted> --- drivers/net/phy/phy_device.c | 14 ++++++-------- include/linux/linkmode.h | 9 +++++++++ 2 files changed, 15 insertions(+), 8 deletions(-)diff --git a/drivers/net/phy/phy_device.cb/drivers/net/phy/phy_device.c index 94b2e85e00a3..3430605695c5 100644--- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c@@ -1565,8 +1565,7 @@ static int phy_sfp_module_insert(void *upstream,const struct sfp_eeprom_id *id) caps = sfp_get_module_caps(phydev->sfp_bus); - linkmode_and(sfp_support, port->supported, caps->link_modes); - if (linkmode_empty(sfp_support)) { + if (!linkmode_and(sfp_support, port->supported, caps-quoted
link_modes)) {dev_err(&phydev->mdio.dev, "incompatible SFP module inserted, no common linkmode\n"); return -EINVAL; }@@ -3761,15 +3760,14 @@ static int phy_probe(struct device *dev) /* Some PHYs may advertise, by default, not support EEE modes.So, * we need to clean them. In addition remove all disabled EEE modes. */ - linkmode_and(phydev->advertising_eee, phydev->supported_eee, - phydev->advertising_eee); - linkmode_andnot(phydev->advertising_eee, phydev-quoted
advertising_eee,- phydev->eee_disabled_modes); - /* There is no "enabled" flag. If PHY is advertising, assume it is * kind of enabled. */ - phydev->eee_cfg.eee_enabled = !linkmode_empty(phydev-quoted
advertising_eee);+ phydev->eee_cfg.eee_enabled = + linkmode_and_andnot(phydev->advertising_eee, + phydev->advertising_eee, + phydev->supported_eee, + phydev->eee_disabled_modes); /* Get master/slave strap overrides */ of_set_phy_timing_role(phydev);diff --git a/include/linux/linkmode.h b/include/linux/linkmode.h indexc08632c10c3d..49587a2e0f69 100644--- a/include/linux/linkmode.h +++ b/include/linux/linkmode.h@@ -26,6 +26,15 @@ static inline bool linkmode_and(unsigned long *dst,const unsigned long *a, return bitmap_and(dst, a, b, __ETHTOOL_LINK_MODE_MASK_NBITS); } +static inline bool linkmode_and_andnot(unsigned long *dst, + const unsigned long *a, + const unsigned long *b, + const unsigned long *c) +{ + return bitmap_and_andnot(dst, a, b, c, + __ETHTOOL_LINK_MODE_MASK_NBITS); +} + static inline void linkmode_or(unsigned long *dst, const unsigned long *a, const unsigned long *b) { -- 2.53.0
Reviewed-by: Aleksandr Loktionov <redacted>