Skip to content

Commit d02ec00

Browse files
AlisonSchofieldjic23
authored andcommitted
iio: adc: ad7298: use iio helper function to guarantee direct mode
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 <[email protected]> Cc: Daniel Baluta <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent b4d4640 commit d02ec00

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/iio/adc/ad7298.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -239,16 +239,16 @@ static int ad7298_read_raw(struct iio_dev *indio_dev,
239239

240240
switch (m) {
241241
case IIO_CHAN_INFO_RAW:
242-
mutex_lock(&indio_dev->mlock);
243-
if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) {
244-
ret = -EBUSY;
245-
} else {
246-
if (chan->address == AD7298_CH_TEMP)
247-
ret = ad7298_scan_temp(st, val);
248-
else
249-
ret = ad7298_scan_direct(st, chan->address);
250-
}
251-
mutex_unlock(&indio_dev->mlock);
242+
ret = iio_device_claim_direct_mode(indio_dev);
243+
if (ret)
244+
return ret;
245+
246+
if (chan->address == AD7298_CH_TEMP)
247+
ret = ad7298_scan_temp(st, val);
248+
else
249+
ret = ad7298_scan_direct(st, chan->address);
250+
251+
iio_device_release_direct_mode(indio_dev);
252252

253253
if (ret < 0)
254254
return ret;

0 commit comments

Comments
 (0)