Re: [PATCH v2 1/4] iio: chemical: scd30: add core driver
From: Jonathan Cameron
Date: Mon Jun 01 2020 - 09:35:46 EST
...
> > > > +static const struct iio_chan_spec scd30_channels[] = {
> > > > + {
> > > > + .type = IIO_PRESSURE,
> > > > + .info_mask_separate = BIT(IIO_CHAN_INFO_CALIBSCALE),
> > > > + .info_mask_separate_available = BIT(IIO_CHAN_INFO_CALIBSCALE),
> > > > + .scan_index = -1,
> > > > + },
> > > > + {
> > > > + .type = IIO_CONCENTRATION,
> > > > + .channel2 = IIO_MOD_CO2,
> > > > + .address = SCD30_CONC,
> > > > + .scan_index = SCD30_CONC,
> > > > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> > > > + BIT(IIO_CHAN_INFO_SCALE),
> > > > + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> > > > + .modified = 1,
> > > > +
> > > > + SCD30_CHAN_SCAN_TYPE('u', 16),
> > > > + },
> > > > + {
> > > > + .type = IIO_TEMP,
> > > > + .address = SCD30_TEMP,
> > > > + .scan_index = SCD30_TEMP,
> > > > + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
> > > > + BIT(IIO_CHAN_INFO_CALIBBIAS) |
> > > > + BIT(IIO_CHAN_INFO_SCALE),
> > >
> > > Combination of processed and scale is unusual. Normally scale provides
> > > a conversion factor or a _RAW reading.
> >
> > Right that's pointless. Scales were for raw measurements inside buffer.
> > Somehow I failed to realize that only co2 concentration is raw.
> >
>
> One more thing occurred to me here. I just looked at CONCENTRATION_RAW
> description and is states that this should return *percentage* reading.
> Then after scaling what we should be left with?
It should say after application of scale and offset. Patches welcome :)
>
> Or perhaps scale should return just 1.0 for completeness if we want to
> live with percentages.
>
> Though in case where percentage reading is fractional then passing
> through buffers will not work. Or am I missing something?
>
> On the other hand if abi said nothing about percentages one would just
> push whatever raw reading sensor outputs and provide scaling info to
> userspace.
>
> > >