[PATCH 6/8] [media] cx231xx: Use common error handling code in read_eeprom()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 17 Sep 2017 20:22:15 +0200

Add a jump target so that a bit of exception handling can be better reused
at the end of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
 drivers/media/usb/cx231xx/cx231xx-cards.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index d204f220dfe5..04c0734aee79 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1117,20 +1117,17 @@ static int read_eeprom(struct cx231xx *dev, struct i2c_client *client,
 
 	/* start reading at offset 0 */
 	ret = i2c_transfer(client->adapter, &msg_write, 1);
-	if (ret < 0) {
-		dev_err(dev->dev, "Can't read eeprom\n");
-		return ret;
-	}
+	if (ret < 0)
+		goto report_failure;
 
 	while (len_todo > 0) {
 		msg_read.len = (len_todo > 64) ? 64 : len_todo;
 		msg_read.buf = eedata_cur;
 
 		ret = i2c_transfer(client->adapter, &msg_read, 1);
-		if (ret < 0) {
-			dev_err(dev->dev, "Can't read eeprom\n");
-			return ret;
-		}
+		if (ret < 0)
+			goto report_failure;
+
 		eedata_cur += msg_read.len;
 		len_todo -= msg_read.len;
 	}
@@ -1140,6 +1137,10 @@ static int read_eeprom(struct cx231xx *dev, struct i2c_client *client,
 			i, 16, &eedata[i]);
 
 	return 0;
+
+report_failure:
+	dev_err(dev->dev, "Can't read eeprom\n");
+	return ret;
 }
 
 void cx231xx_card_setup(struct cx231xx *dev)
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux