Commit 1b88a895 authored by Gustavo Ueti Fukunaga's avatar Gustavo Ueti Fukunaga Committed by Jonathan Cameron

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: default avatarCaio Dantas Simão Ugêda <caiodantas@usp.br>
Signed-off-by: default avatarCaio Dantas Simão Ugêda <caiodantas@usp.br>
Signed-off-by: default avatarGustavo Ueti Fukunaga <gustavofukunaga@usp.br>
Link: https://lore.kernel.org/r/20240527091942.53616-1-gustavofukunaga@usp.brSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent f4bed1ce
......@@ -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)
......
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