netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lan78xx: Fix ladv/radv error handling in lan78xx_link_reset()
@ 2015-09-04 10:47 Geert Uytterhoeven
  2015-09-07  2:47 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2015-09-04 10:47 UTC (permalink / raw)
  To: Woojung.Huh, David S. Miller
  Cc: linux-usb, netdev, linux-kernel, Geert Uytterhoeven

net/usb/lan78xx.c: In function ‘lan78xx_link_reset’:
net/usb/lan78xx.c:1107: warning: comparison is always false due to limited range of data type
net/usb/lan78xx.c:1111: warning: comparison is always false due to limited range of data type

Assigning return values that can be negative error codes to "u16"
variables makes them positive, ignoring the errors.  Hence use "int"
instead.

Drop the "unlikely"s (unlikely considered harmful) and propagate the
actual error values instead of overriding them to -EIO while we're at
it.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Compile-tested only.

Many more overridden or plainly ignored errors, and lots of unlikely()
abuse to fix...
---
 drivers/net/usb/lan78xx.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 39364a45af404388..a39518fc93aadf82 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1049,8 +1049,7 @@ static int lan78xx_link_reset(struct lan78xx_net *dev)
 {
 	struct mii_if_info *mii = &dev->mii;
 	struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
-	u16 ladv, radv;
-	int ret;
+	int ladv, radv, ret;
 	u32 buf;
 
 	/* clear PHY interrupt status */
@@ -1104,12 +1103,12 @@ static int lan78xx_link_reset(struct lan78xx_net *dev)
 		}
 
 		ladv = lan78xx_mdio_read(dev->net, mii->phy_id, MII_ADVERTISE);
-		if (unlikely(ladv < 0))
-			return -EIO;
+		if (ladv < 0)
+			return ladv;
 
 		radv = lan78xx_mdio_read(dev->net, mii->phy_id, MII_LPA);
-		if (unlikely(radv < 0))
-			return -EIO;
+		if (radv < 0)
+			return radv;
 
 		netif_dbg(dev, link, dev->net,
 			  "speed: %u duplex: %d anadv: 0x%04x anlpa: 0x%04x",
-- 
1.9.1

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

* Re: [PATCH] lan78xx: Fix ladv/radv error handling in lan78xx_link_reset()
  2015-09-04 10:47 [PATCH] lan78xx: Fix ladv/radv error handling in lan78xx_link_reset() Geert Uytterhoeven
@ 2015-09-07  2:47 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2015-09-07  2:47 UTC (permalink / raw)
  To: geert; +Cc: Woojung.Huh, linux-usb, netdev, linux-kernel

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: Fri,  4 Sep 2015 12:47:28 +0200

> net/usb/lan78xx.c: In function ‘lan78xx_link_reset’:
> net/usb/lan78xx.c:1107: warning: comparison is always false due to limited range of data type
> net/usb/lan78xx.c:1111: warning: comparison is always false due to limited range of data type
> 
> Assigning return values that can be negative error codes to "u16"
> variables makes them positive, ignoring the errors.  Hence use "int"
> instead.
> 
> Drop the "unlikely"s (unlikely considered harmful) and propagate the
> actual error values instead of overriding them to -EIO while we're at
> it.
> 
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

Applied, thanks.

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

end of thread, other threads:[~2015-09-07  2:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-04 10:47 [PATCH] lan78xx: Fix ladv/radv error handling in lan78xx_link_reset() Geert Uytterhoeven
2015-09-07  2:47 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).