mirror of
https://github.com/torvalds/linux.git
synced 2024-12-25 20:32:22 +00:00
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>
This commit is contained in:
parent
9ed2484598
commit
71e083aaf7
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user