Skip to content

Commit

Permalink
iio: inkern: fix iio_convert_raw_to_processed_unlocked
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alexandre Belloni authored and Jonathan Cameron committed Jul 3, 2013
1 parent 1c297a6 commit f91d1b6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/iio/inkern.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f91d1b6

Please sign in to comment.