Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Gustavo Ueti Fukunaga and committed by
Jonathan Cameron
1b88a895 f4bed1ce

+7 -11
+7 -11
drivers/iio/adc/ti-adc161s626.c
··· 137 137 138 138 switch (mask) { 139 139 case IIO_CHAN_INFO_RAW: 140 - ret = iio_device_claim_direct_mode(indio_dev); 141 - if (ret) 142 - return ret; 143 - 144 - ret = ti_adc_read_measurement(data, chan, val); 145 - iio_device_release_direct_mode(indio_dev); 146 - 147 - if (ret) 148 - return ret; 149 - 150 - return IIO_VAL_INT; 140 + iio_device_claim_direct_scoped(return -EBUSY, indio_dev) { 141 + ret = ti_adc_read_measurement(data, chan, val); 142 + if (ret) 143 + return ret; 144 + return IIO_VAL_INT; 145 + } 146 + unreachable(); 151 147 case IIO_CHAN_INFO_SCALE: 152 148 ret = regulator_get_voltage(data->ref); 153 149 if (ret < 0)