lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Sun, 5 May 2024 18:58:09 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Petar Stoykov <pd.pstoykov@...il.com>
Cc: Jonathan Cameron <Jonathan.Cameron@...wei.com>,
 linux-iio@...r.kernel.org, Lars-Peter Clausen <lars@...afoo.de>, Rob
 Herring <robh+dt@...nel.org>, Andy Shevchenko
 <andriy.shevchenko@...ux.intel.com>, Angel Iglesias
 <ang.iglesiasg@...il.com>, Krzysztof Kozlowski
 <krzysztof.kozlowski+dt@...aro.org>, Conor Dooley <conor+dt@...nel.org>,
 linux-kernel@...r.kernel.org, devicetree@...r.kernel.org
Subject: Re: [PATCH 2/3] iio: pressure: Add driver for Sensirion SDP500


> > > +}
> > > +
> > > +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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ