[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211021140018.3051213-1-roan@protonic.nl>
Date: Thu, 21 Oct 2021 16:00:18 +0200
From: Roan van Dijk <roan@...tonic.nl>
To: Jonathan Cameron <jic23@...nel.org>
Cc: linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
david@...tonic.nl, Lars-Peter Clausen <lars@...afoo.de>,
Roan van Dijk <roan@...tonic.nl>
Subject: [PATCH] iio: chemical: scd4x: Add a scale for the co2 concentration reading
This patch adds a scale for the co2 concentration reading. The reading is
expressed in percent after applying the scale to the raw value.
Signed-off-by: Roan van Dijk <roan@...tonic.nl>
---
drivers/iio/chemical/scd4x.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/chemical/scd4x.c b/drivers/iio/chemical/scd4x.c
index 09b34201c42b..b063b378c7d5 100644
--- a/drivers/iio/chemical/scd4x.c
+++ b/drivers/iio/chemical/scd4x.c
@@ -352,7 +352,11 @@ static int scd4x_read_raw(struct iio_dev *indio_dev,
*val = ret;
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
- if (chan->type == IIO_TEMP) {
+ if (chan->type == IIO_CONCENTRATION) {
+ *val = 0;
+ *val2 = 100;
+ return IIO_VAL_INT_PLUS_MICRO;
+ } else if (chan->type == IIO_TEMP) {
*val = 175000;
*val2 = 65536;
return IIO_VAL_FRACTIONAL;
@@ -501,7 +505,8 @@ static const struct iio_chan_spec scd4x_channels[] = {
.type = IIO_CONCENTRATION,
.channel2 = IIO_MOD_CO2,
.modified = 1,
- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_SCALE),
.address = SCD4X_CO2,
.scan_index = SCD4X_CO2,
.scan_type = {
--
2.30.2
Powered by blists - more mailing lists