iio: imu: adis: group single conversion under a single state lock
authorAlexandru Ardelean <alexandru.ardelean@analog.com>
Fri, 22 Nov 2019 13:24:17 +0000 (15:24 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 23 Nov 2019 12:13:35 +0000 (12:13 +0000)
The single conversion function does a series of reads + writes. This change
extends the use of the state_lock for the entire set of operations.
Previously, indio_dev's mlock was used. This change also removes the use of
this lock.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/imu/adis.c

index 10b8922fd51b61315f77443d14a0bdfd4b27fdff..c53f3ed3cb9724129a96d7e287d3137201d222b4 100644 (file)
@@ -404,15 +404,15 @@ int adis_single_conversion(struct iio_dev *indio_dev,
        unsigned int uval;
        int ret;
 
-       mutex_lock(&indio_dev->mlock);
+       mutex_lock(&adis->state_lock);
 
-       ret = adis_read_reg(adis, chan->address, &uval,
+       ret = __adis_read_reg(adis, chan->address, &uval,
                        chan->scan_type.storagebits / 8);
        if (ret)
                goto err_unlock;
 
        if (uval & error_mask) {
-               ret = adis_check_status(adis);
+               ret = __adis_check_status(adis);
                if (ret)
                        goto err_unlock;
        }
@@ -424,7 +424,7 @@ int adis_single_conversion(struct iio_dev *indio_dev,
 
        ret = IIO_VAL_INT;
 err_unlock:
-       mutex_unlock(&indio_dev->mlock);
+       mutex_unlock(&adis->state_lock);
        return ret;
 }
 EXPORT_SYMBOL_GPL(adis_single_conversion);