Subject: Re: [PATCH v1] ethernet: marvell: Use min macro

From: Simon Horman <[email-masked]>
Date: Tue, 27 Aug 2024 18:54:08 +0100

On Tue, Aug 27, 2024 at 07:58:48PM +0800, Yan Zhen wrote:
> Using the real macro is usually more intuitive and readable,
> When the original file is guaranteed to contain the minmax.h header file 
> and compile correctly.
> 
> Signed-off-by: Yan Zhen <[email-masked]>
> ---
>  drivers/net/ethernet/marvell/mvneta.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
> index d72b2d5f96db..415d2b9e63f9 100644
> --- a/drivers/net/ethernet/marvell/mvneta.c
> +++ b/drivers/net/ethernet/marvell/mvneta.c
> @@ -4750,8 +4750,7 @@ mvneta_ethtool_set_ringparam(struct net_device *dev,
>  
>  	if ((ring->rx_pending == 0) || (ring->tx_pending == 0))
>  		return -EINVAL;
> -	pp->rx_ring_size = ring->rx_pending < MVNETA_MAX_RXD ?
> -		ring->rx_pending : MVNETA_MAX_RXD;
> +	pp->rx_ring_size = min(ring->rx_pending, MVNETA_MAX_RXD);

Given that the type of ring->rx_pending is __32, and MVNETA_MAX_RXD is
a positive value.

See: 80fcac55385c ("minmax: add umin(a, b) and umax(a, b)")
     https://git.kernel.org/torvalds/c/80fcac55385c

>  
>  	pp->tx_ring_size = clamp_t(u16, ring->tx_pending,
>  				   MVNETA_MAX_SKB_DESCS * 2, MVNETA_MAX_TXD);
> -- 
> 2.34.1
> 
>