Skip to content

Commit f51171c

Browse files
vamoiridjic23
authored andcommitted
iio: chemical: bme680: Add SCALE and RAW channels
Add SCALE,RAW channels to the device. Even though PROCESSED should be kept for backwards compatibility add comment to avoid using it if the value is not actually reported in IIO values. Signed-off-by: Vasileios Amoiridis <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 4865ee1 commit f51171c

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

drivers/iio/chemical/bme680_core.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,26 @@ EXPORT_SYMBOL_NS(bme680_regmap_config, IIO_BME680);
144144
static const struct iio_chan_spec bme680_channels[] = {
145145
{
146146
.type = IIO_TEMP,
147+
/* PROCESSED maintained for ABI backwards compatibility */
147148
.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
149+
BIT(IIO_CHAN_INFO_RAW) |
150+
BIT(IIO_CHAN_INFO_SCALE) |
148151
BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO),
149152
},
150153
{
151154
.type = IIO_PRESSURE,
155+
/* PROCESSED maintained for ABI backwards compatibility */
152156
.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
157+
BIT(IIO_CHAN_INFO_RAW) |
158+
BIT(IIO_CHAN_INFO_SCALE) |
153159
BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO),
154160
},
155161
{
156162
.type = IIO_HUMIDITYRELATIVE,
163+
/* PROCESSED maintained for ABI backwards compatibility */
157164
.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
165+
BIT(IIO_CHAN_INFO_RAW) |
166+
BIT(IIO_CHAN_INFO_SCALE) |
158167
BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO),
159168
},
160169
{
@@ -787,6 +796,48 @@ static int bme680_read_raw(struct iio_dev *indio_dev,
787796
default:
788797
return -EINVAL;
789798
}
799+
case IIO_CHAN_INFO_RAW:
800+
switch (chan->type) {
801+
case IIO_TEMP:
802+
ret = bme680_read_temp(data, (s16 *)&chan_val);
803+
if (ret)
804+
return ret;
805+
806+
*val = chan_val;
807+
return IIO_VAL_INT;
808+
case IIO_PRESSURE:
809+
ret = bme680_read_press(data, &chan_val);
810+
if (ret)
811+
return ret;
812+
813+
*val = chan_val;
814+
return IIO_VAL_INT;
815+
case IIO_HUMIDITYRELATIVE:
816+
ret = bme680_read_humid(data, &chan_val);
817+
if (ret)
818+
return ret;
819+
820+
*val = chan_val;
821+
return IIO_VAL_INT;
822+
default:
823+
return -EINVAL;
824+
}
825+
case IIO_CHAN_INFO_SCALE:
826+
switch (chan->type) {
827+
case IIO_TEMP:
828+
*val = 10;
829+
return IIO_VAL_INT;
830+
case IIO_PRESSURE:
831+
*val = 1;
832+
*val2 = 1000;
833+
return IIO_VAL_FRACTIONAL;
834+
case IIO_HUMIDITYRELATIVE:
835+
*val = 1;
836+
*val2 = 1000;
837+
return IIO_VAL_FRACTIONAL;
838+
default:
839+
return -EINVAL;
840+
}
790841
case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
791842
switch (chan->type) {
792843
case IIO_TEMP:

0 commit comments

Comments
 (0)