diff options
author | Alexandru Ardelean <alexandru.ardelean@analog.com> | 2019-11-22 16:24:20 +0300 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2019-11-23 15:17:35 +0300 |
commit | d693845da31c4d1093a8165d1ac4a73eac0f9373 (patch) | |
tree | eea721e27510058e4f8e5863301deb254a36b337 /drivers/iio/imu/adis16480.c | |
parent | 0aee99a1ea53de1aedcf96a4d52d6161ffba011a (diff) | |
download | linux-d693845da31c4d1093a8165d1ac4a73eac0f9373.tar.xz |
iio: imu: adis16480: use state lock for filter freq set
It's the only operation that does 2 operations (a read & a write), so the
unlocked functions can be used under a single state lock.
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/imu/adis16480.c')
-rw-r--r-- | drivers/iio/imu/adis16480.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c index e943039c3f98..f73094e8d35d 100644 --- a/drivers/iio/imu/adis16480.c +++ b/drivers/iio/imu/adis16480.c @@ -555,6 +555,7 @@ static int adis16480_set_filter_freq(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, unsigned int freq) { struct adis16480 *st = iio_priv(indio_dev); + struct mutex *slock = &st->adis.state_lock; unsigned int enable_mask, offset, reg; unsigned int diff, best_diff; unsigned int i, best_freq; @@ -565,9 +566,11 @@ static int adis16480_set_filter_freq(struct iio_dev *indio_dev, offset = ad16480_filter_data[chan->scan_index][1]; enable_mask = BIT(offset + 2); - ret = adis_read_reg_16(&st->adis, reg, &val); + mutex_lock(slock); + + ret = __adis_read_reg_16(&st->adis, reg, &val); if (ret) - return ret; + goto out_unlock; if (freq == 0) { val &= ~enable_mask; @@ -589,7 +592,11 @@ static int adis16480_set_filter_freq(struct iio_dev *indio_dev, val |= enable_mask; } - return adis_write_reg_16(&st->adis, reg, val); + ret = __adis_write_reg_16(&st->adis, reg, val); +out_unlock: + mutex_unlock(slock); + + return ret; } static int adis16480_read_raw(struct iio_dev *indio_dev, |