summaryrefslogtreecommitdiffstats
path: root/drivers/iio/adc/ti-adc161s626.c
diff options
context:
space:
mode:
authorGustavo Ueti Fukunaga <gustavofukunaga@usp.br>2024-05-27 11:19:40 +0200
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2024-06-13 20:19:22 +0200
commit1b88a895b931eaa64b500598abc8fac464aa0b5b (patch)
tree511d0d7d86f30523657f5b75b4216b3db2546426 /drivers/iio/adc/ti-adc161s626.c
parentiio: accel: mma7660: add mount-matrix support (diff)
downloadlinux-1b88a895b931eaa64b500598abc8fac464aa0b5b.tar.xz
linux-1b88a895b931eaa64b500598abc8fac464aa0b5b.zip
iio: adc: ti-adc161s626: make use of iio_device_claim_direct_scoped()
Make use of iio_device_claim_direct_scoped() to make error handling more natural and simplify code. Co-developed-by: Caio Dantas Simão Ugêda <caiodantas@usp.br> Signed-off-by: Caio Dantas Simão Ugêda <caiodantas@usp.br> Signed-off-by: Gustavo Ueti Fukunaga <gustavofukunaga@usp.br> Link: https://lore.kernel.org/r/20240527091942.53616-1-gustavofukunaga@usp.br Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/adc/ti-adc161s626.c')
-rw-r--r--drivers/iio/adc/ti-adc161s626.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/drivers/iio/adc/ti-adc161s626.c b/drivers/iio/adc/ti-adc161s626.c
index b789891dcf49..f7c78d0dd449 100644
--- a/drivers/iio/adc/ti-adc161s626.c
+++ b/drivers/iio/adc/ti-adc161s626.c
@@ -137,17 +137,13 @@ static int ti_adc_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;
-
- ret = ti_adc_read_measurement(data, chan, val);
- iio_device_release_direct_mode(indio_dev);
-
- if (ret)
- return ret;
-
- return IIO_VAL_INT;
+ iio_device_claim_direct_scoped(return -EBUSY, indio_dev) {
+ ret = ti_adc_read_measurement(data, chan, val);
+ if (ret)
+ return ret;
+ return IIO_VAL_INT;
+ }
+ unreachable();
case IIO_CHAN_INFO_SCALE:
ret = regulator_get_voltage(data->ref);
if (ret < 0)