lkml.org 
[lkml]   [2017]   [Sep]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 6/8] [media] cx231xx: Use common error handling code in read_eeprom()
From
Date
From: Markus Elfring <elfring@users.sourceforge.net>
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@users.sourceforge.net>
---
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
\
 
 \ /
  Last update: 2017-09-17 22:23    [W:0.064 / U:2.044 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site