summaryrefslogtreecommitdiff
path: root/drivers/iio
diff options
context:
space:
mode:
authorRoan van Dijk <roan@protonic.nl>2021-10-21 16:00:18 +0200
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2021-10-21 20:53:11 +0100
commite46e2512ac84bd914212dc4b639d596db543f5b1 (patch)
tree6ce37605305834f9820fc7ae931cc8bfa41a14d3 /drivers/iio
parent392998a8032a59bff4ec14dc9d5098c60b50baf9 (diff)
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@protonic.nl> Link: https://lore.kernel.org/r/20211021140018.3051213-1-roan@protonic.nl Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/chemical/scd4x.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/iio/chemical/scd4x.c b/drivers/iio/chemical/scd4x.c
index ebebcb117ba2..267bc3c05338 100644
--- a/drivers/iio/chemical/scd4x.c
+++ b/drivers/iio/chemical/scd4x.c
@@ -353,7 +353,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;
@@ -503,7 +507,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 = {