[PATCH 3/9] net: amd: xgbe: use linkmode_and() return value in xgbe_set_link_ksettings()

Loktionov, Aleksandr aleksandr.loktionov at intel.com
Tue Sep 8 13:04:58 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 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 <ynorov at nvidia.com>
> ---
>  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 <aleksandr.loktionov at intel.com>


More information about the Intel-wired-lan mailing list