]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
iio: proximity: sx9500: claim direct mode during raw proximity reads
authorAlison Schofield <amsfield22@gmail.com>
Fri, 20 Jan 2017 22:11:30 +0000 (14:11 -0800)
committerJonathan Cameron <jic23@kernel.org>
Sat, 21 Jan 2017 12:21:53 +0000 (12:21 +0000)
Driver was checking for direct mode but not locking it.  Use the
claim/release helper functions to guarantee the device stays in
direct mode during raw reads of proximity data.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Reviewed-by: Vlad Dogaru <ddvlad@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/proximity/sx9500.c

index 1f06282ec793a07f66f7f34c187c302f5872577d..9ea147f1a50d10ee13412d41bac823f605bfc1b2 100644 (file)
@@ -387,14 +387,18 @@ static int sx9500_read_raw(struct iio_dev *indio_dev,
                           int *val, int *val2, long mask)
 {
        struct sx9500_data *data = iio_priv(indio_dev);
+       int ret;
 
        switch (chan->type) {
        case IIO_PROXIMITY:
                switch (mask) {
                case IIO_CHAN_INFO_RAW:
-                       if (iio_buffer_enabled(indio_dev))
-                               return -EBUSY;
-                       return sx9500_read_proximity(data, chan, val);
+                       ret = iio_device_claim_direct_mode(indio_dev);
+                       if (ret)
+                               return ret;
+                       ret = sx9500_read_proximity(data, chan, val);
+                       iio_device_release_direct_mode(indio_dev);
+                       return ret;
                case IIO_CHAN_INFO_SAMP_FREQ:
                        return sx9500_read_samp_freq(data, val, val2);
                default: