From: Daniel Golle <daniel@makrotopia.org>
To: Paolo Abeni <pabeni@redhat.com>
Cc: Andrew Lunn <andrew@lunn.ch>, Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, Frank Wunderlich <frankwu@gmx.de>,
Chad Monroe <chad@monroe.io>,
Cezary Wilmanski <cezary.wilmanski@adtran.com>,
Avinash Jayaraman <ajayaraman@maxlinear.com>,
Bing tao Xu <bxu@maxlinear.com>, Liang Xu <lxu@maxlinear.com>,
Juraj Povazanec <jpovazanec@maxlinear.com>,
"Fanni (Fang-Yi) Chan" <fchan@maxlinear.com>,
"Benny (Ying-Tsan) Weng" <yweng@maxlinear.com>,
"Livia M. Rosu" <lrosu@maxlinear.com>,
John Crispin <john@phrozen.org>
Subject: Re: [PATCH net-next v8 4/4] net: dsa: add basic initial driver for MxL862xx switches
Date: Tue, 27 Jan 2026 11:53:28 +0000 [thread overview]
Message-ID: <aXinOE7KIFIm5dUK@makrotopia.org> (raw)
In-Reply-To: <c2e191c4-dec4-4e42-b108-353778d9bd18@redhat.com>
On Tue, Jan 27, 2026 at 11:41:00AM +0100, Paolo Abeni wrote:
> On 1/22/26 4:42 AM, Daniel Golle wrote:
> > +static int mxl862xx_send_cmd(struct mxl862xx_priv *priv, u16 cmd, u16 size,
> > + bool quiet)
> > +{
> > + int ret;
> > +
> > + ret = mxl862xx_reg_write(priv, MXL862XX_MMD_REG_LEN_RET, size);
> > + if (ret)
> > + return ret;
> > +
> > + ret = mxl862xx_reg_write(priv, MXL862XX_MMD_REG_CTRL,
> > + cmd | CTRL_BUSY_MASK);
> > + if (ret)
> > + return ret;
> > +
> > + ret = mxl862xx_busy_wait(priv);
> > + if (ret)
> > + return ret;
> > +
> > + ret = mxl862xx_reg_read(priv, MXL862XX_MMD_REG_LEN_RET);
> > + /* handle errors returned by the firmware as -EIO
> > + * The firmware is based on Zephyr OS and uses the errors as
> > + * defined in errno.h of Zephyr OS. See
> > + * https://github.com/zephyrproject-rtos/zephyr/blob/v3.7.0/lib/libc/minimal/include/errno.h
> > + */
> > + if ((s16)ret < 0) {
>
> The cast is likely not needed above? if `ret` values < S16_MIN are
> possible this will return such values to the caller without the IO err
> printk.
Right, it should rather be
if (ret > S16_MAX && ret <= U16_MAX)
to really only catch the range of numbers which are negative 16-bit
signed values represented as positive 32-bit signed values.
mxl862xx_reg_read() primarily returns a signed 32-bit integer, as it is
basically just a wrapper around __mdiodev_c45_read(). Negative values of
that 32-bit integer mean that the MDIO Clause-45 read has somehow
failed, ie. it's the error the MDIO bus .read_c45() operation has
returned.
In case __mdiodev_c45_read() succeeds it returns the 16-bit value of the
register read. In this case, those 16-bit should be interpreted as a
16-bit signed integer here. A negative value denotes an error returned
from the firmware running on the switch (see comment above the code).
>
> > + if (!quiet)
> > + dev_err(&priv->mdiodev->dev,
> > + "CMD %04x returned error %d\n", cmd, (s16)ret);
> > + return -EIO;
> > + }
> > +
> > + return ret;
> > +}
> > +
> > +int mxl862xx_api_wrap(struct mxl862xx_priv *priv, u16 cmd, void *_data,
> > + u16 size, bool read, bool quiet)
> > +{
> > + __le16 *data = _data;
> > + u16 max, i;
> > + int ret, cmd_ret;
>
> Minor nit: reverse christmas tree above.
Oh right.... I anyway found another minor issue, so I'm going to send
v9 with the above as well as the other minor issue fixed.
> BTW the initial port isolation LGTM, but I would appreciate some DSA
> expert second opinion.
+1
next prev parent reply other threads:[~2026-01-27 11:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-22 3:41 [PATCH net-next v8 0/4] net: dsa: initial support for MaxLinear MxL862xx switches Daniel Golle
2026-01-22 3:41 ` [PATCH net-next v8 1/4] dt-bindings: net: dsa: add MaxLinear MxL862xx Daniel Golle
2026-01-22 3:41 ` [PATCH net-next v8 2/4] net: dsa: add tag format for MxL862xx switches Daniel Golle
2026-01-22 3:41 ` [PATCH net-next v8 3/4] net: mdio: add unlocked mdiodev C45 bus accessors Daniel Golle
2026-01-22 3:42 ` [PATCH net-next v8 4/4] net: dsa: add basic initial driver for MxL862xx switches Daniel Golle
2026-01-27 10:41 ` Paolo Abeni
2026-01-27 11:53 ` Daniel Golle [this message]
2026-01-27 13:24 ` Vladimir Oltean
2026-01-27 13:50 ` Andrew Lunn
2026-01-27 14:48 ` Daniel Golle
2026-01-27 15:04 ` Andrew Lunn
2026-01-27 16:07 ` Daniel Golle
2026-01-27 18:28 ` Andrew Lunn
2026-01-27 19:02 ` Daniel Golle
2026-01-27 18:34 ` Andrew Lunn
2026-01-27 19:10 ` Daniel Golle
2026-01-27 16:19 ` Russell King (Oracle)
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=aXinOE7KIFIm5dUK@makrotopia.org \
--to=daniel@makrotopia.org \
--cc=ajayaraman@maxlinear.com \
--cc=andrew@lunn.ch \
--cc=bxu@maxlinear.com \
--cc=cezary.wilmanski@adtran.com \
--cc=chad@monroe.io \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=fchan@maxlinear.com \
--cc=frankwu@gmx.de \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=john@phrozen.org \
--cc=jpovazanec@maxlinear.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lrosu@maxlinear.com \
--cc=lxu@maxlinear.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
--cc=yweng@maxlinear.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