summaryrefslogtreecommitdiffstats
path: root/drivers/iio/proximity
diff options
context:
space:
mode:
authorMatt Ranostay <mranostay@gmail.com>2016-06-07 21:18:04 -0700
committerJonathan Cameron <jic23@kernel.org>2016-06-11 17:08:20 +0100
commit9e18265443d3a76462eafc3a0863c217aeaf62ac (patch)
tree460b7dab034a905f524d0e96d8b81c49f6aff258 /drivers/iio/proximity
parentbc2e1126eccb47517b9d1c685020c38600f99a3d (diff)
downloadlinux-9e18265443d3a76462eafc3a0863c217aeaf62ac.tar.bz2
iio: proximity: lidar: switch to iio_device_claim_*_mode helpers
Switch from using indio_dev->mlock to the iio_device_claim_*_mode helper functions. Signed-off-by: Matt Ranostay <mranostay@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/proximity')
-rw-r--r--drivers/iio/proximity/pulsedlight-lidar-lite-v2.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
index 4f502386aa86..c0b0e82abf94 100644
--- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
+++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
@@ -203,22 +203,19 @@ static int lidar_read_raw(struct iio_dev *indio_dev,
struct lidar_data *data = iio_priv(indio_dev);
int ret = -EINVAL;
- mutex_lock(&indio_dev->mlock);
-
- if (iio_buffer_enabled(indio_dev) && mask == IIO_CHAN_INFO_RAW) {
- ret = -EBUSY;
- goto error_busy;
- }
-
switch (mask) {
case IIO_CHAN_INFO_RAW: {
u16 reg;
+ if (iio_device_claim_direct_mode(indio_dev))
+ return -EBUSY;
+
ret = lidar_get_measurement(data, &reg);
if (!ret) {
*val = reg;
ret = IIO_VAL_INT;
}
+ iio_device_release_direct_mode(indio_dev);
break;
}
case IIO_CHAN_INFO_SCALE:
@@ -228,9 +225,6 @@ static int lidar_read_raw(struct iio_dev *indio_dev,
break;
}
-error_busy:
- mutex_unlock(&indio_dev->mlock);
-
return ret;
}