]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: consumers: Fix offset handling in iio_convert_raw_to_processed()
authorHans de Goede <hansg@kernel.org>
Sun, 31 Aug 2025 10:48:21 +0000 (12:48 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 10 Sep 2025 18:47:04 +0000 (19:47 +0100)
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 <liambeguin@gmail.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Hans de Goede <hansg@kernel.org>
Link: https://patch.msgid.link/20250831104825.15097-3-hansg@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/inkern.c

index d36a80a7b8a93089a30e078e45aea233c1fa1f40..642beb4b3360d20a4ded1b232cde87f7ccc8b380 100644 (file)
@@ -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;
        }