diff options
author | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2013-07-01 12:40:00 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-25 17:07:23 -0400 |
commit | 79d295ce5b9c322ebb40b2d7fdb9da4eee83f893 (patch) | |
tree | 4188b88fe99dc21c6d61ca73484cc7f5d21860b5 /drivers/iio | |
parent | 8b68eefae0dbd8cdddb54af08c2b424f6da6f6ba (diff) |
iio: inkern: fix iio_convert_raw_to_processed_unlocked
commit f91d1b63a4e096d3023aaaafec9d9d3aff25997f upstream.
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.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/inkern.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 98ddc323add0..0cf5f8e06cfc 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c | |||
@@ -451,7 +451,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan, | |||
451 | int ret; | 451 | int ret; |
452 | 452 | ||
453 | ret = iio_channel_read(chan, &offset, NULL, IIO_CHAN_INFO_OFFSET); | 453 | ret = iio_channel_read(chan, &offset, NULL, IIO_CHAN_INFO_OFFSET); |
454 | if (ret == 0) | 454 | if (ret >= 0) |
455 | raw64 += offset; | 455 | raw64 += offset; |
456 | 456 | ||
457 | scale_type = iio_channel_read(chan, &scale_val, &scale_val2, | 457 | scale_type = iio_channel_read(chan, &scale_val, &scale_val2, |