Thread (21 messages) 21 messages, 4 authors, 2021-06-11
STALE1819d
Revisions (15)
  1. v1 [diff vs current]
  2. v2 current
  3. v3 [diff vs current]
  4. v4 [diff vs current]
  5. v5 [diff vs current]
  6. v6 [diff vs current]
  7. v7 [diff vs current]
  8. v8 [diff vs current]
  9. v9 [diff vs current]
  10. v10 [diff vs current]
  11. v11 [diff vs current]
  12. v12 [diff vs current]
  13. v13 [diff vs current]
  14. v14 [diff vs current]
  15. v15 [diff vs current]

[PATCH v2 5/8] iio: afe: rescale: add upstream offset support

From: Liam Beguin <hidden>
Date: 2021-06-07 14:48:37
Also in: linux-iio, lkml
Subsystem: iio subsystem and drivers, iio unit converter, the rest · Maintainers: Jonathan Cameron, Peter Rosin, Linus Torvalds

From: Liam Beguin <redacted>

Default to using iio_read_channel_processed() if the upstream channel
exposes an offset.

When possible, it's preferable to avoid using
iio_read_channel_processed() to maintain as much precision as possible.

Signed-off-by: Liam Beguin <redacted>
---
 drivers/iio/afe/iio-rescale.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/afe/iio-rescale.c b/drivers/iio/afe/iio-rescale.c
index 774eb3044edd..e34148d39b39 100644
--- a/drivers/iio/afe/iio-rescale.c
+++ b/drivers/iio/afe/iio-rescale.c
@@ -148,7 +148,10 @@ static int rescale_configure_channel(struct device *dev,
 	chan->ext_info = rescale->ext_info;
 	chan->type = rescale->cfg->type;
 
-	if (iio_channel_has_info(schan, IIO_CHAN_INFO_RAW) ||
+	if (iio_channel_has_info(schan, IIO_CHAN_INFO_OFFSET)) {
+		dev_info(dev, "found upstream offset, using processed value\n");
+		rescale->chan_processed = true;
+	} else if (iio_channel_has_info(schan, IIO_CHAN_INFO_RAW) ||
 	    iio_channel_has_info(schan, IIO_CHAN_INFO_SCALE)) {
 		dev_info(dev, "using raw+scale source channel\n");
 	} else if (iio_channel_has_info(schan, IIO_CHAN_INFO_PROCESSED)) {
-- 
2.30.1.489.g328c10930387
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help