Skip to content

Commit f91d1b6

Browse files
alexandrebellonijic23
authored andcommitted
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: <[email protected]> # 3.10.x Signed-off-by: Alexandre Belloni <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 1c297a6 commit f91d1b6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/iio/inkern.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
451451
int ret;
452452

453453
ret = iio_channel_read(chan, &offset, NULL, IIO_CHAN_INFO_OFFSET);
454-
if (ret == 0)
454+
if (ret >= 0)
455455
raw64 += offset;
456456

457457
scale_type = iio_channel_read(chan, &scale_val, &scale_val2,

0 commit comments

Comments
 (0)