Skip to content

Commit 0db5de4

Browse files
narcisaamgregkh
authored andcommitted
iio: chemical: ccs811: Fix output of IIO_CONCENTRATION channels
commit 8f114ac upstream. in_concentration_raw should report, according to sysfs-bus-iio documentation, a "Raw (unscaled no offset etc.) percentage reading of a substance." Modify scale to convert from ppm/ppb to percentage: 1 ppm = 0.0001% 1 ppb = 0.0000001% There is no offset needed to convert the ppm/ppb to percentage, so remove offset from IIO_CONCENTRATION (IIO_MOD_CO2) channel. Cc'd stable to reduce chance of userspace breakage in the long run as we fix this wrong bit of ABI usage. Signed-off-by: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com> Reviewed-by: Matt Ranostay <matt.ranostay@konsulko.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e2d4cdb commit 0db5de4

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

‎drivers/iio/chemical/ccs811.c‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ static const struct iio_chan_spec ccs811_channels[] = {
9191
.channel2 = IIO_MOD_CO2,
9292
.modified = 1,
9393
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
94-
BIT(IIO_CHAN_INFO_OFFSET) |
9594
BIT(IIO_CHAN_INFO_SCALE),
9695
.scan_index = 0,
9796
.scan_type = {
@@ -245,24 +244,18 @@ static int ccs811_read_raw(struct iio_dev *indio_dev,
245244
switch (chan->channel2) {
246245
case IIO_MOD_CO2:
247246
*val = 0;
248-
*val2 = 12834;
247+
*val2 = 100;
249248
return IIO_VAL_INT_PLUS_MICRO;
250249
case IIO_MOD_VOC:
251250
*val = 0;
252-
*val2 = 84246;
253-
return IIO_VAL_INT_PLUS_MICRO;
251+
*val2 = 100;
252+
return IIO_VAL_INT_PLUS_NANO;
254253
default:
255254
return -EINVAL;
256255
}
257256
default:
258257
return -EINVAL;
259258
}
260-
case IIO_CHAN_INFO_OFFSET:
261-
if (!(chan->type == IIO_CONCENTRATION &&
262-
chan->channel2 == IIO_MOD_CO2))
263-
return -EINVAL;
264-
*val = -400;
265-
return IIO_VAL_INT;
266259
default:
267260
return -EINVAL;
268261
}

0 commit comments

Comments
 (0)