[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220325213518.2668832-5-michael@walle.cc>
Date: Fri, 25 Mar 2022 22:35:14 +0100
From: Michael Walle <michael@...le.cc>
To: Andrew Lunn <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: "David S . Miller" <davem@...emloft.net>,
Xu Liang <lxu@...linear.com>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Florian Fainelli <f.fainelli@...il.com>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Michael Walle <michael@...le.cc>
Subject: [PATCH RFC net-next v2 4/8] net: phy: add error handling for __phy_{read,write}_mmd
Now that __phy_mmd_indirect() returns an error code, check it and
additionally check the error code of the last read or write access.
Signed-off-by: Michael Walle <michael@...le.cc>
---
drivers/net/phy/phy-core.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
index dd9b6b64757d..2a300c58d1e5 100644
--- a/drivers/net/phy/phy-core.c
+++ b/drivers/net/phy/phy-core.c
@@ -493,8 +493,11 @@ int __phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum)
} else {
struct mii_bus *bus = phydev->mdio.bus;
int phy_addr = phydev->mdio.addr;
+ int ret;
- __phy_mmd_indirect(bus, phy_addr, devad, regnum);
+ ret = __phy_mmd_indirect(bus, phy_addr, devad, regnum);
+ if (ret)
+ return ret;
/* Read the content of the MMD's selected register */
val = __mdiobus_read(bus, phy_addr, MII_MMD_DATA);
@@ -550,12 +553,12 @@ int __phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val)
struct mii_bus *bus = phydev->mdio.bus;
int phy_addr = phydev->mdio.addr;
- __phy_mmd_indirect(bus, phy_addr, devad, regnum);
+ ret = __phy_mmd_indirect(bus, phy_addr, devad, regnum);
+ if (ret)
+ return ret;
/* Write the data into MMD's selected register */
- __mdiobus_write(bus, phy_addr, MII_MMD_DATA, val);
-
- ret = 0;
+ ret = __mdiobus_write(bus, phy_addr, MII_MMD_DATA, val);
}
return ret;
}
--
2.30.2
Powered by blists - more mailing lists