Commit f26cc90a authored by Jorge Harrisonn's avatar Jorge Harrisonn Committed by Jonathan Cameron

iio: adc: ad7606: using claim_direct_scoped for code simplification

Using iio_device_claim_direct_scoped instead of calling `iio_device
_claim_direct_modeand later callingiio_device_release_direct_mode`

This should make code cleaner and error handling easier
Co-authored-by: default avatarLais Nuto <laisnuto@usp.br>
Signed-off-by: default avatarLais Nuto <laisnuto@usp.br>
Signed-off-by: default avatarJorge Harrisonn <jorge.harrisonn@usp.br>
Link: https://lore.kernel.org/r/20240501215724.26655-2-jorge.harrisonn@usp.brSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 1613e604
...@@ -174,17 +174,14 @@ static int ad7606_read_raw(struct iio_dev *indio_dev, ...@@ -174,17 +174,14 @@ static int ad7606_read_raw(struct iio_dev *indio_dev,
switch (m) { switch (m) {
case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_RAW:
ret = iio_device_claim_direct_mode(indio_dev); iio_device_claim_direct_scoped(return -EBUSY, indio_dev) {
if (ret) ret = ad7606_scan_direct(indio_dev, chan->address);
return ret; if (ret < 0)
return ret;
ret = ad7606_scan_direct(indio_dev, chan->address); *val = (short) ret;
iio_device_release_direct_mode(indio_dev); return IIO_VAL_INT;
}
if (ret < 0) unreachable();
return ret;
*val = (short)ret;
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
if (st->sw_mode_en) if (st->sw_mode_en)
ch = chan->address; ch = chan->address;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment