[PATCH 2/2] net: phy: mv88e6352: Fix miiphy_read/miiphy_write return value checks

Daniel Klauer daniel.klauer at gin.de
Wed Feb 9 16:32:57 CET 2022


The miiphy_read/miiphy_write functions return 1 on error, not -errno.
Fix up the checks accordingly and insert -EIO as fallback error code.

Signed-off-by: Daniel Klauer <daniel.klauer at gin.de>
---
 drivers/net/phy/mv88e6352.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/net/phy/mv88e6352.c b/drivers/net/phy/mv88e6352.c
index 56060762d8..a87af7ed24 100644
--- a/drivers/net/phy/mv88e6352.c
+++ b/drivers/net/phy/mv88e6352.c
@@ -36,16 +36,14 @@ static int sw_wait_rdy(const char *devname, u8 phy_addr)
 {
 	u16 command;
 	u32 timeout = 100;
-	int ret;
 
 	/* wait till the SMI is not busy */
 	do {
 		/* read command register */
-		ret = miiphy_read(devname, phy_addr, COMMAND_REG, &command);
-		if (ret < 0) {
+		if (miiphy_read(devname, phy_addr, COMMAND_REG, &command)) {
 			printf("%s: Error reading command register\n",
 				__func__);
-			return ret;
+			return -EIO;
 		}
 		if (timeout-- == 0) {
 			printf("Err..(%s) SMI busy timeout\n", __func__);
@@ -69,17 +67,17 @@ static int sw_reg_read(const char *devname, u8 phy_addr, u8 port,
 	command = SMI_HDR | SMIRD_OP | ((port&SMI_MASK) << PORT_SHIFT) |
 			(reg & SMI_MASK);
 	debug("%s: write to command: %#x\n", __func__, command);
-	ret = miiphy_write(devname, phy_addr, COMMAND_REG, command);
-	if (ret)
-		return ret;
+	if (miiphy_write(devname, phy_addr, COMMAND_REG, command))
+		return -EIO;
 
 	ret = sw_wait_rdy(devname, phy_addr);
 	if (ret)
 		return ret;
 
-	ret = miiphy_read(devname, phy_addr, DATA_REG, data);
+	if (miiphy_read(devname, phy_addr, DATA_REG, data))
+		return -EIO;
 
-	return ret;
+	return 0;
 }
 
 static int sw_reg_write(const char *devname, u8 phy_addr, u8 port,
@@ -93,16 +91,14 @@ static int sw_reg_write(const char *devname, u8 phy_addr, u8 port,
 		return ret;
 
 	debug("%s: write to data: %#x\n", __func__, data);
-	ret = miiphy_write(devname, phy_addr, DATA_REG, data);
-	if (ret)
-		return ret;
+	if (miiphy_write(devname, phy_addr, DATA_REG, data))
+		return -EIO;
 
 	value = SMI_HDR | SMIWR_OP | ((port & SMI_MASK) << PORT_SHIFT) |
 			(reg & SMI_MASK);
 	debug("%s: write to command: %#x\n", __func__, value);
-	ret = miiphy_write(devname, phy_addr, COMMAND_REG, value);
-	if (ret)
-		return ret;
+	if (miiphy_write(devname, phy_addr, COMMAND_REG, value))
+		return -EIO;
 
 	ret = sw_wait_rdy(devname, phy_addr);
 	if (ret)
-- 
2.32.0



More information about the U-Boot mailing list