iio: addac: ad74413: fix resistance input processing
Subsystems (3)
PATCH 1/1 iio: addac: ad74413: fix resistance input processing
On success, ad74413r_get_single_adc_result() returns IIO_VAL_INT aka
1. So currently, the IIO_CHAN_INFO_PROCESSED case is effectively equivalent to the IIO_CHAN_INFO_RAW case, and we never call ad74413r_adc_to_resistance_result() to convert the adc measurement to ohms.
Check ret for being negative rather than non-zero.
--- drivers/iio/addac/ad74413r.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/addac/ad74413r.c +1 -1
@@ -1007,7 +1007,7 @@ static int ad74413r_read_raw(struct iio_dev *indio_dev, ret =ad74413r_get_single_adc_result (indio_dev, chan->channel, val); -if (ret) +if (ret <0 )return ret;ad74413r_adc_to_resistance_result (*val, val);
Signature · 1 line
2.37.2
Quoted 11 lines · Rasmus Villemoes
On success,
ad74413r_get_single_adc_result()returnsIIO_VAL_INTaka
1. So currently, theIIO_CHAN_INFO_PROCESSEDcase is effectively equivalent to theIIO_CHAN_INFO_RAWcase, and we never callad74413r_adc_to_resistance_result()to convert the adc measurement to ohms.Check ret for being negative rather than non-zero.
Fixes fea251b6a5dbd (iio: addac: add AD74413R driver)Signed-off-by Rasmus Villemoes <[email protected]>---
Quoted 16 lines
drivers/iio/addac/ad74413r.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/addac/ad74413r.c +0
-0@@ -1007,7 +1007,7 @@ static int ad74413r_read_raw(struct iio_dev *indio_dev,
ret =ad74413r_get_single_adc_result(indio_dev, chan->channel, val);
- if (ret)
+ if (ret < 0)
return ret;
ad74413r_adc_to_resistance_result(*val, val);