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>
This commit is contained in:
parent
f4bed1ceb8
commit
1b88a895b9
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user