Skip to content

Commit b4d4640

Browse files
AlisonSchofieldjic23
authored andcommitted
iio: adc: ad7793: 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 4d19c48 commit b4d4640

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

drivers/iio/adc/ad7793.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -519,11 +519,9 @@ static int ad7793_write_raw(struct iio_dev *indio_dev,
519519
int ret, i;
520520
unsigned int tmp;
521521

522-
mutex_lock(&indio_dev->mlock);
523-
if (iio_buffer_enabled(indio_dev)) {
524-
mutex_unlock(&indio_dev->mlock);
525-
return -EBUSY;
526-
}
522+
ret = iio_device_claim_direct_mode(indio_dev);
523+
if (ret)
524+
return ret;
527525

528526
switch (mask) {
529527
case IIO_CHAN_INFO_SCALE:
@@ -548,7 +546,7 @@ static int ad7793_write_raw(struct iio_dev *indio_dev,
548546
ret = -EINVAL;
549547
}
550548

551-
mutex_unlock(&indio_dev->mlock);
549+
iio_device_release_direct_mode(indio_dev);
552550
return ret;
553551
}
554552

0 commit comments

Comments
 (0)