> -----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 3/9] net: amd: xgbe: use linkmode_and() return value
> in xgbe_set_link_ksettings()
>
> bitmap_empty() is O(N).
>
> Use the return value of linkmode_and() when validating the requested
> advertisement instead of scanning the result bitmap separately.
>
> Signed-off-by: Yury Norov <[email protected]>
> ---
> drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
> b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
> index a9f4fcc4daae..113a10855938 100644
> --- a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
> @@ -231,6 +231,7 @@ static int xgbe_set_link_ksettings(struct
> net_device *netdev,
> struct xgbe_prv_data *pdata = netdev_priv(netdev);
> struct ethtool_link_ksettings *lks = &pdata->phy.lks;
> __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising);
> + bool has_advertising;
> u32 speed;
> int ret;
>
> @@ -267,11 +268,11 @@ static int xgbe_set_link_ksettings(struct
> net_device *netdev,
> __ETHTOOL_LINK_MODE_MASK_NBITS, cmd-
> >link_modes.advertising,
> __ETHTOOL_LINK_MODE_MASK_NBITS, lks-
> >link_modes.supported);
>
> - linkmode_and(advertising, cmd->link_modes.advertising,
> - lks->link_modes.supported);
> + has_advertising = linkmode_and(advertising,
> + cmd->link_modes.advertising,
> + lks->link_modes.supported);
>
> - if ((cmd->base.autoneg == AUTONEG_ENABLE) &&
> - bitmap_empty(advertising, __ETHTOOL_LINK_MODE_MASK_NBITS))
> {
> + if (!has_advertising && cmd->base.autoneg == AUTONEG_ENABLE) {
> netdev_err(netdev,
> "unsupported requested advertisement\n");
> return -EINVAL;
> --
> 2.53.0
Reviewed-by: Aleksandr Loktionov <[email protected]>