From: Hans de Goede Date: Sun, 31 Aug 2025 10:48:21 +0000 (+0200) Subject: iio: consumers: Fix offset handling in iio_convert_raw_to_processed() X-Git-Tag: v6.18-rc1~74^2~7^2~42 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=33f5c69c4daff39c010b3ea6da8ebab285f4277b;p=thirdparty%2Fkernel%2Fstable.git iio: consumers: Fix offset handling in iio_convert_raw_to_processed() Fix iio_convert_raw_to_processed() offset handling for channels without a scale attribute. The offset has been applied to the raw64 value not to the original raw value. Use the raw64 value so that the offset is taken into account. Fixes: 14b457fdde38 ("iio: inkern: apply consumer scale when no channel scale is available") Cc: Liam Beguin Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Link: https://patch.msgid.link/20250831104825.15097-3-hansg@kernel.org Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index d36a80a7b8a93..642beb4b3360d 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -640,7 +640,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan, * If no channel scaling is available apply consumer scale to * raw value and return. */ - *processed = raw * scale; + *processed = raw64 * scale; return 0; }