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

iio: inkern: fix iio_convert_raw_to_processed_unlocked

When reading IIO_CHAN_INFO_OFFSET, the return value of iio_channel_read() for
success will be IIO_VAL*, checking for 0 is not correct.

Without this fix the offset applied by iio drivers will be ignored when
converting a raw value to one in appropriate base units (e.g mV) in
a IIO client drivers that use iio_convert_raw_to_processed including
iio-hwmon.

Cc: <stable@vger.kernel.org> # 3.10.x
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Alexandre Belloni and committed by
Jonathan Cameron
f91d1b63 1c297a66

+1 -1
+1 -1
drivers/iio/inkern.c
··· 451 451 int ret; 452 452 453 453 ret = iio_channel_read(chan, &offset, NULL, IIO_CHAN_INFO_OFFSET); 454 - if (ret == 0) 454 + if (ret >= 0) 455 455 raw64 += offset; 456 456 457 457 scale_type = iio_channel_read(chan, &scale_val, &scale_val2,