From: Andrew Lunn <andrew@lunn.ch>
To: Miaoqian Lin <linmq006@gmail.com>
Cc: Vivien Didelot <vivien.didelot@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Ansuel Smith <ansuelsmth@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: dsa: Fix return value check of wait_for_completion_timeout
Date: Tue, 12 Apr 2022 14:53:26 +0200 [thread overview]
Message-ID: <YlV2Rr+12Ikwa4yk@lunn.ch> (raw)
In-Reply-To: <20220412024541.17572-1-linmq006@gmail.com>
On Tue, Apr 12, 2022 at 02:45:40AM +0000, Miaoqian Lin wrote:
> wait_for_completion_timeout() returns unsigned long not int.
> It returns 0 if timed out, and positive if completed.
> The check for <= 0 is ambiguous and should be == 0 here
> indicating timeout which is the only error case.
Please fix your subject line to indicate which driver you are patching.
Please also read the netdev FAQ which will point out a few other
process issues.
>
> Fixes: 2cd548566384 ("net: dsa: qca8k: add support for phy read/write with mgmt Ethernet")
> Fixes: 5950c7c0a68c ("net: dsa: qca8k: add support for mgmt read/write in Ethernet packet")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
> drivers/net/dsa/qca8k.c | 25 +++++++++++++------------
> 1 file changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
> index d3ed0a7f8077..bd8c238955a8 100644
> --- a/drivers/net/dsa/qca8k.c
> +++ b/drivers/net/dsa/qca8k.c
> @@ -300,7 +300,7 @@ static int qca8k_read_eth(struct qca8k_priv *priv, u32 reg, u32 *val, int len)
> struct qca8k_mgmt_eth_data *mgmt_eth_data = &priv->mgmt_eth_data;
> struct sk_buff *skb;
> bool ack;
> - int ret;
> + unsigned long ret;
Please sort variables longest to shortest, reverse christmass tree.
>
> skb = qca8k_alloc_mdio_header(MDIO_READ, reg, NULL,
> QCA8K_ETHERNET_MDIO_PRIORITY, len);
> @@ -338,7 +338,7 @@ static int qca8k_read_eth(struct qca8k_priv *priv, u32 reg, u32 *val, int len)
>
> mutex_unlock(&mgmt_eth_data->mutex);
>
> - if (ret <= 0)
> + if (ret == 0)
> return -ETIMEDOUT;
Given this change, what happens if -ERESTARTSYS is returned?
Please consider the same question for all cases you change <= to ==.
Andrew
prev parent reply other threads:[~2022-04-12 13:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-12 2:45 Miaoqian Lin
2022-04-12 12:53 ` 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=YlV2Rr+12Ikwa4yk@lunn.ch \
--to=andrew@lunn.ch \
--cc=ansuelsmth@gmail.com \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linmq006@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=vivien.didelot@gmail.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®