Skip to content

Commit

Permalink
iio: addac: ad74413: fix resistance input processing
Browse files Browse the repository at this point in the history
commit 24febc9 upstream.

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.

Fixes: fea251b (iio: addac: add AD74413R driver)
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20230503095817.452551-1-linux@rasmusvillemoes.dk
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Villemoes authored and gregkh committed Jun 9, 2023
1 parent ab0c2df commit 84f4d63
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/iio/addac/ad74413r.c
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,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);
Expand Down

0 comments on commit 84f4d63

Please sign in to comment.