diff mbox series

[v1] netronome: nfp: Use min macro

Message ID 20240827084005.3815912-1-yanzhen@vivo.com (mailing list archive)
State Rejected
Delegated to: Netdev Maintainers
Headers show
Series [v1] netronome: nfp: Use min macro | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 3 maintainers not CCed: yinjun.zhang@corigine.com horms@kernel.org yu.xiao@corigine.com
netdev/build_clang success Errors and warnings before: 16 this patch: 16
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 16 this patch: 16
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 19 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 3 this patch: 3
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-27--09-00 (tests: 713)

Commit Message

Yan Zhen Aug. 27, 2024, 8:40 a.m. UTC
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(-)

Comments

Jakub Kicinski Aug. 27, 2024, 2:24 p.m. UTC | #1
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 ?
David Laight Aug. 31, 2024, 12:49 p.m. UTC | #2
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)
diff mbox series

Patch

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);