* [PATCH] smsc95xx: Use common error handling code in smsc95xx_write_eeprom()
@ 2017-10-29 10:15 SF Markus Elfring
0 siblings, 0 replies; only message in thread
From: SF Markus Elfring @ 2017-10-29 10:15 UTC (permalink / raw)
To: netdev, linux-usb, UNGLinuxDriver, Steve Glendinning
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 29 Oct 2017 11:08:34 +0100
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_warn" by goto statements.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/net/usb/smsc95xx.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 309b88acd3d0..6a82e8055e9d 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -399,10 +399,8 @@ static int smsc95xx_write_eeprom(struct usbnet *dev, u32 offset, u32 length,
/* Issue write/erase enable command */
val = E2P_CMD_BUSY_ | E2P_CMD_EWEN_;
ret = smsc95xx_write_reg(dev, E2P_CMD, val);
- if (ret < 0) {
- netdev_warn(dev->net, "Error writing E2P_DATA\n");
- return ret;
- }
+ if (ret < 0)
+ goto report_write_failure;
ret = smsc95xx_wait_eeprom(dev);
if (ret < 0)
@@ -413,10 +411,8 @@ static int smsc95xx_write_eeprom(struct usbnet *dev, u32 offset, u32 length,
/* Fill data register */
val = data[i];
ret = smsc95xx_write_reg(dev, E2P_DATA, val);
- if (ret < 0) {
- netdev_warn(dev->net, "Error writing E2P_DATA\n");
- return ret;
- }
+ if (ret < 0)
+ goto report_write_failure;
/* Send "write" command */
val = E2P_CMD_BUSY_ | E2P_CMD_WRITE_ | (offset & E2P_CMD_ADDR_);
@@ -434,6 +430,10 @@ static int smsc95xx_write_eeprom(struct usbnet *dev, u32 offset, u32 length,
}
return 0;
+
+report_write_failure:
+ netdev_warn(dev->net, "Error writing E2P_DATA\n");
+ return ret;
}
static int __must_check smsc95xx_write_reg_async(struct usbnet *dev, u16 index,
--
2.14.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-10-29 10:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-29 10:15 [PATCH] smsc95xx: Use common error handling code in smsc95xx_write_eeprom() SF Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®