aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/iio
diff options
context:
space:
mode:
authorMarkus Elfring <elfring@users.sourceforge.net>2017-11-03 09:00:25 +0100
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2017-12-02 10:40:05 +0000
commit71e083aaf716fffa91cf80e85e88f3c0674be81a (patch)
tree8bba64f34b7c69aa9e5e6a4e1e7e269a8ecd8850 /drivers/staging/iio
parentiio: magnetometer: ak8975: Add another ACPI ID (diff)
downloadlinux-dev-71e083aaf716fffa91cf80e85e88f3c0674be81a.tar.xz
linux-dev-71e083aaf716fffa91cf80e85e88f3c0674be81a.zip
staging: iio: ad7152: Improve unlocking of a mutex in ad7152_start_calib()
* Add a jump target so that a call of the function "mutex_unlock" is stored only twice in this function implementation. * Replace two calls by goto statements. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/staging/iio')
-rw-r--r--drivers/staging/iio/cdc/ad7152.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/staging/iio/cdc/ad7152.c b/drivers/staging/iio/cdc/ad7152.c
index 61377ca444de..59d1b35f6a4e 100644
--- a/drivers/staging/iio/cdc/ad7152.c
+++ b/drivers/staging/iio/cdc/ad7152.c
@@ -118,22 +118,23 @@ static inline ssize_t ad7152_start_calib(struct device *dev,
mutex_lock(&chip->state_lock);
ret = i2c_smbus_write_byte_data(chip->client, AD7152_REG_CFG, regval);
- if (ret < 0) {
- mutex_unlock(&chip->state_lock);
- return ret;
- }
+ if (ret < 0)
+ goto unlock;
do {
mdelay(20);
ret = i2c_smbus_read_byte_data(chip->client, AD7152_REG_CFG);
- if (ret < 0) {
- mutex_unlock(&chip->state_lock);
- return ret;
- }
+ if (ret < 0)
+ goto unlock;
+
} while ((ret == regval) && timeout--);
mutex_unlock(&chip->state_lock);
return len;
+
+unlock:
+ mutex_unlock(&chip->state_lock);
+ return ret;
}
static ssize_t ad7152_start_offset_calib(struct device *dev,