> -----Original Message-----
> From: Yury Norov <[email protected]>
> Sent: Monday, September 7, 2026 11:55 PM
> To: Andrew Lunn <[email protected]>; Heiner Kallweit
> <[email protected]>; Russell King <[email protected]>; Raju
> Rangoju <[email protected]>; Prashanth Kumar K R
> <[email protected]>; Nguyen, Anthony L
> <[email protected]>; Kitszel, Przemyslaw
> <[email protected]>; Jian Shen <[email protected]>;
> Jijie Shao <[email protected]>; David S. Miller
> <[email protected]>; Eric Dumazet <[email protected]>; Jakub
> Kicinski <[email protected]>; Paolo Abeni <[email protected]>; linux-
> [email protected]; [email protected]; intel-wired-
> [email protected]; [email protected]
> Cc: Yury Norov <[email protected]>; Yury Norov <[email protected]>;
> Rasmus Villemoes <[email protected]>; Andrew Morton
> <[email protected]>
> 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 <[email protected]>
> ---
>  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 <[email protected]>

Reply via email to