mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kory Maincent <kory.maincent@bootlin.com>
To: Ian Rogers <irogers@google.com>,
	Oleksij Rempel <o.rempel@pengutronix.de>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev, Elkin Cruz <elkin@google.com>
Subject: Re: [PATCH net] net: pse-pd: pd692x0: Return fw_upload_err codes from firmware upload ops
Date: Thu, 19 Nov 2026 18:26:48 +0100	[thread overview]
Message-ID: <f712f16f-dd35-4afc-81db-4e93232846aa@bootlin.com> (raw)
In-Reply-To: <20261119171014.1534691-1-irogers@google.com>



On 11/19/26 18:10, Ian Rogers wrote:
> pd692x0_fw_reset() and pd692x0_fw_write() return negative errno values
> from i2c_master_send() directly as enum fw_upload_err instead of
> FW_UPLOAD_ERR_RW_ERROR, and pd692x0_fw_recv_resp() ignores negative
> errors from its trailing i2c_master_recv(). When a negative errno is
> propagated to the firmware upload core, fw_upload_error() rejects it
> as >= FW_UPLOAD_ERR_MAX, logs an invalid error code message, and
> reports "unknown-error" instead of "read-write-error" via sysfs.
> 
> Return FW_UPLOAD_ERR_RW_ERROR on I2C transfer failures and use
> enum fw_upload_err consistently across the PD692x0 firmware upload
> helpers.

Please write a readable commit message with human hands.

> Found via Clang -Wimplicit-int-enum-cast on an x86_64 allyesconfig
> build. Verified by building drivers/net/pse-pd/pd692x0.o with LLVM=1
> W=1 (-Werror) and -Wimplicit-int-enum-cast, and with a standalone C
> reproducer; not runtime-tested on PD692x0 hardware.
> 
> Fixes: 9a9938451890 ("net: pse-pd: Add PD692x0 PSE controller driver")
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>   drivers/net/pse-pd/pd692x0.c | 81 ++++++++++++++++++------------------
>   1 file changed, 40 insertions(+), 41 deletions(-)
> 
> diff --git a/drivers/net/pse-pd/pd692x0.c b/drivers/net/pse-pd/pd692x0.c
> index 7958f5741463..94a857eaa3de 100644
> --- a/drivers/net/pse-pd/pd692x0.c
> +++ b/drivers/net/pse-pd/pd692x0.c
> @@ -1455,6 +1455,8 @@ pd692x0_fw_recv_resp(const struct i2c_client *client, unsigned long ms_timeout,
>   
>   	/* Read remaining characters */
>   	ret = i2c_master_recv(client, fw_msg_buf + 1, msg_size - 1);
> +	if (ret < 0)
> +		return FW_UPLOAD_ERR_RW_ERROR;
>   	if (strncmp(fw_msg_buf, msg_ok, msg_size)) {

The error will be catch anyway by the string comparison. If you want to 
add a check on ret then add another error message.
This is not a fix.

>   		dev_err(&client->dev,
>   			"Wrong FW download process answer (%*pE)\n",
> @@ -1465,9 +1467,10 @@ pd692x0_fw_recv_resp(const struct i2c_client *client, unsigned long ms_timeout,
>   	return FW_UPLOAD_ERR_NONE;
>   }
>   
> -static int pd692x0_fw_write_line(const struct i2c_client *client,
> -				 const char line[PD692X0_FW_LINE_MAX_SZ],
> -				 const bool last_line)
> +static enum fw_upload_err
> +pd692x0_fw_write_line(const struct i2c_client *client,
> +		      const char line[PD692X0_FW_LINE_MAX_SZ],
> +		      const bool last_line)
>   {
>   	int ret;
>   
> @@ -1478,19 +1481,12 @@ static int pd692x0_fw_write_line(const struct i2c_client *client,
>   		line++;
>   	}
>   
> -	if (last_line) {
> -		ret = pd692x0_fw_recv_resp(client, 100, "TP\r\n",
> -					   sizeof("TP\r\n") - 1);
> -		if (ret)
> -			return ret;
> -	} else {
> -		ret = pd692x0_fw_recv_resp(client, 100, "T*\r\n",
> -					   sizeof("T*\r\n") - 1);
> -		if (ret)
> -			return ret;
> -	}
> +	if (last_line)
> +		return pd692x0_fw_recv_resp(client, 100, "TP\r\n",
> +					    sizeof("TP\r\n") - 1);
>   
> -	return FW_UPLOAD_ERR_NONE;
> +	return pd692x0_fw_recv_resp(client, 100, "T*\r\n",
> +				    sizeof("T*\r\n") - 1);

This is not a fix, just moving code around.

For the rest, FW_UPLOAD_ERR_NONE is similar to ret = 0 so there is no 
real issue, only some type mismatch and I am not sure these changes 
should land as a fix.

Regards
-- 
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com


      reply	other threads:[~2026-11-19 17:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 17:10 Ian Rogers
2026-11-19 17:26 ` Kory Maincent [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=f712f16f-dd35-4afc-81db-4e93232846aa@bootlin.com \
    --to=kory.maincent@bootlin.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=elkin@google.com \
    --cc=irogers@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.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®