diff mbox series

[net-next] amd-xgbe: use ethtool string helpers

Message ID 20241022233203.9670-1-rosenp@gmail.com (mailing list archive)
State Accepted
Commit cf57ee160152056724cdecf7445d924407259ae9
Delegated to: Netdev Maintainers
Headers show
Series [net-next] amd-xgbe: 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: 4 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 32 lines checked
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 success net-next-2024-10-23--12-00 (tests: 777)

Commit Message

Rosen Penev Oct. 22, 2024, 11:32 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/ethernet/amd/xgbe/xgbe-ethtool.c | 22 ++++++++------------
 1 file changed, 9 insertions(+), 13 deletions(-)

Comments

Shyam Sundar S K Oct. 23, 2024, 7:32 a.m. UTC | #1
On 10/23/2024 05:02, Rosen Penev wrote:
> The latter is the preferred way to copy ethtool strings.
> 
> Avoids manually incrementing the pointer.
> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>

Looks good to me.

Acked-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>

Thanks,
Shyam

> ---
>  drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c | 22 ++++++++------------
>  1 file changed, 9 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
> index 5fc94c2f638e..4431ab1c18b3 100644
> --- a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
> @@ -195,23 +195,19 @@ static void xgbe_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
>  
>  	switch (stringset) {
>  	case ETH_SS_STATS:
> -		for (i = 0; i < XGBE_STATS_COUNT; i++) {
> -			memcpy(data, xgbe_gstring_stats[i].stat_string,
> -			       ETH_GSTRING_LEN);
> -			data += ETH_GSTRING_LEN;
> -		}
> +		for (i = 0; i < XGBE_STATS_COUNT; i++)
> +			ethtool_puts(&data, xgbe_gstring_stats[i].stat_string);
> +
>  		for (i = 0; i < pdata->tx_ring_count; i++) {
> -			sprintf(data, "txq_%u_packets", i);
> -			data += ETH_GSTRING_LEN;
> -			sprintf(data, "txq_%u_bytes", i);
> -			data += ETH_GSTRING_LEN;
> +			ethtool_sprintf(&data, "txq_%u_packets", i);
> +			ethtool_sprintf(&data, "txq_%u_bytes", i);
>  		}
> +
>  		for (i = 0; i < pdata->rx_ring_count; i++) {
> -			sprintf(data, "rxq_%u_packets", i);
> -			data += ETH_GSTRING_LEN;
> -			sprintf(data, "rxq_%u_bytes", i);
> -			data += ETH_GSTRING_LEN;
> +			ethtool_sprintf(&data, "rxq_%u_packets", i);
> +			ethtool_sprintf(&data, "rxq_%u_bytes", i);
>  		}
> +
>  		break;
>  	}
>  }
Simon Horman Oct. 24, 2024, 12:02 p.m. UTC | #2
On Tue, Oct 22, 2024 at 04:32:03PM -0700, Rosen Penev wrote:
> The latter is the preferred way to copy ethtool strings.
> 
> Avoids manually incrementing the pointer.
> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>

Reviewed-by: Simon Horman <horms@kernel.org>
patchwork-bot+netdevbpf@kernel.org Oct. 29, 2024, 11 p.m. UTC | #3
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 22 Oct 2024 16:32:03 -0700 you wrote:
> 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/ethernet/amd/xgbe/xgbe-ethtool.c | 22 ++++++++------------
>  1 file changed, 9 insertions(+), 13 deletions(-)

Here is the summary with links:
  - [net-next] amd-xgbe: use ethtool string helpers
    https://git.kernel.org/netdev/net-next/c/cf57ee160152

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
index 5fc94c2f638e..4431ab1c18b3 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
@@ -195,23 +195,19 @@  static void xgbe_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
 
 	switch (stringset) {
 	case ETH_SS_STATS:
-		for (i = 0; i < XGBE_STATS_COUNT; i++) {
-			memcpy(data, xgbe_gstring_stats[i].stat_string,
-			       ETH_GSTRING_LEN);
-			data += ETH_GSTRING_LEN;
-		}
+		for (i = 0; i < XGBE_STATS_COUNT; i++)
+			ethtool_puts(&data, xgbe_gstring_stats[i].stat_string);
+
 		for (i = 0; i < pdata->tx_ring_count; i++) {
-			sprintf(data, "txq_%u_packets", i);
-			data += ETH_GSTRING_LEN;
-			sprintf(data, "txq_%u_bytes", i);
-			data += ETH_GSTRING_LEN;
+			ethtool_sprintf(&data, "txq_%u_packets", i);
+			ethtool_sprintf(&data, "txq_%u_bytes", i);
 		}
+
 		for (i = 0; i < pdata->rx_ring_count; i++) {
-			sprintf(data, "rxq_%u_packets", i);
-			data += ETH_GSTRING_LEN;
-			sprintf(data, "rxq_%u_bytes", i);
-			data += ETH_GSTRING_LEN;
+			ethtool_sprintf(&data, "rxq_%u_packets", i);
+			ethtool_sprintf(&data, "rxq_%u_bytes", i);
 		}
+
 		break;
 	}
 }