All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: lan9303: fix missing error handling
@ 2019-03-10  8:08 Kangjie Lu
  2019-03-10 18:00 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Kangjie Lu @ 2019-03-10  8:08 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Andrew Lunn, Vivien Didelot, Florian Fainelli,
	David S. Miller, netdev, linux-kernel

Both lan9303_phy_write and regmap_write may fail. The fix adds
the error handling to print error messages upon failure.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/net/dsa/lan9303-core.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index 2ffab7ee3d80..3f5e89f431f9 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -1072,6 +1072,10 @@ static void lan9303_adjust_link(struct dsa_switch *ds, int port,
 		ctl &= ~BMCR_FULLDPLX;
 
 	res =  lan9303_phy_write(ds, port, MII_BMCR, ctl);
+	if (res) {
+		dev_err(ds->dev, "lan9303_phy_write failed: %d\n", res);
+		return;
+	}
 
 	if (port == chip->phy_addr_base) {
 		/* Virtual Phy: Remove Turbo 200Mbit mode */
@@ -1080,6 +1084,8 @@ static void lan9303_adjust_link(struct dsa_switch *ds, int port,
 		ctl &= ~LAN9303_VIRT_SPECIAL_TURBO;
 		res =  regmap_write(chip->regmap,
 				    LAN9303_VIRT_SPECIAL_CTRL, ctl);
+		if (res)
+			dev_err(ds->dev, "regmap_write failed: %d\n", res);
 	}
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: lan9303: fix missing error handling
  2019-03-10  8:08 [PATCH] net: lan9303: fix missing error handling Kangjie Lu
@ 2019-03-10 18:00 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-03-10 18:00 UTC (permalink / raw)
  To: kjlu; +Cc: pakki001, andrew, vivien.didelot, f.fainelli, netdev, linux-kernel

From: Kangjie Lu <kjlu@umn.edu>
Date: Sun, 10 Mar 2019 03:08:56 -0500

> Both lan9303_phy_write and regmap_write may fail. The fix adds
> the error handling to print error messages upon failure.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>

It's ignored elsewhere in this driver in places you haven't handled.

I doubt this is much of an improvement to the driver to be quite
honest.

I disagree with the mantra that just because an error is potentially
returned, that it always must be checked.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-10 18:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-10  8:08 [PATCH] net: lan9303: fix missing error handling Kangjie Lu
2019-03-10 18:00 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.