diff mbox series

[RFC,05/10] ena: Update driver to use ethtool_gsprintf

Message ID 161542654541.13546.817443057977441498.stgit@localhost.localdomain (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series ethtool: Factor out common code related to writing ethtool strings | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers warning 9 maintainers not CCed: hawk@kernel.org daniel@iogearbox.net bpf@vger.kernel.org shayagr@amazon.com ast@kernel.org sameehj@amazon.com john.fastabend@gmail.com colin.king@canonical.com davem@davemloft.net
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit fail Errors and warnings before: 100 this patch: 100
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 54 lines checked
netdev/build_allmodconfig_warn fail Errors and warnings before: 100 this patch: 100
netdev/header_inline success Link

Commit Message

Alexander Duyck March 11, 2021, 1:35 a.m. UTC
From: Alexander Duyck <alexanderduyck@fb.com>

Replace instances of snprintf or memcpy with a pointer update with
ethtool_gsprintf.

Signed-off-by: Alexander Duyck <alexanderduyck@fb.com>
---
 drivers/net/ethernet/amazon/ena/ena_ethtool.c |   25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

Comments

Kiyanovski, Arthur March 11, 2021, 1:42 p.m. UTC | #1
> -----Original Message-----
> From: Alexander Duyck <alexander.duyck@gmail.com>
> Sent: Thursday, March 11, 2021 3:36 AM
> To: kuba@kernel.org
> Cc: netdev@vger.kernel.org; oss-drivers@netronome.com;
> simon.horman@netronome.com; yisen.zhuang@huawei.com;
> salil.mehta@huawei.com; intel-wired-lan@lists.osuosl.org;
> jesse.brandeburg@intel.com; anthony.l.nguyen@intel.com;
> drivers@pensando.io; snelson@pensando.io; Belgazal, Netanel
> <netanel@amazon.com>; Kiyanovski, Arthur <akiyano@amazon.com>;
> Tzalik, Guy <gtzalik@amazon.com>; Bshara, Saeed <saeedb@amazon.com>;
> GR-Linux-NIC-Dev@marvell.com; skalluru@marvell.com;
> rmody@marvell.com; kys@microsoft.com; haiyangz@microsoft.com;
> sthemmin@microsoft.com; wei.liu@kernel.org; mst@redhat.com;
> jasowang@redhat.com; pv-drivers@vmware.com; doshir@vmware.com;
> alexanderduyck@fb.com
> Subject: [EXTERNAL] [RFC PATCH 05/10] ena: Update driver to use
> ethtool_gsprintf
> 
> CAUTION: This email originated from outside of the organization. Do not click
> links or open attachments unless you can confirm the sender and know the
> content is safe.
> 
> 
> 
> From: Alexander Duyck <alexanderduyck@fb.com>
> 
> Replace instances of snprintf or memcpy with a pointer update with
> ethtool_gsprintf.
> 
> Signed-off-by: Alexander Duyck <alexanderduyck@fb.com>

Acked-by: Arthur Kiyanovski <akiyano@amazon.com>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/amazon/ena/ena_ethtool.c b/drivers/net/ethernet/amazon/ena/ena_ethtool.c
index d6cc7aa612b7..42f6bad7ca26 100644
--- a/drivers/net/ethernet/amazon/ena/ena_ethtool.c
+++ b/drivers/net/ethernet/amazon/ena/ena_ethtool.c
@@ -251,10 +251,10 @@  static void ena_queue_strings(struct ena_adapter *adapter, u8 **data)
 		for (j = 0; j < ENA_STATS_ARRAY_TX; j++) {
 			ena_stats = &ena_stats_tx_strings[j];
 
-			snprintf(*data, ETH_GSTRING_LEN,
-				 "queue_%u_%s_%s", i,
-				 is_xdp ? "xdp_tx" : "tx", ena_stats->name);
-			(*data) += ETH_GSTRING_LEN;
+			ethtool_gsprintf(data,
+					 "queue_%u_%s_%s", i,
+					 is_xdp ? "xdp_tx" : "tx",
+					 ena_stats->name);
 		}
 
 		if (!is_xdp) {
@@ -264,9 +264,9 @@  static void ena_queue_strings(struct ena_adapter *adapter, u8 **data)
 			for (j = 0; j < ENA_STATS_ARRAY_RX; j++) {
 				ena_stats = &ena_stats_rx_strings[j];
 
-				snprintf(*data, ETH_GSTRING_LEN,
-					 "queue_%u_rx_%s", i, ena_stats->name);
-				(*data) += ETH_GSTRING_LEN;
+				ethtool_gsprintf(data,
+						 "queue_%u_rx_%s", i,
+						 ena_stats->name);
 			}
 		}
 	}
@@ -280,9 +280,8 @@  static void ena_com_dev_strings(u8 **data)
 	for (i = 0; i < ENA_STATS_ARRAY_ENA_COM; i++) {
 		ena_stats = &ena_stats_ena_com_strings[i];
 
-		snprintf(*data, ETH_GSTRING_LEN,
-			 "ena_admin_q_%s", ena_stats->name);
-		(*data) += ETH_GSTRING_LEN;
+		ethtool_gsprintf(data,
+				 "ena_admin_q_%s", ena_stats->name);
 	}
 }
 
@@ -295,15 +294,13 @@  static void ena_get_strings(struct ena_adapter *adapter,
 
 	for (i = 0; i < ENA_STATS_ARRAY_GLOBAL; i++) {
 		ena_stats = &ena_stats_global_strings[i];
-		memcpy(data, ena_stats->name, ETH_GSTRING_LEN);
-		data += ETH_GSTRING_LEN;
+		ethtool_gsprintf(&data, ena_stats->name);
 	}
 
 	if (eni_stats_needed) {
 		for (i = 0; i < ENA_STATS_ARRAY_ENI(adapter); i++) {
 			ena_stats = &ena_stats_eni_strings[i];
-			memcpy(data, ena_stats->name, ETH_GSTRING_LEN);
-			data += ETH_GSTRING_LEN;
+			ethtool_gsprintf(&data, ena_stats->name);
 		}
 	}