Third set of IIO new device support, cleanups etc for the 5.8 cycle.

A rather late final set to pick up a couple of new drivers, a bunch
of cleanup and some fixes that can wait for the merge window.

In particularly I'd like to highlight the great core and driver
cleanup work that the Alex and the team at Analog devices are currently
doing.  Should see lots more of that in the next cycle give what is
currently under review.

This pull also has the first few fixes squashing a class of alignment
and small kernel data leak bugs that Lars-Peter Clausen picked up
on in a review.  Quite a few more of those to come.  They've been
there a long time so we aren't rushing the reviews.

New device support
* atlas ezo
  - new driver supporting this range of chemical and similar sensors
    with the odd interface of ascii strings over i2c.
* bma180
  - bma023, bma150 and smb380 support.  Note these are currently also
    supported by a driver in input which we will hopefully remove
    (eventually). There are Kconfig protections to avoid a clash
    in the meantime.
* vcnl3020
  - new driver for this proximity sensor.

Core change
* during buffer updates, change the current state variable before
  we actually call pre and post enable callbacks so drivers can know
  where we are going.  Note this is a precursor to only exposing
  one enable callback to drivers.  The (false) logic behind having two
  such callbacks has long been fixed, but only now is the mess getting
  cleaned up.

* exynos adc.
  - add reporting of channels scale values.

Cleanups and minor fixes.
* core
  - drop now unused attrcount_orig variable.
* ad5360, ad5446, ad5449, ad5755, ad5761, ad5764, ad5380, ad5421,
  ad5592, ad5686 and vf610_dac
  - remove direct use of iio_dev->mlock from all these drivers.
    Its semantics used to be poorly defined, but now it is for core
    use only.  Removing it's use in drivers has been a long process
    of which this is the latest step!
* exynos_adc
  - drop a pointless check on the phy as the driver doesn't access it.
* ping
  - avoid a dance from iio_priv and iio_priv_to_dev back again by
    just passing the iio_dev into the functions.
* pms7003
  - alignment and potential data leak fix.
* sps30
  - alignment bug fix.

iio:chemical:pms7003: Fix timestamp alignment and prevent data leak.

One of a class of bugs pointed out by Lars in a recent review.
iio_push_to_buffers_with_timestamp assumes the buffer used is aligned
to the size of the timestamp (8 bytes).  This is not guaranteed in
this driver which uses an array of smaller elements on the stack.
As Lars also noted this anti pattern can involve a leak of data to
userspace and that indeed can happen here.  We close both issues by
moving to a suitable structure in the iio_priv() data with alignment
explicitly requested.  This data is allocated with kzalloc so no
data can leak appart from previous readings.

Fixes: a1d642266c14 ("iio: chemical: add support for Plantower PMS7003 sensor")
Reported-by: Lars-Peter Clausen <>
Signed-off-by: Jonathan Cameron <>
Cc: <>
Acked-by: Tomasz Duszynski <>
1 file changed