lkml.org 
[lkml]   [2017]   [Oct]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] iio/adc/palmas: Use common error handling code in palmas_gpadc_calibrate()
Date
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 26 Oct 2017 07:58:03 +0200

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

* Adjust condition checks.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/iio/adc/palmas_gpadc.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c
index 69b9affeef1e..5e6566692d46 100644
--- a/drivers/iio/adc/palmas_gpadc.c
+++ b/drivers/iio/adc/palmas_gpadc.c
@@ -304,17 +304,13 @@ static int palmas_gpadc_calibrate(struct palmas_gpadc *adc, int adc_chan)

ret = palmas_read(adc->palmas, PALMAS_TRIM_GPADC_BASE,
adc->adc_info[adc_chan].trim1_reg, &d1);
- if (ret < 0) {
- dev_err(adc->dev, "TRIM read failed: %d\n", ret);
- goto scrub;
- }
+ if (ret)
+ goto report_failure;

ret = palmas_read(adc->palmas, PALMAS_TRIM_GPADC_BASE,
adc->adc_info[adc_chan].trim2_reg, &d2);
- if (ret < 0) {
- dev_err(adc->dev, "TRIM read failed: %d\n", ret);
- goto scrub;
- }
+ if (ret)
+ goto report_failure;

/* gain error calculation */
k = (1000 + (1000 * (d2 - d1)) / (x2 - x1));
@@ -329,6 +325,10 @@ static int palmas_gpadc_calibrate(struct palmas_gpadc *adc, int adc_chan)

scrub:
return ret;
+
+report_failure:
+ dev_err(adc->dev, "TRIM read failed: %d\n", ret);
+ goto scrub;
}

static int palmas_gpadc_start_conversion(struct palmas_gpadc *adc, int adc_chan)
--
2.14.3
\
 
 \ /
  Last update: 2017-10-26 08:09    [W:0.064 / U:0.448 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site