net: mv88e6xxx: use ethtool_puts
Subsystems (4)
PATCH 1/1 net: mv88e6xxx: use ethtool_puts
Allows simplifying get_strings and avoids manual pointer manipulation.
--- drivers/net/dsa/mv88e6xxx/chip.c | 7 ++----- drivers/net/dsa/mv88e6xxx/serdes.c | 6 ++---- 2 files changed, 4 insertions(+), 9 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.c +2 -5
@@ -1162,8 +1162,7 @@ static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,for (i =0 , j =0 ; i <ARRAY_SIZE (mv88e6xxx_hw_stats); i++) { stat = &mv88e6xxx_hw_stats[i];if (stat->type & types) { -memcpy (data + j *ETH_GSTRING_LEN , stat->string, -ETH_GSTRING_LEN ); +ethtool_puts (&data, stat->string); j++; } }
@@ -1204,9 +1203,7 @@ static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)unsigned int i;for (i =0 ; i <ARRAY_SIZE (mv88e6xxx_atu_vtu_stats_strings); i++) -strscpy (data + i *ETH_GSTRING_LEN , - mv88e6xxx_atu_vtu_stats_strings[i], -ETH_GSTRING_LEN ); +ethtool_puts (&data, mv88e6xxx_atu_vtu_stats_strings[i]); } static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
drivers/net/dsa/mv88e6xxx/serdes.c +2 -4
@@ -144,8 +144,7 @@ int mv88e6352_serdes_get_strings(struct mv88e6xxx_chip *chip,for (i =0 ; i <ARRAY_SIZE (mv88e6352_serdes_hw_stats); i++) { stat = &mv88e6352_serdes_hw_stats[i]; -memcpy (data + i *ETH_GSTRING_LEN , stat->string, -ETH_GSTRING_LEN ); +ethtool_puts (&data, stat->string); }return ARRAY_SIZE (mv88e6352_serdes_hw_stats); }
@@ -405,8 +404,7 @@ int mv88e6390_serdes_get_strings(struct mv88e6xxx_chip *chip,for (i =0 ; i <ARRAY_SIZE (mv88e6390_serdes_hw_stats); i++) { stat = &mv88e6390_serdes_hw_stats[i]; -memcpy (data + i *ETH_GSTRING_LEN , stat->string, -ETH_GSTRING_LEN ); +ethtool_puts (&data, stat->string); }return ARRAY_SIZE (mv88e6390_serdes_hw_stats); }
Signature · 1 line
2.47.0
Quoted 3 lines · Rosen Penev
Allows simplifying
get_stringsand avoids manual pointer manipulation.Signed-off-by Rosen Penev <[email protected]>
Andrew
Quoted 4 lines · Rosen Penev
Allows simplifying
get_stringsand avoids manual pointer manipulation.Signed-off-by Rosen Penev <[email protected]>
LGTM
Signature · 2 lines
Regards, Kalesh A P
Quoted 4 lines · Kalesh Anakkur Purayil
Quoted 2 lines · Rosen Penev
Allows simplifying
get_stringsand avoids manual pointer manipulation.
Looking more at these files, I see further pointer manipulation later on. Specifically I have this change locally:
static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
u32 stringset, uint8_t *data)
{
struct mv88e6xxx_chip *chip = ds->priv;- int count = 0;
if (stringset != ETH_SS_STATS)
return;
mv88e6xxx_reg_lock(chip);- if (chip->info->ops->stats_get_strings)
- count = chip->info->ops->stats_get_strings(chip, data);
-
- if (chip->info->ops->serdes_get_strings) {
- data += count * ETH_GSTRING_LEN;
- count = chip->info->ops->serdes_get_strings(chip, port, data);
- }
-
- data += count * ETH_GSTRING_LEN;
mv88e6xxx_atu_vtu_get_strings(data);
mv88e6xxx_reg_unlock(chip);Do you guys think a v2 is in order?
Quoted 10 lines
Quoted 2 lines
Signed-off-by Rosen Penev <[email protected]>LGTM
Reviewed-by Kalesh AP <[email protected]>--
Regards,
Kalesh A P
Andrew Lunn
maintainerQuoted 8 lines · Rosen Penev
Quoted 4 lines · Kalesh Anakkur Purayil
Quoted 2 lines · Rosen Penev
Allows simplifying
get_stringsand avoids manual pointer manipulation.Looking more at these files, I see further pointer manipulation later on. Specifically I have this change locally:
So lets mark this as change-requested.
Andrew
---
pw-bot: cr