Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1499172 > unrolled thread

[PATCH] iio: accel: mma8452: claim direct mode during raw reads

Started byAlison Schofield <amsfield22@gmail.com>
First post2016-10-11 21:50 +0200
Last post2016-10-11 21:50 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] iio: accel: mma8452: claim direct mode during raw reads Alison Schofield <amsfield22@gmail.com> - 2016-10-11 21:50 +0200

#1499172 — [PATCH] iio: accel: mma8452: claim direct mode during raw reads

FromAlison Schofield <amsfield22@gmail.com>
Date2016-10-11 21:50 +0200
Subject[PATCH] iio: accel: mma8452: claim direct mode during raw reads
Message-ID<srbdM-2oc-17@gated-at.bofh.it>
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>
---
 drivers/iio/accel/mma8452.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index 6e82e02..cbbc746 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;
 
-- 
2.1.4

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web