Re: [PATCH 2/3] iio: pressure: Add driver for Sensirion SDP500

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> > > +}
> > > +
> > > +static const struct iio_chan_spec sdp500_channels[] = {
> > > +    {
> > > +        .type = IIO_PRESSURE,
> > > +        .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),  
> >
> > Looks like a simple linear scale.  Would be better to make scaling
> > a userspace / consumer problem and provide IIO_CHAN_INFO_RAW
> > and IIO_CHAN_INFO_SCALE.  
> 
> I prefer returning the pressure directly because there is no other calculation
> that the user of this driver can do. If they make the calculation differently
> then their pressure value would be wrong.

Ah. I missed this and just made the same comment on v2.
Let me give some more info than in the original review.

The documentation on how to apply scale is simple and this scaling is
pretty hard to get wrong.

There are a couple of reasons we prefer to make it a userspace problem
to do linear scaling and keep the actual channel value raw (if possible).
1) Logging applications typically store the scale once, and each data
   point is then much cheaper to store as a u16 than as a floating point
   number.
2) If you ever add buffered support, we do not support floating point
   values in the buffer.  That basically means we have to have both
   _PROCESSED and _RAW provided so that _SCALE makes sense for the buffer.
   Horribly messy ABI is the result.

Hence, push the scaling to userspace.

Note that we can't always do this as some conversion functions are
non linear and very hard to describe.  In those cases _PROCESSED makes
sense.  That's not true here.

Jonathan




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux