diff mbox series

[net-next] net: mv88e6xxx: use ethtool_puts

Message ID 20241021010652.4944-1-rosenp@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: mv88e6xxx: use ethtool_puts | 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 7 of 7 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, 37 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 fail net-next-2024-10-21--06-00 (tests: 777)

Commit Message

Rosen Penev Oct. 21, 2024, 1:06 a.m. UTC
Allows simplifying get_strings and avoids manual pointer manipulation.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/net/dsa/mv88e6xxx/chip.c   | 7 ++-----
 drivers/net/dsa/mv88e6xxx/serdes.c | 6 ++----
 2 files changed, 4 insertions(+), 9 deletions(-)

Comments

Andrew Lunn Oct. 21, 2024, 3:59 p.m. UTC | #1
On Sun, Oct 20, 2024 at 06:06:52PM -0700, Rosen Penev wrote:
> Allows simplifying get_strings and avoids manual pointer manipulation.
> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Kalesh Anakkur Purayil Oct. 21, 2024, 4:27 p.m. UTC | #2
On Mon, Oct 21, 2024 at 6:37 AM Rosen Penev <rosenp@gmail.com> wrote:
>
> Allows simplifying get_strings and avoids manual pointer manipulation.
>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>

LGTM
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Rosen Penev Oct. 21, 2024, 6:56 p.m. UTC | #3
On Mon, Oct 21, 2024 at 9:27 AM Kalesh Anakkur Purayil
<kalesh-anakkur.purayil@broadcom.com> wrote:
>
> On Mon, Oct 21, 2024 at 6:37 AM Rosen Penev <rosenp@gmail.com> wrote:
> >
> > Allows simplifying get_strings and 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?
> >
> > Signed-off-by: Rosen Penev <rosenp@gmail.com>
>
> LGTM
> Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
>
>
> --
> Regards,
> Kalesh A P
Andrew Lunn Oct. 21, 2024, 8:44 p.m. UTC | #4
On Mon, Oct 21, 2024 at 11:56:47AM -0700, Rosen Penev wrote:
> On Mon, Oct 21, 2024 at 9:27 AM Kalesh Anakkur Purayil
> <kalesh-anakkur.purayil@broadcom.com> wrote:
> >
> > On Mon, Oct 21, 2024 at 6:37 AM Rosen Penev <rosenp@gmail.com> wrote:
> > >
> > > Allows simplifying get_strings and 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
diff mbox series

Patch

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index fe123abf7b5b..8416b03e131d 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -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,
diff --git a/drivers/net/dsa/mv88e6xxx/serdes.c b/drivers/net/dsa/mv88e6xxx/serdes.c
index 01ea53940786..327831d2b547 100644
--- a/drivers/net/dsa/mv88e6xxx/serdes.c
+++ b/drivers/net/dsa/mv88e6xxx/serdes.c
@@ -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);
 }