linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lan78xx: Use common error handling code in lan78xx_phy_init()
@ 2017-10-28 20:56 SF Markus Elfring
  2017-10-30 14:32 ` Woojung.Huh
  0 siblings, 1 reply; 2+ messages in thread
From: SF Markus Elfring @ 2017-10-28 20:56 UTC (permalink / raw)
  To: netdev, linux-usb, UNGLinuxDriver, Woojung Huh; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 28 Oct 2017 22:42:52 +0200

* Add a jump target so that a specific error message is stored only once
  at the end of this function implementation.

* Replace two calls of the function "netdev_err" by goto statements.

* Adjust two condition checks.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/usb/lan78xx.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 0161f77641fa..ff07e20621e3 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -2030,17 +2030,15 @@ static int lan78xx_phy_init(struct lan78xx_net *dev)
 		/* external PHY fixup for KSZ9031RNX */
 		ret = phy_register_fixup_for_uid(PHY_KSZ9031RNX, 0xfffffff0,
 						 ksz9031rnx_fixup);
-		if (ret < 0) {
-			netdev_err(dev->net, "fail to register fixup\n");
-			return ret;
-		}
+		if (ret)
+			goto report_fixup_failure;
+
 		/* external PHY fixup for LAN8835 */
 		ret = phy_register_fixup_for_uid(PHY_LAN8835, 0xfffffff0,
 						 lan8835_fixup);
-		if (ret < 0) {
-			netdev_err(dev->net, "fail to register fixup\n");
-			return ret;
-		}
+		if (ret)
+			goto report_fixup_failure;
+
 		/* add more external PHY fixup here if needed */
 
 		phydev->is_internal = false;
@@ -2093,6 +2091,10 @@ static int lan78xx_phy_init(struct lan78xx_net *dev)
 	phy_unregister_fixup_for_uid(PHY_LAN8835, 0xfffffff0);
 
 	return ret;
+
+report_fixup_failure:
+	netdev_err(dev->net, "fail to register fixup\n");
+	return ret;
 }
 
 static int lan78xx_set_rx_max_frame_length(struct lan78xx_net *dev, int size)
-- 
2.14.3

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

* RE: [PATCH] lan78xx: Use common error handling code in lan78xx_phy_init()
  2017-10-28 20:56 [PATCH] lan78xx: Use common error handling code in lan78xx_phy_init() SF Markus Elfring
@ 2017-10-30 14:32 ` Woojung.Huh
  0 siblings, 0 replies; 2+ messages in thread
From: Woojung.Huh @ 2017-10-30 14:32 UTC (permalink / raw)
  To: elfring, netdev, linux-usb, UNGLinuxDriver; +Cc: linux-kernel, kernel-janitors

> From: SF Markus Elfring [mailto:elfring@users.sourceforge.net]
> Sent: Saturday, October 28, 2017 4:57 PM
> To: netdev@vger.kernel.org; linux-usb@vger.kernel.org; UNGLinuxDriver;
> Woojung Huh - C21699
> Cc: LKML; kernel-janitors@vger.kernel.org
> Subject: [PATCH] lan78xx: Use common error handling code in
> lan78xx_phy_init()
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 28 Oct 2017 22:42:52 +0200
> 
> * Add a jump target so that a specific error message is stored only once
>   at the end of this function implementation.
> 
> * Replace two calls of the function "netdev_err" by goto statements.
> 
> * Adjust two condition checks.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---

Reviewed-by: Woojung Huh <Woojung.Huh@microchip.com>

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

end of thread, other threads:[~2017-10-30 14:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-28 20:56 [PATCH] lan78xx: Use common error handling code in lan78xx_phy_init() SF Markus Elfring
2017-10-30 14:32 ` Woojung.Huh

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).