From: Andrew Lunn <andrew@lunn.ch>
To: Yangfl <mmyangfl@gmail.com>
Cc: netdev@vger.kernel.org, Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Simon Horman <horms@kernel.org>,
Russell King <linux@armlinux.org.uk>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v8 3/3] net: dsa: yt921x: Add support for Motorcomm YT921x
Date: Fri, 12 Sep 2025 17:38:07 +0200 [thread overview]
Message-ID: <47ec4174-ca82-42f6-be52-f28e75c9f007@lunn.ch> (raw)
In-Reply-To: <CAAXyoMPLRHfSUGboC4SO+gBD0TdHq19fNs7AK3W2ZQnHT48gyA@mail.gmail.com>
> > > +static int
> > > +yt921x_mbus_int_write(struct mii_bus *mbus, int port, int reg, u16 data)
> > > +{
> > > + struct yt921x_priv *priv = mbus->priv;
> > > + int res;
> > > +
> > > + if (port >= YT921X_PORT_NUM)
> > > + return 0;
> >
> > -ENODEV.
> >
>
> mdio-tools complains a lot when returning an error code.
It should. There is no device there, so its an error.
> Also that is
> what dsa_user_phy_write() returns for a non-existing port.
I would say that is not ideal. If you are trying to write to a PHY
which does not exist, you want to know about it.
> > > + unsigned long delay = YT921X_STATS_INTERVAL_JIFFIES;
> > > + struct device *dev = to_device(priv);
> > > + struct yt921x_mib *mib = &pp->mib;
> > > + struct yt921x_mib_raw raw;
> > > + int port = pp->index;
> > > + int res;
> > > +
> > > + yt921x_reg_lock(priv);
> > > + res = yt921x_mib_read(priv, port, &raw);
> > > + yt921x_reg_unlock(priv);
> > > +
> > > + if (res) {
> > > + dev_err(dev, "Failed to %s port %d: %i\n", "read stats for",
> > > + port, res);
> > > + delay *= 4;
> > > + goto end;
> > > + }
> > > +
> > > + spin_lock(&pp->stats_lock);
> > > +
> > > + /* Handle overflow of 32bit MIBs */
> > > + for (size_t i = 0; i < ARRAY_SIZE(yt921x_mib_descs); i++) {
> > > + const struct yt921x_mib_desc *desc = &yt921x_mib_descs[i];
> > > + u32 *rawp = (u32 *)((u8 *)&raw + desc->offset);
One thing which might helper is make yt921x_mib_raw and a yt921x_mib
union. List all the fields, but also have a u32 array. You might also
consider a u64 array, so you don't need to construct a u64 from two
u32. But you need to check alignment.
> > > +static bool yt921x_dsa_support_eee(struct dsa_switch *ds, int port)
> > > +{
> > > + struct yt921x_priv *priv = to_yt921x_priv(ds);
> > > +
> > > + return (priv->pon_strap_cap & YT921X_PON_STRAP_EEE) != 0;
> >
> > What does the strapping actually tell you?
> >
>
> Whether EEE capability is present.
This is really a strapping? A resistor pulling the pin high/low?
The silicon itself should know if it has EEE support or not. Strapping
is normally used for configuration, what are the reset defaults. So i
suspect this strapping says the design of the board would like EEE
on/off by default, not that the silicon supports EEE. And the user
should have the choice to enable/disable EEE, independent of the board
designs defaults.
> > What does a while (0) loop bring you here?
> >
>
> break statement instead of goto err.
Which you only seem to do once, here, and nowhere else. And look at
other drivers, how many use a while (0) loop like this?
goto err is the standard way to do this.
Andrew
prev parent reply other threads:[~2025-09-12 15:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-12 2:46 [PATCH net-next v8 0/3] " David Yang
2025-09-12 2:46 ` [PATCH net-next v8 1/3] dt-bindings: net: dsa: yt921x: Add Motorcomm YT921x switch support David Yang
2025-09-12 2:46 ` [PATCH net-next v8 2/3] net: dsa: tag_yt921x: add support for Motorcomm YT921x tags David Yang
2025-09-12 2:46 ` [PATCH net-next v8 3/3] net: dsa: yt921x: Add support for Motorcomm YT921x David Yang
2025-09-12 12:56 ` Andrew Lunn
2025-09-12 14:27 ` Yangfl
2025-09-12 15:38 ` Andrew Lunn [this message]
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=47ec4174-ca82-42f6-be52-f28e75c9f007@lunn.ch \
--to=andrew@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=krzk+dt@kernel.org \
--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 \
--cc=robh@kernel.org \
/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®