All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Yan Zhen <yanzhen@vivo.com>
Cc: marcin.s.wojtas@gmail.com, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	opensource.kernel@vivo.com
Subject: Re: [PATCH v1] ethernet: marvell: Use min macro
Date: Tue, 27 Aug 2024 18:57:45 +0100	[thread overview]
Message-ID: <20240827175745.GS1368797@kernel.org> (raw)
In-Reply-To: <20240827175408.GR1368797@kernel.org>

On Tue, Aug 27, 2024 at 06:54:08PM +0100, Simon Horman wrote:
> 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 <yanzhen@vivo.com>
> > ---
> >  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.

Sorry, I hit send to soon. What I wanted to say is:

I think that it is appropriate to use umin() here.
Because:
1) As I understand things, the type of MVNETA_MAX_RXD is signed,
   but it always holds a positive value
2) ring->rx_pending is unsigned

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

  reply	other threads:[~2024-08-27 17:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-27 11:58 [PATCH v1] ethernet: marvell: Use min macro Yan Zhen
2024-08-27 17:54 ` Simon Horman
2024-08-27 17:57   ` Simon Horman [this message]
2024-08-31 12:39     ` David Laight
2024-09-01 17:11       ` Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240827175745.GS1368797@kernel.org \
    --to=horms@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcin.s.wojtas@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=opensource.kernel@vivo.com \
    --cc=pabeni@redhat.com \
    --cc=yanzhen@vivo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.