diff mbox series

[net-next] net: fjes: use ethtool string helpers

Message ID 20241022205431.511859-1-rosenp@gmail.com (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: fjes: use ethtool string helpers | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for 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: 5 this patch: 5
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
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: 21 this patch: 21
netdev/checkpatch warning WARNING: line length of 82 exceeds 80 columns WARNING: line length of 84 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-10-23--00-00 (tests: 273)

Commit Message

Rosen Penev Oct. 22, 2024, 8:54 p.m. UTC
The latter is the preferred way to copy ethtool strings.

Avoids manually incrementing the pointer.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/net/fjes/fjes_ethtool.c | 50 +++++++++++----------------------
 1 file changed, 17 insertions(+), 33 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/fjes/fjes_ethtool.c b/drivers/net/fjes/fjes_ethtool.c
index 19c99529566b..1dc7754e0f1f 100644
--- a/drivers/net/fjes/fjes_ethtool.c
+++ b/drivers/net/fjes/fjes_ethtool.c
@@ -92,42 +92,26 @@  static void fjes_get_strings(struct net_device *netdev,
 
 	switch (stringset) {
 	case ETH_SS_STATS:
-		for (i = 0; i < ARRAY_SIZE(fjes_gstrings_stats); i++) {
-			memcpy(p, fjes_gstrings_stats[i].stat_string,
-			       ETH_GSTRING_LEN);
-			p += ETH_GSTRING_LEN;
-		}
+		for (i = 0; i < ARRAY_SIZE(fjes_gstrings_stats); i++)
+			ethtool_puts(&p, fjes_gstrings_stats[i].stat_string);
+
 		for (i = 0; i < hw->max_epid; i++) {
 			if (i == hw->my_epid)
 				continue;
-			sprintf(p, "ep%u_com_regist_buf_exec", i);
-			p += ETH_GSTRING_LEN;
-			sprintf(p, "ep%u_com_unregist_buf_exec", i);
-			p += ETH_GSTRING_LEN;
-			sprintf(p, "ep%u_send_intr_rx", i);
-			p += ETH_GSTRING_LEN;
-			sprintf(p, "ep%u_send_intr_unshare", i);
-			p += ETH_GSTRING_LEN;
-			sprintf(p, "ep%u_send_intr_zoneupdate", i);
-			p += ETH_GSTRING_LEN;
-			sprintf(p, "ep%u_recv_intr_rx", i);
-			p += ETH_GSTRING_LEN;
-			sprintf(p, "ep%u_recv_intr_unshare", i);
-			p += ETH_GSTRING_LEN;
-			sprintf(p, "ep%u_recv_intr_stop", i);
-			p += ETH_GSTRING_LEN;
-			sprintf(p, "ep%u_recv_intr_zoneupdate", i);
-			p += ETH_GSTRING_LEN;
-			sprintf(p, "ep%u_tx_buffer_full", i);
-			p += ETH_GSTRING_LEN;
-			sprintf(p, "ep%u_tx_dropped_not_shared", i);
-			p += ETH_GSTRING_LEN;
-			sprintf(p, "ep%u_tx_dropped_ver_mismatch", i);
-			p += ETH_GSTRING_LEN;
-			sprintf(p, "ep%u_tx_dropped_buf_size_mismatch", i);
-			p += ETH_GSTRING_LEN;
-			sprintf(p, "ep%u_tx_dropped_vlanid_mismatch", i);
-			p += ETH_GSTRING_LEN;
+			ethtool_sprintf(&p, "ep%u_com_regist_buf_exec", i);
+			ethtool_sprintf(&p, "ep%u_com_unregist_buf_exec", i);
+			ethtool_sprintf(&p, "ep%u_send_intr_rx", i);
+			ethtool_sprintf(&p, "ep%u_send_intr_unshare", i);
+			ethtool_sprintf(&p, "ep%u_send_intr_zoneupdate", i);
+			ethtool_sprintf(&p, "ep%u_recv_intr_rx", i);
+			ethtool_sprintf(&p, "ep%u_recv_intr_unshare", i);
+			ethtool_sprintf(&p, "ep%u_recv_intr_stop", i);
+			ethtool_sprintf(&p, "ep%u_recv_intr_zoneupdate", i);
+			ethtool_sprintf(&p, "ep%u_tx_buffer_full", i);
+			ethtool_sprintf(&p, "ep%u_tx_dropped_not_shared", i);
+			ethtool_sprintf(&p, "ep%u_tx_dropped_ver_mismatch", i);
+			ethtool_sprintf(&p, "ep%u_tx_dropped_buf_size_mismatch", i);
+			ethtool_sprintf(&p, "ep%u_tx_dropped_vlanid_mismatch", i);
 		}
 		break;
 	}