From: Andrew Lunn <andrew@lunn.ch>
To: Wan Jiabing <wanjiabing@vivo.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Antoine Tenart <atenart@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
kael_w@yeah.net
Subject: Re: [PATCH net] net: phy: mscc: Add error check when __phy_read() failed
Date: Tue, 10 May 2022 14:25:10 +0200 [thread overview]
Message-ID: <YnpZphRYEZJm/9D6@lunn.ch> (raw)
In-Reply-To: <20220510035458.9804-1-wanjiabing@vivo.com>
On Tue, May 10, 2022 at 11:54:56AM +0800, Wan Jiabing wrote:
> Calling __phy_read() might return a negative error code. Use 'int'
> to declare variables which call __phy_read() and also add error check
> for them.
It would be good to add a comment here:
The numerous callers of vsc8584_macsec_phy_read() don't expect it to
fail. So don't return the error code from __phy_read(), but also don't
return random values if it does fail.
The commit message should try to answer any questions to reviewer
has. And when i first looked at the change, i thought this is wrong,
the error code is thrown away. But then i remembers our discussion. So
it is good to mention that in the commit message.
> Fixes: fa164e40c53b ("net: phy: mscc: split the driver into separate files")
> Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
> ---
> drivers/net/phy/mscc/mscc_macsec.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/phy/mscc/mscc_macsec.c b/drivers/net/phy/mscc/mscc_macsec.c
> index b7b2521c73fb..8a63e32fafa0 100644
> --- a/drivers/net/phy/mscc/mscc_macsec.c
> +++ b/drivers/net/phy/mscc/mscc_macsec.c
> @@ -22,9 +22,9 @@
> static u32 vsc8584_macsec_phy_read(struct phy_device *phydev,
> enum macsec_bank bank, u32 reg)
> {
> - u32 val, val_l = 0, val_h = 0;
> unsigned long deadline;
> - int rc;
> + int rc, val, val_l, val_h;
> + u32 ret = 0;
Networking code uses "reverse christmas tree", meaning these lines
should be sorted, longest first, shortest last. So deadline needs to
come after val_h.
Andrew
prev parent reply other threads:[~2022-05-10 12:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-10 3:54 [PATCH net] net: phy: mscc: Add error check when __phy_read() failed Wan Jiabing
2022-05-10 12:25 ` 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=YnpZphRYEZJm/9D6@lunn.ch \
--to=andrew@lunn.ch \
--cc=atenart@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kael_w@yeah.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=wanjiabing@vivo.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