[PATCH 3/4] net: ksz9477: propagate phy read error
Gerald Loacker
gerald.loacker at wolfvision.net
Fri Sep 8 03:16:48 PDT 2023
In case of an error we should not return an arbitrary value, propagate the
error code instead.
Fix return value in case of address error.
Signed-off-by: Gerald Loacker <gerald.loacker at wolfvision.net>
---
drivers/net/ksz9477.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ksz9477.c b/drivers/net/ksz9477.c
index 9665e0f723..d664b7cf01 100644
--- a/drivers/net/ksz9477.c
+++ b/drivers/net/ksz9477.c
@@ -29,14 +29,15 @@ static int ksz9477_phy_read16(struct dsa_switch *ds, int addr, int reg)
{
struct device *dev = ds->dev;
struct ksz_switch *priv = dev_get_priv(dev);
- u16 val = 0xffff;
+ u16 val;
+ int ret;
if (addr >= priv->phy_port_cnt)
- return val;
+ return -EINVAL;
- ksz_pread16(priv, addr, 0x100 + (reg << 1), &val);
+ ret = ksz_pread16(priv, addr, 0x100 + (reg << 1), &val);
- return val;
+ return (ret < 0) ? ret : val;
}
static int ksz9477_phy_write16(struct dsa_switch *ds, int addr, int reg,
--
2.37.2
More information about the barebox
mailing list