[PATCH 7/9] net: phy: use linkmode operation return values in phy_device.c

Loktionov, Aleksandr aleksandr.loktionov at intel.com
Wed Sep 9 08:09:55 UTC 2026



> -----Original Message-----
> From: Yury Norov <yury.norov at gmail.com>
> Sent: Monday, September 7, 2026 11:55 PM
> To: Andrew Lunn <andrew at lunn.ch>; Heiner Kallweit
> <hkallweit1 at gmail.com>; Russell King <linux at armlinux.org.uk>; Raju
> Rangoju <Raju.Rangoju at amd.com>; Prashanth Kumar K R
> <PrashanthKumar.K.R at amd.com>; Nguyen, Anthony L
> <anthony.l.nguyen at intel.com>; Kitszel, Przemyslaw
> <przemyslaw.kitszel at intel.com>; Jian Shen <shenjian15 at huawei.com>;
> Jijie Shao <shaojijie at huawei.com>; David S. Miller
> <davem at davemloft.net>; Eric Dumazet <edumazet at google.com>; Jakub
> Kicinski <kuba at kernel.org>; Paolo Abeni <pabeni at redhat.com>; linux-
> kernel at vger.kernel.org; netdev at vger.kernel.org; intel-wired-
> lan at lists.osuosl.org; linux-usb at vger.kernel.org
> Cc: Yury Norov <ynorov at nvidia.com>; Yury Norov <yury.norov at gmail.com>;
> Rasmus Villemoes <linux at rasmusvillemoes.dk>; Andrew Morton
> <akpm at linux-foundation.org>
> 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 <ynorov at nvidia.com>
> ---
>  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.c
> b/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-
> >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-
> >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-
> >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 index
> c08632c10c3d..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 <aleksandr.loktionov at intel.com>



More information about the Intel-wired-lan mailing list