[PATCH v2] iio: afe: rescale: always expose offset
From: Andrea Amer via B4 Relay
Date: Fri Oct 16 2026 - 07:07:18 EST
From: Andrea Amer <and.amer@xxxxxxxxx>
A rescale channel advertises IIO_CHAN_INFO_OFFSET only when its own
offset is non-zero. A child rescale therefore hides a source offset,
and consumers apply raw * scale and drop it. rescale_read_raw() already
folds the source offset in, so expose the attribute in every case.
Fixes: a29c3283653b ("iio: afe: rescale: add offset support")
Signed-off-by: Andrea Amer <and.amer@xxxxxxxxx>
---
Changes in v2:
- Keep the IIO_CHAN_INFO_SCALE line unchanged (Andy Shevchenko)
- Link to v1: https://lore.kernel.org/r/20261012-iio-rescale-offset-v1-1-14ed15979ff2@xxxxxxxxx
---
drivers/iio/afe/iio-rescale.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/iio/afe/iio-rescale.c b/drivers/iio/afe/iio-rescale.c
index 3a6a09ffa5267ddfd5131fbd04a5df928836589d..4639a67ea462bf5c29603783a6f230d769fb02b0 100644
--- a/drivers/iio/afe/iio-rescale.c
+++ b/drivers/iio/afe/iio-rescale.c
@@ -301,11 +301,9 @@ static int rescale_configure_channel(struct device *dev,
}
chan->info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_OFFSET) |
BIT(IIO_CHAN_INFO_SCALE);
- if (rescale->offset)
- chan->info_mask_separate |= BIT(IIO_CHAN_INFO_OFFSET);
-
/*
* Using .read_avail() is fringe to begin with and makes no sense
* whatsoever for processed channels, so we make sure that this cannot
---
base-commit: a3b3580713f3ac5a32dc2874ee546828977a1d68
change-id: 20261012-iio-rescale-offset-41254a33b6d6
Best regards,
--
Andrea Amer <and.amer@xxxxxxxxx>