From: Alexandre Belloni Date: Mon, 1 Jul 2013 16:40:00 +0000 (+0100) Subject: iio: inkern: fix iio_convert_raw_to_processed_unlocked X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=79d295ce5b9c322ebb40b2d7fdb9da4eee83f893;p=karo-tx-linux.git 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 Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- 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,