public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Daniel Klauer <daniel.klauer@gin.de>
To: <u-boot@lists.denx.de>
Subject: [PATCH 2/2] net: phy: mv88e6352: Fix miiphy_read/miiphy_write return value checks
Date: Wed, 9 Feb 2022 16:32:57 +0100	[thread overview]
Message-ID: <20220209153257.284853-2-daniel.klauer@gin.de> (raw)
In-Reply-To: <20220209153257.284853-1-daniel.klauer@gin.de>

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


  reply	other threads:[~2022-02-09 15:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-09 15:32 [PATCH 1/2] miiphyutil: Fix inconsistent miiphy_write() error return value Daniel Klauer
2022-02-09 15:32 ` Daniel Klauer [this message]
2022-02-12 11:50   ` [PATCH 2/2] net: phy: mv88e6352: Fix miiphy_read/miiphy_write return value checks Ramon Fried
2022-02-14 10:33     ` Daniel Klauer
2022-02-15  7:08       ` Ramon Fried
2022-02-16 10:52         ` Daniel Klauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220209153257.284853-2-daniel.klauer@gin.de \
    --to=daniel.klauer@gin.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox