RE: [PATCH 8/9] r8152: use linkmode_and_and() in EEE checks
From: Loktionov, Aleksandr
Date: Tue Sep 08 2026 - 09:48:15 EST
> -----Original Message-----
> From: Yury Norov <yury.norov@xxxxxxxxx>
> Sent: Monday, September 7, 2026 11:55 PM
> To: Andrew Lunn <andrew@xxxxxxx>; Heiner Kallweit
> <hkallweit1@xxxxxxxxx>; Russell King <linux@xxxxxxxxxxxxxxx>; Raju
> Rangoju <Raju.Rangoju@xxxxxxx>; Prashanth Kumar K R
> <PrashanthKumar.K.R@xxxxxxx>; Nguyen, Anthony L
> <anthony.l.nguyen@xxxxxxxxx>; Kitszel, Przemyslaw
> <przemyslaw.kitszel@xxxxxxxxx>; Jian Shen <shenjian15@xxxxxxxxxx>;
> Jijie Shao <shaojijie@xxxxxxxxxx>; David S. Miller
> <davem@xxxxxxxxxxxxx>; Eric Dumazet <edumazet@xxxxxxxxxx>; Jakub
> Kicinski <kuba@xxxxxxxxxx>; Paolo Abeni <pabeni@xxxxxxxxxx>; linux-
> kernel@xxxxxxxxxxxxxxx; netdev@xxxxxxxxxxxxxxx; intel-wired-
> lan@xxxxxxxxxxxxxxxx; linux-usb@xxxxxxxxxxxxxxx
> Cc: Yury Norov <ynorov@xxxxxxxxxx>; Yury Norov <yury.norov@xxxxxxxxx>;
> Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>; Andrew Morton
> <akpm@xxxxxxxxxxxxxxxxxxxx>
> Subject: [PATCH 8/9] r8152: use linkmode_and_and() in EEE checks
>
> Combine the three link mode masks in a single operation and use its
> return value to determine whether EEE is active.
>
> Signed-off-by: Yury Norov <ynorov@xxxxxxxxxx>
> ---
> drivers/net/usb/r8152.c | 10 ++++------ include/linux/linkmode.h |
> 8 ++++++++
> 2 files changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index
> f61686433031..75f0574fe1d4 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
> @@ -9149,9 +9149,8 @@ static int r8152_get_eee(struct r8152 *tp,
> struct ethtool_keee *eee)
> if (speed & _100bps)
> linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT,
> common);
>
> - linkmode_and(common, common, eee->advertised);
> - linkmode_and(common, common, eee->lp_advertised);
> - eee->eee_active = !linkmode_empty(common);
> + eee->eee_active = linkmode_and_and(common, common, eee-
> >advertised,
> + eee->lp_advertised);
>
> return 0;
> }
> @@ -9222,9 +9221,8 @@ static int r8153_get_eee(struct r8152 *tp,
> struct ethtool_keee *eee)
> if (speed & _100bps)
> linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT,
> common);
>
> - linkmode_and(common, common, eee->advertised);
> - linkmode_and(common, common, eee->lp_advertised);
> - eee->eee_active = !linkmode_empty(common);
> + eee->eee_active = linkmode_and_and(common, common, eee-
> >advertised,
> + eee->lp_advertised);
>
> return 0;
> }
> diff --git a/include/linux/linkmode.h b/include/linux/linkmode.h index
> 49587a2e0f69..efd392dc62ae 100644
> --- a/include/linux/linkmode.h
> +++ b/include/linux/linkmode.h
> @@ -26,6 +26,14 @@ 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_and(unsigned long *dst,
> + const unsigned long *a,
> + const unsigned long *b,
> + const unsigned long *c)
> +{
> + return bitmap_and_and(dst, a, b, c,
> __ETHTOOL_LINK_MODE_MASK_NBITS); }
> +
> static inline bool linkmode_and_andnot(unsigned long *dst,
> const unsigned long *a,
> const unsigned long *b,
> --
> 2.53.0
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@xxxxxxxxx>