From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> Date: Wed, 25 Oct 2017 22:00:42 +0200 Adjust jump targets so that a call of the function "mutex_unlock" is stored only once in a case branch of this function implementation. Replace two calls by goto statements. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> --- drivers/iio/accel/stk8ba50.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/iio/accel/stk8ba50.c b/drivers/iio/accel/stk8ba50.c index afe90567ad37..ffc26b5d1fad 100644 --- a/drivers/iio/accel/stk8ba50.c +++ b/drivers/iio/accel/stk8ba50.c @@ -221,20 +221,24 @@ static int stk8ba50_read_raw(struct iio_dev *indio_dev, return -EBUSY; mutex_lock(&data->lock); ret = stk8ba50_set_power(data, STK8BA50_MODE_NORMAL); - if (ret < 0) { - mutex_unlock(&data->lock); - return -EINVAL; - } + if (ret < 0) + goto e_inval; + ret = stk8ba50_read_accel(data, chan->address); if (ret < 0) { stk8ba50_set_power(data, STK8BA50_MODE_SUSPEND); - mutex_unlock(&data->lock); - return -EINVAL; +e_inval: + ret = -EINVAL; + goto unlock; } *val = sign_extend32(ret >> STK8BA50_DATA_SHIFT, 9); - stk8ba50_set_power(data, STK8BA50_MODE_SUSPEND); + ret = stk8ba50_set_power(data, STK8BA50_MODE_SUSPEND); +unlock: mutex_unlock(&data->lock); - return IIO_VAL_INT; + if (ret >= 0) + ret = IIO_VAL_INT; + + return ret; case IIO_CHAN_INFO_SCALE: *val = 0; *val2 = stk8ba50_scale_table[data->range].scale_val; -- 2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html