[net-next,01/15] net: dsa: mt7530: make some noise if register read fails

Message ID 9bc5f475099a4a8840842808ea1a1290abf2c0d3.1680180959.git.daniel@makrotopia.org
State New
Headers
Series net: dsa: add support for MT7988 |

Commit Message

Daniel Golle March 30, 2023, 3:19 p.m. UTC
  Simply returning the negative error value instead of the read value
doesn't seem like a good idea. Return 0 instead and add WARN_ON_ONCE(1)
so this kind of error will not go unnoticed.

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 drivers/net/dsa/mt7530.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Andrew Lunn March 30, 2023, 8:58 p.m. UTC | #1
On Thu, Mar 30, 2023 at 04:19:26PM +0100, Daniel Golle wrote:
> Simply returning the negative error value instead of the read value
> doesn't seem like a good idea. Return 0 instead and add WARN_ON_ONCE(1)
> so this kind of error will not go unnoticed.
> 
> Suggested-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
  

Patch

diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index a0d99af897ace..18d4aa6bb9968 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -224,9 +224,10 @@  mt7530_mii_read(struct mt7530_priv *priv, u32 reg)
 	/* MT7530 uses 31 as the pseudo port */
 	ret = bus->write(bus, 0x1f, 0x1f, page);
 	if (ret < 0) {
+		WARN_ON_ONCE(1);
 		dev_err(&bus->dev,
 			"failed to read mt7530 register\n");
-		return ret;
+		return 0;
 	}
 
 	lo = bus->read(bus, 0x1f, r);