Re: [PATCH net] net: pse-pd: pd692x0: Return fw_upload_err codes from firmware upload ops

From: Kory Maincent

Date: Thu Nov 19 2026 - 12:27:04 EST




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@xxxxxxxxxx>
---
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