diff mbox series

[RFC,net-next,v2,4/8] net: phy: add error handling for __phy_{read,write}_mmd

Message ID 20220325213518.2668832-5-michael@walle.cc (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series net: phy: C45-over-C22 access | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 28 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Michael Walle March 25, 2022, 9:35 p.m. UTC
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@walle.cc>
---
 drivers/net/phy/phy-core.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
diff mbox series

Patch

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;
 }