iio: accel: bma180: use iio helper function to guarantee direct mode
authorAlison Schofield <amsfield22@gmail.com>
Mon, 25 Jul 2016 19:11:20 +0000 (12:11 -0700)
committerJonathan Cameron <jic23@kernel.org>
Mon, 15 Aug 2016 16:12:43 +0000 (17:12 +0100)
Replace the code that guarantees the device stays in direct mode
with iio_device_claim_direct_mode() which does same.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Cc: Daniel Baluta <daniel.baluta@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/accel/bma180.c

index e3f88ba5faf33ff4b7179fb96f603d20875f77a6..0890934ef66f66bca02521ffe71192591afe3aa5 100644 (file)
@@ -469,13 +469,14 @@ static int bma180_read_raw(struct iio_dev *indio_dev,
 
        switch (mask) {
        case IIO_CHAN_INFO_RAW:
+               ret = iio_device_claim_direct_mode(indio_dev);
+               if (ret)
+                       return ret;
+
                mutex_lock(&data->mutex);
-               if (iio_buffer_enabled(indio_dev)) {
-                       mutex_unlock(&data->mutex);
-                       return -EBUSY;
-               }
                ret = bma180_get_data_reg(data, chan->scan_index);
                mutex_unlock(&data->mutex);
+               iio_device_release_direct_mode(indio_dev);
                if (ret < 0)
                        return ret;
                *val = sign_extend32(ret >> chan->scan_type.shift,
This page took 0.025972 seconds and 5 git commands to generate.