mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: mmyangfl@gmail.com
Cc: netdev@vger.kernel.org, andrew@lunn.ch, olteanv@gmail.com,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, linux@armlinux.org.uk,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v3 5/8] net: dsa: motorcomm: Introduce yt921x_speed
Date: Mon, 21 Sep 2026 19:44:12 +0000	[thread overview]
Message-ID: <179001985288.2160803.4254571626134705483@kernel.org> (raw)
In-Reply-To: <20260917185010.3189199-6-mmyangfl@gmail.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The new `enum yt921x_speed` in drivers/net/dsa/motorcomm/chip.h
  (lines 116-123) has no explicit enumerator values and no comment, yet…
- [Low] The new driver-private helper added in
  drivers/net/dsa/motorcomm/chip.h is named `ethtool_speed_to_yt921x()`,…

--

net: dsa: motorcomm: Introduce yt921x_speed

This replaces the three per-register speed switch statements in
yt921x_port_up() with a single conversion helper and a new enum, since
FIELD_PREP() results cannot be used as case labels.  The old
YT921X_{PORT,SERDES,MDIO_POLLING}_SPEED_* constants are dropped in favour
of feeding the enum value into the corresponding FIELD_PREP() wrappers.

> diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
> index 5049f4be8aa6b..c99be2044fa20 100644
> --- a/drivers/net/dsa/motorcomm/chip.c
> +++ b/drivers/net/dsa/motorcomm/chip.c
> @@ -3771,29 +3771,15 @@ yt921x_port_up(struct yt921x_priv *priv, int port, unsigned int mode,
>  {
>  	const struct yt921x_info *info = priv->info;
>  	struct yt921x_port *pp = &priv->ports[port];
> +	int ps = ethtool_speed_to_yt921x(speed);

[Severity: Low]
This isn't a bug, but should this helper carry the driver prefix?  Every
other symbol reachable from chip.h uses yt921x_/YT921X_, while this new
static inline takes a name in the core ethtool_ namespace, so the call
site here reads as if the DSA driver is calling core ethtool API.

Would something like yt921x_speed_from_ethtool() be preferable, both here
and at the definition in chip.h?  It would also avoid a collision should a
generic ethtool_speed_to_* helper or macro ever appear in
include/linux/ethtool.h.

>  	u32 mask;
>  	u32 ctrl;
>  	int res;
>  
> -	switch (speed) {
> -	case SPEED_10:
> -		ctrl = YT921X_PORT_SPEED_10;
> -		break;
> -	case SPEED_100:
> -		ctrl = YT921X_PORT_SPEED_100;
> -		break;
> -	case SPEED_1000:
> -		ctrl = YT921X_PORT_SPEED_1000;
> -		break;
> -	case SPEED_2500:
> -		ctrl = YT921X_PORT_SPEED_2500;
> -		break;
> -	case SPEED_10000:
> -		ctrl = YT921X_PORT_SPEED_10000;
> -		break;
> -	default:
> +	if (ps == YT921X_SPEED_NUM)
>  		return -EINVAL;
> -	}
> +
> +	ctrl = YT921X_PORT_SPEED(ps);

[ ... ]

> @@ -3810,25 +3796,7 @@ yt921x_port_up(struct yt921x_priv *priv, int port, unsigned int mode,
>  
>  	if (pp->serdes) {
>  		mask = YT921X_SERDES_SPEED_M;
> -		switch (speed) {
[ ... ]
> -		}
> +		ctrl = YT921X_SERDES_SPEED(ps);

[ ... ]

> @@ -3850,25 +3818,7 @@ yt921x_port_up(struct yt921x_priv *priv, int port, unsigned int mode,
>  		if (res)
>  			return res;
>  
> -		switch (speed) {
[ ... ]
> -		}
> +		ctrl = YT921X_MDIO_POLLING_SPEED(ps);

> diff --git a/drivers/net/dsa/motorcomm/chip.h b/drivers/net/dsa/motorcomm/chip.h
> index 3fb0c6a69dd8c..b3670f1e14276 100644
> --- a/drivers/net/dsa/motorcomm/chip.h
> +++ b/drivers/net/dsa/motorcomm/chip.h
> @@ -89,11 +89,6 @@
>  #define  YT921X_SERDES_DUPLEX_FULL		BIT(3)
>  #define  YT921X_SERDES_SPEED_M			GENMASK(2, 0)
>  #define   YT921X_SERDES_SPEED(x)			FIELD_PREP(YT921X_SERDES_SPEED_M, (x))
> -#define   YT921X_SERDES_SPEED_10			YT921X_SERDES_SPEED(0)
> -#define   YT921X_SERDES_SPEED_100			YT921X_SERDES_SPEED(1)
> -#define   YT921X_SERDES_SPEED_1000			YT921X_SERDES_SPEED(2)
> -#define   YT921X_SERDES_SPEED_10000			YT921X_SERDES_SPEED(3)
> -#define   YT921X_SERDES_SPEED_2500			YT921X_SERDES_SPEED(4)

[ ... ]

> @@ -107,11 +102,6 @@
>  #define  YT921X_PORT_SPEED_M			GENMASK(2, 0)
>  #define   YT921X_PORT_SPEED(x)				FIELD_PREP(YT921X_PORT_SPEED_M, (x))
> -#define   YT921X_PORT_SPEED_10				YT921X_PORT_SPEED(0)
> -#define   YT921X_PORT_SPEED_100				YT921X_PORT_SPEED(1)
> -#define   YT921X_PORT_SPEED_1000			YT921X_PORT_SPEED(2)
> -#define   YT921X_PORT_SPEED_10000			YT921X_PORT_SPEED(3)
> -#define   YT921X_PORT_SPEED_2500			YT921X_PORT_SPEED(4)

[ ... ]

> @@ -122,11 +112,16 @@
>  #define  YT921X_MDIO_POLLING_SPEED_M		GENMASK(2, 0)
>  #define   YT921X_MDIO_POLLING_SPEED(x)			FIELD_PREP(YT921X_MDIO_POLLING_SPEED_M, (x))
> -#define   YT921X_MDIO_POLLING_SPEED_10			YT921X_MDIO_POLLING_SPEED(0)
> -#define   YT921X_MDIO_POLLING_SPEED_100			YT921X_MDIO_POLLING_SPEED(1)
> -#define   YT921X_MDIO_POLLING_SPEED_1000		YT921X_MDIO_POLLING_SPEED(2)
> -#define   YT921X_MDIO_POLLING_SPEED_10000		YT921X_MDIO_POLLING_SPEED(3)
> -#define   YT921X_MDIO_POLLING_SPEED_2500		YT921X_MDIO_POLLING_SPEED(4)
> +
> +enum yt921x_speed {
> +	YT921X_SPEED_10,
> +	YT921X_SPEED_100,
> +	YT921X_SPEED_1000,
> +	YT921X_SPEED_10000,
> +	YT921X_SPEED_2500,
> +	YT921X_SPEED_NUM
> +};

[Severity: Low]
Should these enumerators carry explicit values?  The ordinals here are the
raw hardware field encodings, which yt921x_port_up() writes straight into
three register fields:

	ctrl = YT921X_PORT_SPEED(ps);
	...
	ctrl = YT921X_SERDES_SPEED(ps);
	...
	ctrl = YT921X_MDIO_POLLING_SPEED(ps);

The encoding is not monotonic in speed (10G is 3, 2.5G is 4).  Before this
patch that was visible in the constants being removed above:

	#define   YT921X_PORT_SPEED_10000	YT921X_PORT_SPEED(3)
	#define   YT921X_PORT_SPEED_2500	YT921X_PORT_SPEED(4)

Afterwards the only record of it is the textual order of the enumerators.

Would a later "sort these by speed" cleanup then silently program 2.5G as 3
and 10G as 4, with no compile-time or runtime diagnostic?  Assigning
YT921X_SPEED_10000 = 3 and YT921X_SPEED_2500 = 4 explicitly, and/or noting
in a comment that these are hardware field encodings, would keep that
intact.

The values themselves are unchanged by this patch (10 -> 0, 100 -> 1,
1000 -> 2, 10000 -> 3, 2500 -> 4 all match the removed macros), and the
enum still has no explicit values at the end of the series.

[ ... ]

> @@ -1004,4 +999,22 @@ struct yt921x_priv {
>  	struct yt921x_acl_blk *acl_blks[YT921X_ACL_BLK_NUM];
>  };
>  
> +static inline int ethtool_speed_to_yt921x(int speed)
     ^^^^^^^^^^^^^^^^^^^^^^^^

[Severity: Low]
This is the definition referred to above; renaming it to something like
yt921x_speed_from_ethtool() would keep the driver's namespace consistent.

> +{
> +	switch (speed) {
> +	case SPEED_10:
> +		return YT921X_SPEED_10;
[ ... ]
> +	default:
> +		return YT921X_SPEED_NUM;
> +	}
> +}
> +
>  #endif

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260917185010.3189199-1-mmyangfl%40gmail.com

  reply	other threads:[~2026-09-21 19:44 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 18:49 [PATCH net-next v3 0/8] net: dsa: motorcomm: Add SerDes PCS David Yang
2026-09-17 18:49 ` [PATCH net-next v3 1/8] net: dsa: motorcomm: Remove YT921X_PORT_MASK_* macros David Yang
2026-09-22 11:45   ` Andrew Lunn
2026-09-17 18:49 ` [PATCH net-next v3 2/8] net: dsa: motorcomm: Split xMII and SERDES port masks David Yang
2026-09-22 11:47   ` Andrew Lunn
2026-09-17 18:49 ` [PATCH net-next v3 3/8] net: dsa: motorcomm: Check port type with runtime info David Yang
2026-09-21 19:44   ` netdev-bot+sashiko
2026-09-17 18:49 ` [PATCH net-next v3 4/8] net: dsa: motorcomm: Fix register bit field names David Yang
2026-09-22 11:48   ` Andrew Lunn
2026-09-17 18:49 ` [PATCH net-next v3 5/8] net: dsa: motorcomm: Introduce yt921x_speed David Yang
2026-09-21 19:44   ` netdev-bot+sashiko [this message]
2026-09-22 11:53   ` Andrew Lunn
2026-09-17 18:49 ` [PATCH net-next v3 6/8] net: dsa: motorcomm: Hoist port_to_priv helper into chip.h David Yang
2026-09-22 11:53   ` Andrew Lunn
2026-09-17 18:49 ` [PATCH net-next v3 7/8] net: dsa: motorcomm: Split MDIO bus module David Yang
2026-09-21 19:44   ` netdev-bot+sashiko
2026-09-22 11:56   ` Andrew Lunn
2026-09-17 18:49 ` [PATCH net-next v3 8/8] net: dsa: motorcomm: Add SerDes PCS David Yang
2026-09-21 19:44   ` netdev-bot+sashiko
2026-09-22 12:04   ` Andrew Lunn
2026-09-22 11:23 ` [PATCH net-next v3 0/8] " Paolo Abeni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179001985288.2160803.4254571626134705483@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mmyangfl@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®