netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] netronome: nfp: Use min macro
@ 2024-08-27  8:40 Yan Zhen
  2024-08-27 14:24 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Yan Zhen @ 2024-08-27  8:40 UTC (permalink / raw)
  To: louis.peens, davem, edumazet, pabeni
  Cc: kuba, oss-drivers, netdev, linux-kernel, opensource.kernel,
	Yan Zhen

Using min macro not only makes the code more concise and readable
but also improves efficiency sometimes.

Signed-off-by: Yan Zhen <yanzhen@vivo.com>
---
 drivers/net/ethernet/netronome/nfp/nfp_net_common.c      | 4 +---
 drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c | 2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index 182ba0a8b095..e6cb255ac914 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -2857,10 +2857,8 @@ int nfp_net_init(struct nfp_net *nn)
 	/* Set default MTU and Freelist buffer size */
 	if (!nfp_net_is_data_vnic(nn) && nn->app->ctrl_mtu) {
 		nn->dp.mtu = min(nn->app->ctrl_mtu, nn->max_mtu);
-	} else if (nn->max_mtu < NFP_NET_DEFAULT_MTU) {
-		nn->dp.mtu = nn->max_mtu;
 	} else {
-		nn->dp.mtu = NFP_NET_DEFAULT_MTU;
+		nn->dp.mtu = min(nn->max_mtu, NFP_NET_DEFAULT_MTU);
 	}
 	nn->dp.fl_bufsz = nfp_net_calc_fl_bufsz(&nn->dp);
 
diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c
index 5cfddc9a5d87..3d7225cb24aa 100644
--- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c
+++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c
@@ -412,7 +412,7 @@ int nfp_eth_config_commit_end(struct nfp_nsp *nsp)
 
 	if (nfp_nsp_config_modified(nsp)) {
 		ret = nfp_nsp_write_eth_table(nsp, entries, NSP_ETH_TABLE_SIZE);
-		ret = ret < 0 ? ret : 0;
+		ret = min(ret, 0);
 	}
 
 	nfp_eth_config_cleanup_end(nsp);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] netronome: nfp: Use min macro
  2024-08-27  8:40 [PATCH v1] netronome: nfp: Use min macro Yan Zhen
@ 2024-08-27 14:24 ` Jakub Kicinski
  2024-08-31 12:49   ` David Laight
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2024-08-27 14:24 UTC (permalink / raw)
  To: Yan Zhen
  Cc: louis.peens, davem, edumazet, pabeni, oss-drivers, netdev,
	linux-kernel, opensource.kernel

On Tue, 27 Aug 2024 16:40:05 +0800 Yan Zhen wrote:
> Using min macro not only makes the code more concise and readable
> but also improves efficiency sometimes.

The code is fine, you're making it worse.

How many of those pointless min()/max() conversions do you have 
for drivers/net ?
-- 
pw-bot: reject

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH v1] netronome: nfp: Use min macro
  2024-08-27 14:24 ` Jakub Kicinski
@ 2024-08-31 12:49   ` David Laight
  0 siblings, 0 replies; 3+ messages in thread
From: David Laight @ 2024-08-31 12:49 UTC (permalink / raw)
  To: 'Jakub Kicinski', Yan Zhen
  Cc: louis.peens@corigine.com, davem@davemloft.net,
	edumazet@google.com, pabeni@redhat.com, oss-drivers@corigine.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	opensource.kernel@vivo.vom

From: Jakub Kicinski
> Sent: 27 August 2024 15:24
> 
> On Tue, 27 Aug 2024 16:40:05 +0800 Yan Zhen wrote:
> > Using min macro not only makes the code more concise and readable
> > but also improves efficiency sometimes.
> 
> The code is fine, you're making it worse.
> 
> How many of those pointless min()/max() conversions do you have
> for drivers/net ?

Maybe someone who understands cochineal should change the pattern
so that is require one of the 'arguments' to be non-trivial.
(or perhaps just delete the script ;-)

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-31 12:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-27  8:40 [PATCH v1] netronome: nfp: Use min macro Yan Zhen
2024-08-27 14:24 ` Jakub Kicinski
2024-08-31 12:49   ` David Laight

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).