diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c
index 2924ac61300d..62a152be8180 100644
--- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
+++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
@@ -83,7 +83,7 @@ static const char ice_gstrings_test[][ETH_GSTRING_LEN] = {
"Link test (on/offline)",
};
-#define ICE_TEST_LEN (sizeof(ice_gstrings_test) / ETH_GSTRING_LEN)
+#define ICE_TEST_LEN ARRAY_SIZE(ice_gstrings_test)
/* These PF_STATs might look like duplicates of some NETDEV_STATs,
* but they aren't. This device is capable of supporting multiple
@@ -1481,48 +1481,53 @@ static void
__ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data,
struct ice_vsi *vsi)
{
+ const char *str;
unsigned int i;
- u8 *p = data;
switch (stringset) {
case ETH_SS_STATS:
- for (i = 0; i < ICE_VSI_STATS_LEN; i++)
- ethtool_puts(&p, ice_gstrings_vsi_stats[i].stat_string);
+ for (i = 0; i < ICE_VSI_STATS_LEN; i++) {
+ str = ice_gstrings_vsi_stats[i].stat_string;
+ ethtool_puts(&data, str);
+ }
if (ice_is_port_repr_netdev(netdev))
return;
ice_for_each_alloc_txq(vsi, i) {
- ethtool_sprintf(&p, "tx_queue_%u_packets", i);
- ethtool_sprintf(&p, "tx_queue_%u_bytes", i);
+ ethtool_sprintf(&data, "tx_queue_%u_packets", i);
+ ethtool_sprintf(&data, "tx_queue_%u_bytes", i);
}
ice_for_each_alloc_rxq(vsi, i) {
- ethtool_sprintf(&p, "rx_queue_%u_packets", i);
- ethtool_sprintf(&p, "rx_queue_%u_bytes", i);
+ ethtool_sprintf(&data, "rx_queue_%u_packets", i);
+ ethtool_sprintf(&data, "rx_queue_%u_bytes", i);
}
if (vsi->type != ICE_VSI_PF)
return;
- for (i = 0; i < ICE_PF_STATS_LEN; i++)
- ethtool_puts(&p, ice_gstrings_pf_stats[i].stat_string);
+ for (i = 0; i < ICE_PF_STATS_LEN; i++) {
+ str = ice_gstrings_pf_stats[i].stat_string;
+ ethtool_puts(&data, str);
+ }
for (i = 0; i < ICE_MAX_USER_PRIORITY; i++) {
- ethtool_sprintf(&p, "tx_priority_%u_xon.nic", i);
- ethtool_sprintf(&p, "tx_priority_%u_xoff.nic", i);
+ ethtool_sprintf(&data, "tx_priority_%u_xon.nic", i);
+ ethtool_sprintf(&data, "tx_priority_%u_xoff.nic", i);
}
for (i = 0; i < ICE_MAX_USER_PRIORITY; i++) {
- ethtool_sprintf(&p, "rx_priority_%u_xon.nic", i);
- ethtool_sprintf(&p, "rx_priority_%u_xoff.nic", i);
+ ethtool_sprintf(&data, "rx_priority_%u_xon.nic", i);
+ ethtool_sprintf(&data, "rx_priority_%u_xoff.nic", i);
}
break;
case ETH_SS_TEST:
- memcpy(data, ice_gstrings_test, ICE_TEST_LEN * ETH_GSTRING_LEN);
+ for (i = 0; i < ICE_TEST_LEN; i++)
+ ethtool_puts(&data, ice_gstrings_test[i]);
break;
case ETH_SS_PRIV_FLAGS:
for (i = 0; i < ICE_PRIV_FLAG_ARRAY_SIZE; i++)
- ethtool_puts(&p, ice_gstrings_priv_flags[i].name);
+ ethtool_puts(&data, ice_gstrings_priv_flags[i].name);
break;
default:
break;