[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <67f7960a.050a0220.3a2285.9d15@mx.google.com>
Date: Thu, 10 Apr 2025 11:57:24 +0200
From: Christian Marangi <ansuelsmth@...il.com>
To: Andrew Lunn <andrew@...n.ch>
Cc: Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
Florian Fainelli <florian.fainelli@...adcom.com>,
Broadcom internal kernel review list <bcm-kernel-feedback-list@...adcom.com>,
Marek BehĂșn <kabel@...nel.org>,
Andrei Botila <andrei.botila@....nxp.com>,
Sabrina Dubroca <sd@...asysnail.net>,
Daniel Golle <daniel@...rotopia.org>,
Eric Woudstra <ericwouds@...il.com>, netdev@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [net-next PATCH v6 5/6] net: phy: Add support for Aeonsemi
AS21xxx PHYs
On Wed, Apr 09, 2025 at 06:29:59PM +0200, Andrew Lunn wrote:
> > +static int aeon_ipc_get_fw_version(struct phy_device *phydev)
> > +{
> > + u16 ret_data[8], data[1];
> > + u16 ret_sts;
> > + int ret;
> > +
> > + data[0] = IPC_INFO_VERSION;
> > + ret = aeon_ipc_send_msg(phydev, IPC_CMD_INFO, data,
> > + sizeof(data), &ret_sts);
> > + if (ret)
> > + return ret;
> > +
> > + ret = aeon_ipc_rcv_msg(phydev, ret_sts, ret_data);
> > + if (ret < 0)
> > + return ret;
> > +
> > + phydev_info(phydev, "Firmware Version: %s\n", (char *)ret_data);
>
> Maybe don't trust the firmware to return a \0 terminated string?
>
> > +static int as21xxx_match_phy_device(struct phy_device *phydev,
> > + const struct phy_driver *phydrv)
> > +{
> > + /* Sync parity... */
> > + ret = aeon_ipc_sync_parity(phydev, priv);
> > + if (ret)
> > + goto out;
> > +
> > + /* ...and send a third NOOP cmd to wait for firmware finish loading */
> > + ret = aeon_ipc_noop(phydev, priv, &ret_sts);
> > + if (ret)
> > + goto out;
> > +
> > +out:
> > + mutex_destroy(&priv->ipc_lock);
> > + kfree(priv);
> > +
> > + /* Return not maching anyway as PHY ID will change after
> > + * firmware is loaded. This relies on the driver probe
> > + * order where the first PHY driver probed is the
> > + * generic one.
> > + */
> > + return ret;
> > +}
>
> This is not obvious. ret is either an error code, and we want to
> return it. Or it is 0 because aeon_ipc_noop() returned 0 on success.
> But the code then turns that 0 success into a false, does not match.
> I think this last bit needs commenting on.
>
> With those two fixed, you can add my Reviewed-by:
>
Hi Andrew,
I just sent v7 but I didn't add the review tag just to make sure you are
ok with the additional comments and handling of NULL terminated string.
--
Ansuel
Powered by blists - more mailing lists