diff options
author | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2013-07-01 20:40:00 +0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-07-03 23:30:52 +0400 |
commit | f91d1b63a4e096d3023aaaafec9d9d3aff25997f (patch) | |
tree | 03339141691dfb4a10a99c992f6484eb46772692 /drivers/iio | |
parent | 1c297a66654a3295ae87e2b7f3724d214eb2b5ec (diff) | |
download | linux-f91d1b63a4e096d3023aaaafec9d9d3aff25997f.tar.xz |
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>
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, int ret; ret = iio_channel_read(chan, &offset, NULL, IIO_CHAN_INFO_OFFSET); - if (ret == 0) + if (ret >= 0) raw64 += offset; scale_type = iio_channel_read(chan, &scale_val, &scale_val2, |