Commit 4d9b0413 authored by Alison Schofield's avatar Alison Schofield Committed by Jonathan Cameron

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: default avatarAlison Schofield <amsfield22@gmail.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 4e2cf0e2
...@@ -459,12 +459,14 @@ static int mma8452_read_raw(struct iio_dev *indio_dev, ...@@ -459,12 +459,14 @@ static int mma8452_read_raw(struct iio_dev *indio_dev,
switch (mask) { switch (mask) {
case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_RAW:
if (iio_buffer_enabled(indio_dev)) ret = iio_device_claim_direct_mode(indio_dev);
return -EBUSY; if (ret)
return ret;
mutex_lock(&data->lock); mutex_lock(&data->lock);
ret = mma8452_read(data, buffer); ret = mma8452_read(data, buffer);
mutex_unlock(&data->lock); mutex_unlock(&data->lock);
iio_device_release_direct_mode(indio_dev);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment