aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorAlison Schofield <amsfield22@gmail.com>2016-10-11 12:31:36 -0700
committerJonathan Cameron <jic23@kernel.org>2016-10-23 19:33:54 +0100
commit4d9b0413e29d61e6382b613f4835118504e65e86 (patch)
treee64ed3723527072620ce95bffed098d8a49b7ce1 /drivers/iio
parenttools: iio: iio_generic_buffer: add -A to force-enable all channels (diff)
downloadlinux-dev-4d9b0413e29d61e6382b613f4835118504e65e86.tar.xz
linux-dev-4d9b0413e29d61e6382b613f4835118504e65e86.zip
iio: accel: mma8452: claim direct mode during raw reads
Driver was checking for direct mode but not locking it. Use claim/release helper functions to guarantee the device stays in direct mode during raw reads. Signed-off-by: Alison Schofield <amsfield22@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/accel/mma8452.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index 1c7051581513..7951def89d63 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -459,12 +459,14 @@ static int mma8452_read_raw(struct iio_dev *indio_dev,
switch (mask) {
case IIO_CHAN_INFO_RAW:
- if (iio_buffer_enabled(indio_dev))
- return -EBUSY;
+ ret = iio_device_claim_direct_mode(indio_dev);
+ if (ret)
+ return ret;
mutex_lock(&data->lock);
ret = mma8452_read(data, buffer);
mutex_unlock(&data->lock);
+ iio_device_release_direct_mode(indio_dev);
if (ret < 0)
return ret;