1
0
Fork 0
Commit Graph

52 Commits (redonkable)

Author SHA1 Message Date
Jonathan Cameron 7005a4885a iio:health:afe4404 Fix timestamp alignment and prevent data leak.
[ Upstream commit f88ecccac4 ]

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 a 40 byte 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: 87aec56e27 ("iio: health: Add driver for the TI AFE4404 heart monitor")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-07-22 09:33:00 +02:00
Jonathan Cameron baf22f66c9 iio:health:afe4403 Fix timestamp alignment and prevent data leak.
commit 3f9c6d3879 upstream.

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 a 32 byte 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: eec96d1e2d ("iio: health: Add driver for the TI AFE4403 heart monitor")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Andrew F. Davis <afd@ti.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-07-22 09:32:54 +02:00
Thomas Gleixner 1802d0beec treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174
Based on 1 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license version 2 as
  published by the free software foundation this program is
  distributed in the hope that it will be useful but without any
  warranty without even the implied warranty of merchantability or
  fitness for a particular purpose see the gnu general public license
  for more details

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

has been chosen to replace the boilerplate/reference in 655 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190527070034.575739538@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:26:41 -07:00
Thomas Gleixner c942fddf87 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157
Based on 3 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license or at
  your option any later version this program is distributed in the
  hope that it will be useful but without any warranty without even
  the implied warranty of merchantability or fitness for a particular
  purpose see the gnu general public license for more details

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license or at
  your option any later version [author] [kishon] [vijay] [abraham]
  [i] [kishon]@[ti] [com] this program is distributed in the hope that
  it will be useful but without any warranty without even the implied
  warranty of merchantability or fitness for a particular purpose see
  the gnu general public license for more details

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license or at
  your option any later version [author] [graeme] [gregory]
  [gg]@[slimlogic] [co] [uk] [author] [kishon] [vijay] [abraham] [i]
  [kishon]@[ti] [com] [based] [on] [twl6030]_[usb] [c] [author] [hema]
  [hk] [hemahk]@[ti] [com] this program is distributed in the hope
  that it will be useful but without any warranty without even the
  implied warranty of merchantability or fitness for a particular
  purpose see the gnu general public license for more details

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 1105 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190527070033.202006027@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:26:37 -07:00
Thomas Gleixner ec8f24b7fa treewide: Add SPDX license identifier - Makefile/Kconfig
Add SPDX license identifiers to all Make/Kconfig files which:

 - Have no license information of any form

These files fall under the project license, GPL v2 only. The resulting SPDX
license identifier is:

  GPL-2.0-only

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-21 10:50:46 +02:00
Gustavo A. R. Silva 9ffa68f654 iio: health: max30102: Mark expected switch fall-throughs
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Notice that in this particular case, I placed the "fall through"
annotation at the bottom of the case, which is what GCC is expecting
to find.

Addresses-Coverity-ID: 1458342 ("Missing break in switch")
Addresses-Coverity-ID: 1458345 ("Missing break in switch")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-08-19 17:21:35 +01:00
Matt Ranostay d6ad805844 iio: add SPDX identifier for various drivers
Add GPLv2+ SPDX identifier and update email for author's drivers.

Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-02-18 11:55:19 +00:00
Greg Kroah-Hartman e8cd29b774 Merge Linus's staging merge point into staging-next
This resolves the merge issue pointed out by Stephen in
drivers/iio/adc/meson_saradc.c.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-06 15:27:17 +01:00
Peter Meerwald-Stadler ad44a9f804 iio: health: max30102: Temperature should be in milli Celsius
As per ABI temperature should be in milli Celsius after scaling,
not Celsius

Note on stable cc.  This driver is breaking the standard IIO
ABI. (JC)

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 11:15:14 +00:00
Peter Meerwald-Stadler 90579b69e9 iio: health: max30102: Add MAX30105 support
The Maxim MAX30105 part adds a third LED (green) and uses a multi-LED
measuring mode producing three measurements

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:41:08 +00:00
Peter Meerwald-Stadler fef79edc17 iio: health: max30102: Prepare for copying varying number of measurements
Current code assumes always 2 measurements (6 bytes) have to be copied,
prepare for more flexibility

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:41:05 +00:00
Peter Meerwald-Stadler 83e6415d56 iio: health: max30102: Move mode setting to buffer_postenable
Move the programming of the mode setting from init() to
buffer_postenable()

Split out a separate function to
only update the power/shutdown bit

This changes permits to more easily implement different
modes of measurements in further patches

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:41:01 +00:00
Peter Meerwald-Stadler ad90e570e2 iio: health: max30102: Introduce indices for LED channels
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:57 +00:00
Peter Meerwald-Stadler a9c47abbdd iio: health: max30102: Add power enable parameter to get_temp function
Chip must not be in shutdown for reading temperature, so briefly leave
shutdown if buffer is not already running

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:55 +00:00
Peter Meerwald-Stadler 839a74cde7 iio: health: max30102: Introduce intensity channel macro
Signed-off-by: Peter Meerwald-Stalder <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:50 +00:00
Peter Meerwald-Stadler 84b0ce05e4 iio: health: max30102: Add check for part ID
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:46 +00:00
Peter Meerwald-Stadler d0b950c73d iio: health: max30102: Check retval of powermode function
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:44 +00:00
Peter Meerwald-Stadler 7b0b0ec157 iio: health: max30102: Fix mode config values
Table 4 of the datasheet specifies the mode control, these are not
individual bits; add multi LED mode

Add multi-LED mode and fix MODE_MASK (3 bits wide, not 2)

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:39 +00:00
Peter Meerwald-Stadler c31c946af8 iio: health: max30102: Remove inconsistent full stop in error message
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:34 +00:00
Peter Meerwald-Stadler dd86dbf94f iio: health: max30102: Fix missing newline in dev_err
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:31 +00:00
Jonathan Cameron 73bba67096 iio:health: drop assign iio_info.driver_module and iio_trigger_ops.owner
The equivalent of both of these are now done via macro magic when
the relevant register calls are made.  The actual structure
elements will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:29:44 +01:00
Greg Kroah-Hartman 34ff6c2fe3 First set of IIO new device support, features and cleanup for the 4.12 cycle.
Quite a bit of outreachy activity here with a driver from a current intern
 and a number of cleanup patches as part of the next round.
 
 Getting a pull request in early this cycle as it's looking like another large
 cycle for IIO.
 
 New device support
 * adxl345
   - initial device support. Note, once complete support is done the intent
     is to superceded the driver in input/misc.
   - bindings.
   - conversion from i2c direct calls to regmap and driver split.
   - spi support.
 * chromeos light and proximity.
   - new driver.
 * devantech srf04 ultrasonic ranger
   - new driver with device tree bindings.
 * hid temperature
   - new driver for environemntal temperature support from hid devices.
 * max30102 oximeter
   - new driver with device tree bindings.
 * st lsm6dsx
   - refactor and addition of device support for lsm6dsl and lsm6ds3h.
 
 Staging graduation
 * isl29028 including copyright notice update to reflect Brian's work.
 * lpc32xx_adc.
 * spear adc. It's not perfect and there are some datasheet disagreements, but
   it works and is good enough to graduate.
 
 New features
 * documentation
   - abi docs for in_proximity_sampling_frequency_available.
   - generalise counting direction ABI docs as a second driver is going to
   use them.
 * hid-sensor-prox
   - Add support for HID_USAGE_SENSOR_HUMAN_PRESENCE if used on a particular
   device.
 * isl29028
   - runtime pm.
 * meson-saradc
   - switch from polling to interrupt mode and improved read_raw_sample function
   to avoid unnecessary loop.
 * tmp007
   - interrupt and threshold event support.
 
 Cleanups and minor fixes
 * ad2s1210
   - permissions to octal.
 * ad7192
   - permissions to octal.
   - use BIT macro.
 * ad9832
   - merge header definitions into source file.
 * ad9834
   - merge header definitions into source file.
 * ade7753
   - merge header definitions into source file.
   - cleanup include ordering.
 * ade7854
   - simplify return logic.
 * adis16201
   - merge header definitions into source file.
   - rename _core.c to .c as there is nothing else.
 * adis16203
   - merge header definitions into source file.
   - rename _core.c to .c as there is nothing else.
 * adis16209
   - merge header definitions into source file.
   - rename _core.c to .c as there is nothing else.
 * adis16240
   - permissions to octal.
   - merge header definitions into source file.
   - rename _core.c to .c as there is nothing else.
 * adt7136
   - permissions to octal.
 * cio-dac
   - set missing parent device.
 * documentation
   - update version numbers on sysfs ABI for counter bits that didn't quite.
   make 4.9.
 * isl29028
   - mdelay to msleep.
   - incorrrect sleep time when taking first proximity reading.
 * lmp91000
   - set missing parent device.
 * lpc32xx
   - Consistent prefixes for defines.
   - rename local state structure to _state.
 * max30100
   - set missing parent device.
 * max30102
   - set missing parent device.
 * maxim-thermocouple
   - set missing parent device.
 * meter driver header
   - permissions to octal.
 * pulsedlight-lidar-lite-v2
   - set missing parent device.
 * quad-8
   - set missing parent device.
 * st104
   - set missing parent device.
 
 Other
 * Mailmap
   - update Matt Ranostay's email address to the Konsolko one.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAli8K40RHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FogLWBAAoclyQ3AwUecfujFcGx/ZJuba63M+qPIk
 SvmUCocnCjfgLI5WnB4J6rMldoD7CMAhrOpFeFuJlr/g6f4WMToJVT6PdHEtMqvB
 Rci/ODa9QNDPBpA1sLGCFu704yzBxQTmq53V1d9kZBJ/FxTqwOZamStjKAC2EskX
 yuslGGGSdveIYfmBfHIY1VlT2xwuf9xmyhi0STAIn86ViATH/Hhz2xWNBjaHxTrs
 gJ6sLGmwh9RYO1KlXSUmbXHd9mWoME2iIsEVGsPzILPkHuHsjvVtjPmQkHB6cT8v
 W1OvYJqHz7CbOmcqOVCUbtho/sdw9uhdGkc+Vm9ilxukfVFu9I3cnTTV6um7rj76
 /bKf4qB0B/BlXgyfGdGY/gmotSI53sPeG7Vp0nd/5ZmYXKhP4NS+rRB1ipy71nGV
 YY/fmgrAobm3wrmWdMUOhBCH/hfN8aSR3S6exJarEejfIpOzu3GeVP8706krKvwO
 1HOHBVyJ5gt+WI18kvYC78Mhs5HVeKCSuHf8eJ1bZHOUoVtIHtN4HnF5wCa0on/t
 Qu0am0SW596J95EUVMsodNYXUTP6JwcQeKt65VvXSq2jcnqylPT95SuroVqZ3NNH
 Lpq7kfjfV4p/n6G9EUE/7+RBXZL0BboI7v8GbIvodfXmFk099mkEbHnpMRffc6XQ
 o1TUYqzAQPI=
 =rlqq
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-4.12a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

First set of IIO new device support, features and cleanup for the 4.12 cycle.

Quite a bit of outreachy activity here with a driver from a current intern
and a number of cleanup patches as part of the next round.

Getting a pull request in early this cycle as it's looking like another large
cycle for IIO.

New device support
* adxl345
  - initial device support. Note, once complete support is done the intent
    is to superceded the driver in input/misc.
  - bindings.
  - conversion from i2c direct calls to regmap and driver split.
  - spi support.
* chromeos light and proximity.
  - new driver.
* devantech srf04 ultrasonic ranger
  - new driver with device tree bindings.
* hid temperature
  - new driver for environemntal temperature support from hid devices.
* max30102 oximeter
  - new driver with device tree bindings.
* st lsm6dsx
  - refactor and addition of device support for lsm6dsl and lsm6ds3h.

Staging graduation
* isl29028 including copyright notice update to reflect Brian's work.
* lpc32xx_adc.
* spear adc. It's not perfect and there are some datasheet disagreements, but
  it works and is good enough to graduate.

New features
* documentation
  - abi docs for in_proximity_sampling_frequency_available.
  - generalise counting direction ABI docs as a second driver is going to
  use them.
* hid-sensor-prox
  - Add support for HID_USAGE_SENSOR_HUMAN_PRESENCE if used on a particular
  device.
* isl29028
  - runtime pm.
* meson-saradc
  - switch from polling to interrupt mode and improved read_raw_sample function
  to avoid unnecessary loop.
* tmp007
  - interrupt and threshold event support.

Cleanups and minor fixes
* ad2s1210
  - permissions to octal.
* ad7192
  - permissions to octal.
  - use BIT macro.
* ad9832
  - merge header definitions into source file.
* ad9834
  - merge header definitions into source file.
* ade7753
  - merge header definitions into source file.
  - cleanup include ordering.
* ade7854
  - simplify return logic.
* adis16201
  - merge header definitions into source file.
  - rename _core.c to .c as there is nothing else.
* adis16203
  - merge header definitions into source file.
  - rename _core.c to .c as there is nothing else.
* adis16209
  - merge header definitions into source file.
  - rename _core.c to .c as there is nothing else.
* adis16240
  - permissions to octal.
  - merge header definitions into source file.
  - rename _core.c to .c as there is nothing else.
* adt7136
  - permissions to octal.
* cio-dac
  - set missing parent device.
* documentation
  - update version numbers on sysfs ABI for counter bits that didn't quite.
  make 4.9.
* isl29028
  - mdelay to msleep.
  - incorrrect sleep time when taking first proximity reading.
* lmp91000
  - set missing parent device.
* lpc32xx
  - Consistent prefixes for defines.
  - rename local state structure to _state.
* max30100
  - set missing parent device.
* max30102
  - set missing parent device.
* maxim-thermocouple
  - set missing parent device.
* meter driver header
  - permissions to octal.
* pulsedlight-lidar-lite-v2
  - set missing parent device.
* quad-8
  - set missing parent device.
* st104
  - set missing parent device.

Other
* Mailmap
  - update Matt Ranostay's email address to the Konsolko one.
2017-03-06 13:17:21 +01:00
Lars-Peter Clausen fa722499bb iio: max30102: Set parent device
Initialize the parent of the IIO device to the device that registered it.
This makes sure that the IIO device appears the right level in the device
hierarchy.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-19 12:00:16 +00:00
Lars-Peter Clausen 5d548b733e iio: max30100: Set parent device
Initialize the parent of the IIO device to the device that registered it.
This makes sure that the IIO device appears the right level in the device
hierarchy.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-19 11:59:36 +00:00
Greg Kroah-Hartman a769f30c7b Merge 4.10-rc7 into staging-next
This resolves the merge errors that were reported in linux-next and it
picks up the staging and IIO fixes that we need/want in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-06 09:36:10 +01:00
Matt Ranostay b3c590ce14 iio: health: add MAX30102 oximeter driver support
MAX30102 is an heart rate and pulse oximeter sensor that works using
two LEDS of different wavelengths, and detecting the light reflected
back.

This patchset adds support for both IR and RED LED channels which can
be processed in userspace to determine heart rate and blood oxygen
levels. The MAX30102 part isn't completely register and functional
compatible with the existing MAX30100 driver.

Signed-off-by: Matt Ranostay <matt@ranostay.consulting>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-02-05 09:45:00 +00:00
Nicholas Mc Guire 18e2452a3c iio: health: max30100: use msleep() for long uncritical delays
ulseep_range() uses hrtimers and provides no advantage over msleep()
for larger delays. Fix up the 35ms delays here to use msleep() and
reduce the load on the hrtimer subsystem.

Fixes: commit 4d33615df5 ("iio: light: add MAX30100 oximeter driver support")
Link: http://lkml.org/lkml/2017/1/11/377
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Reviewed-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22 13:21:28 +00:00
Matt Ranostay 828f84ee8f iio: health: max30100: fixed parenthesis around FIFO count check
FIFO was being read every sample after the "almost full" state was
reached. This was due to an incorrect placement of the parenthesis
in the while condition check.

Note - the fixes tag is not actually correct, but the fix in this patch
would also be needed for it to function correctly so we'll go with that
one.  Backports should pick up both.

Signed-off-by: Matt Ranostay <matt@ranostay.consulting>
Fixes: b74fccad7 ("iio: health: max30100: correct FIFO check condition")
Cc: Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-21 14:16:20 +00:00
Alison Schofield 802ecfc113 iio: health: afe4404: retrieve a valid iio_dev in suspend/resume
The suspend/resume functions were using dev_to_iio_dev() to get
the iio_dev. That only works on IIO dev's.  Replace it with i2c
functions to get the correct iio_dev.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Acked-by: Andrew F. Davis <afd@ti.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-21 13:12:41 +00:00
Alison Schofield a5badd1e97 iio: health: afe4403: retrieve a valid iio_dev in suspend/resume
The suspend/resume functions were using dev_to_iio_dev() to get
the iio_dev. That only works on IIO dev's.  Replace it with spi
functions to get the correct iio_dev.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Acked-by: Andrew F. Davis <afd@ti.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-21 13:11:06 +00:00
Greg Kroah-Hartman aabb406008 First round of IIO new device support, features and cleanups for the 4.8 cycle.
New device support
 * ads1015
   - add ads1115 support
 * bma220 accelerometer
   - new driver
   - triggered buffer support.
 * bmc150
   - add bmm150 support.
 * bmp280
   - bme280 support with addition of humidity channel.
 * max5487 potentiometer
   - new driver
 * MMA7660FC accelerometer.
   - New driver
 * st-pressure
   - support for the lps22hb
 * loop trigger.
   - This one is *nasty* but we have real applications (parrot drones) where
   it is useful.  The trigger basically spins as hard as it can firing off
   a new trigger each time all triggered devices come back to say they are
   done.  It doesn't hang a machine even when doing it on a dummy driver.
   A lot nicer than having this implemented within lots of device drivers
   anyway.
 
 Core stuff
 * Add support to create IIO devices via configfs (similar to we did for
 triggers a while back) + docs.
 * New channel types
   - IIO_ELECTRICAL_CONDUCTIVITY
 * Couple of MAINTAINERS patches to list the device tree bindings.
 * Make trigger ops structure non optional (comment fix). It hasn't been for
 an awful long time, but that's not what the description said.
 
 New features
 * ak8975
   - support adapters that are limited to byte data only by allowing the
   emulated block read i2c function that was recently introduced.
 * atlas-ph
   - support atlas-ec (electrical conductivity sensor)
 * bmi160
   - add available frequency and scale attributes to make the driver
   more user friendly (and avoid having to read the datasheet to know
   what will work).
 * dummy
   - move creation to configfs interface.  It's not real hardware so we
   are not that worried about the ABI breakage ;)
 * mma8452
   - oversampling ration support
 * nau7802
   - expose available gains to make life easier for userspace.
 * st-sensors
   - allow use of emulation for SMBus block reads as all the st parts support
   it.
 * ti-ads1015
   - list datasheet names to allow their use by inkernel consumers.
 * Various module alias additions to help auto probing.  Drop one redundant one
 as well.
 
 Cleanups
 * ad7266, ad7476, ad7887, ad7923, ad799x
   - use direct mode claim function rather than open coding it during sensor
   read (prevents switching on buffers mid read).
 * ad7793, ad7791
   - use direct mode claim to prevent frequency changes when buffers running.
 * afe440x - These are ABI breaking but the driver requires custom userspace
   code to do anything useful anyway and that is still being written and under
   control of TI.  Ultimately we may have other libraries to do pulse
   oximetry with these devices but we aren't aware of any yet.
   - kernel-doc format fixes
   - drop ifdef fun around of_match_ptr - it's not worth the mess to save
   a tiny amount of space.
   - drop some unnecessary register initializations.
   - drop the weird locked gain modes as they gain us nothing (can just set
   all gains separately).
   - remove handling of offset attributes seeing as no channels actually have
   them (oops)
   - Drop the LED3 input channel as it's an alias for ALED2.
   - *big one* remove channel names - an experiment that turned out to not
   make sense - see patch for details.
   - use regmap fields to clean up code.
   - tie the tia gain stages to appropriate channels in the ABI as that is
   what they really effect. Same with the LED currents.
   - cleanout some unused defines and fix a missnamed one.
 * atlas-ph
   - reorganise to allow support of other similar parts.
 * bmc150
   - document supported chips in kconfig help.
 * jsa1212
   - drop an unneeded i2c functionality check for functionality the driver
   doesn't use.
 * mxs-lradc
   - simply touch screen registration code.
   - remove the touch screen unregister as all devm based now.
   - disable only those channels that are masked in hardware stop (others
   are already dealt with elsewhere)
 * st-sensors
   - unexport st_sensors_get_buffer_element as nothing outside the st-sensors
   core driver uses it.
   - fix handling of failure to start up regulators.
 * tpl0102
   - drop an i2c functionality test for features that aren't needed.
 * ti-am335x
   - use variable name rather than type in sizeof for clarity.
   - use SIMPLE_DEV_PM_OPS helper macro to tidy up a bit.
 
 Tools
 * Add install / uninstall to makefile.  Someone cares, so presumably
 some people will find it useful!
 *  generic_buffer
    - rename to iio_generic_buffer to line up with other tools.
    - handle cleanup when receiving signals
    - Add a --device-num option and a --trigger-num option rather than
    relying on naming which doesn't work if you have two of the same part.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJXWFXGAAoJEFSFNJnE9BaIQ4kP/jcoVTR8w6EMdcr1BErrvFgm
 IMbMMK8wJtc1dhKcp77h/DQjCunPAaDMgdtg1uJcreRDl1dY1jiFh/PMLrt/eods
 tsJZcN1h40aLlPEdMQFl3oiaWjpUm23gdDtfiCHA+sM/FhQ+A+83EdonU7hbAGT2
 E2NAb5xkC+74WEUit5qEouz++4JRnsJEpBx3A7mwkiUH9RnFA9OflsTdIFSIEbzb
 V4yMWeYBAlhwKPy/7z6/hAMK/+Psabw8FppCAw2HcADVpT517rkl4MpvErSZeFGz
 cr46+ZWhXZ4PaG2jG2xVLpqSbqLSfWp8uqfj0WavW2gFn/1jCB+FST904q7IPVW2
 QPxALqxMAMSzOHxTYmDLfJ4IJ5vvLKroom4ixKgbl7jKXF3+PTooR6U4hGQmLK7K
 VKWjb/kIdHpuRT3/pG2kysMtJkk1av5BBZkl9sWUEFgCd4vYP1eB1Ah3aE/P26OH
 BCueMDaJqKAzmVa6Dx5MCLlJpxHpQl/OBz5wdXiMRbYeky/QHgzaTmi/HZ0wwXvn
 zFHAglWzLq7q0HY+q7wwI20R16cRYIve3HOaLFvQdXd1xpBP1BF+aAxT/vSb+otS
 1OWCEHAxq4XEM7VcRKv9XL59gXuSB8ZaSl6k82+IjjfgOqLHh8BSygVle7iu14TE
 glokfXQRC7xhgfC1zQf9
 =Hq1a
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-4.8a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

First round of IIO new device support, features and cleanups for the 4.8 cycle.

New device support
* ads1015
  - add ads1115 support
* bma220 accelerometer
  - new driver
  - triggered buffer support.
* bmc150
  - add bmm150 support.
* bmp280
  - bme280 support with addition of humidity channel.
* max5487 potentiometer
  - new driver
* MMA7660FC accelerometer.
  - New driver
* st-pressure
  - support for the lps22hb
* loop trigger.
  - This one is *nasty* but we have real applications (parrot drones) where
  it is useful.  The trigger basically spins as hard as it can firing off
  a new trigger each time all triggered devices come back to say they are
  done.  It doesn't hang a machine even when doing it on a dummy driver.
  A lot nicer than having this implemented within lots of device drivers
  anyway.

Core stuff
* Add support to create IIO devices via configfs (similar to we did for
triggers a while back) + docs.
* New channel types
  - IIO_ELECTRICAL_CONDUCTIVITY
* Couple of MAINTAINERS patches to list the device tree bindings.
* Make trigger ops structure non optional (comment fix). It hasn't been for
an awful long time, but that's not what the description said.

New features
* ak8975
  - support adapters that are limited to byte data only by allowing the
  emulated block read i2c function that was recently introduced.
* atlas-ph
  - support atlas-ec (electrical conductivity sensor)
* bmi160
  - add available frequency and scale attributes to make the driver
  more user friendly (and avoid having to read the datasheet to know
  what will work).
* dummy
  - move creation to configfs interface.  It's not real hardware so we
  are not that worried about the ABI breakage ;)
* mma8452
  - oversampling ration support
* nau7802
  - expose available gains to make life easier for userspace.
* st-sensors
  - allow use of emulation for SMBus block reads as all the st parts support
  it.
* ti-ads1015
  - list datasheet names to allow their use by inkernel consumers.
* Various module alias additions to help auto probing.  Drop one redundant one
as well.

Cleanups
* ad7266, ad7476, ad7887, ad7923, ad799x
  - use direct mode claim function rather than open coding it during sensor
  read (prevents switching on buffers mid read).
* ad7793, ad7791
  - use direct mode claim to prevent frequency changes when buffers running.
* afe440x - These are ABI breaking but the driver requires custom userspace
  code to do anything useful anyway and that is still being written and under
  control of TI.  Ultimately we may have other libraries to do pulse
  oximetry with these devices but we aren't aware of any yet.
  - kernel-doc format fixes
  - drop ifdef fun around of_match_ptr - it's not worth the mess to save
  a tiny amount of space.
  - drop some unnecessary register initializations.
  - drop the weird locked gain modes as they gain us nothing (can just set
  all gains separately).
  - remove handling of offset attributes seeing as no channels actually have
  them (oops)
  - Drop the LED3 input channel as it's an alias for ALED2.
  - *big one* remove channel names - an experiment that turned out to not
  make sense - see patch for details.
  - use regmap fields to clean up code.
  - tie the tia gain stages to appropriate channels in the ABI as that is
  what they really effect. Same with the LED currents.
  - cleanout some unused defines and fix a missnamed one.
* atlas-ph
  - reorganise to allow support of other similar parts.
* bmc150
  - document supported chips in kconfig help.
* jsa1212
  - drop an unneeded i2c functionality check for functionality the driver
  doesn't use.
* mxs-lradc
  - simply touch screen registration code.
  - remove the touch screen unregister as all devm based now.
  - disable only those channels that are masked in hardware stop (others
  are already dealt with elsewhere)
* st-sensors
  - unexport st_sensors_get_buffer_element as nothing outside the st-sensors
  core driver uses it.
  - fix handling of failure to start up regulators.
* tpl0102
  - drop an i2c functionality test for features that aren't needed.
* ti-am335x
  - use variable name rather than type in sizeof for clarity.
  - use SIMPLE_DEV_PM_OPS helper macro to tidy up a bit.

Tools
* Add install / uninstall to makefile.  Someone cares, so presumably
some people will find it useful!
*  generic_buffer
   - rename to iio_generic_buffer to line up with other tools.
   - handle cleanup when receiving signals
   - Add a --device-num option and a --trigger-num option rather than
   relying on naming which doesn't work if you have two of the same part.
2016-06-09 09:15:58 -07:00
Andrew F. Davis 0825cce21f iio: health/afe4404: ENSEPGAIN is part of CONTROL2 register
Rename this definition, no functional changes.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-04 11:14:16 +01:00
Andrew F. Davis e462350a95 iio: health/afe440x: Remove unused definitions
These definitions are not currently used and if the functionality
they represent is needed the values should be added back to a table
for easy userspace use.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-04 11:13:36 +01:00
Andrew F. Davis 3ff34ee2ad iio: health/afe440x: Match LED currents to stages
The current channel number for the LEDs should match the stage
number that they are active during, fix this here.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-04 11:12:55 +01:00
Andrew F. Davis 1276187c52 iio: health/afe440x: Make gain settings a modifier for the stages
Currently the TIA gain settings are exported to userspace as sysfs
entries that do not clearly represent their internal relation to the
sampling stages. The gain settings are enabled on a per-stage basis,
this can be seen in figure 24 of the current AFE4404 datasheet.
These gain settings should therefore be tied to the channels that are
read during these stages. Make this change here.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-04 11:11:30 +01:00
Andrew F. Davis b36e825764 iio: health/afe440x: Use regmap fields
These drivers can use regmap fields to access fields in registers, this
allows us to remove some macros/defines and simplify code, do this here.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-04 11:10:38 +01:00
Andrew F. Davis 24b9dea764 iio: health/afe440x: Remove channel names
These AFEs have 4 ADC mesuring stages (called LED2, ALED2, LED1, and
ALED1 in the datasheet), we map these as channels, these stages can serve
different purposes depending on the application. For instance the AFE4404
has an additional LED (LED3), this LED can be timed to be active during
stage 2 (or anystage, but the datasheet describes this case and the name
of the stage reflects this use). This ability is used further in upcoming
parts that tie the front-end gain and the LED timings together. For these
reasons we remove explicit naming the channels.

Without channel names it is best that the index numbers are in order to
match the stage number, reorder the channel numbers.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-04 11:08:14 +01:00
Andrew F. Davis 606c7e6c1b iio: health/afe4404: Remove LED3 input channel
Input channel LED3 is only an alias for stage ALED2, this virtual channel
does nothing for us, remove this channel.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-04 11:04:30 +01:00
Andrew F. Davis 2e0df3a583 iio: health/afe440x: Remove unneeded offset handling
No channel in the afe4403 driver has IIO_CHAN_INFO_OFFSET set so
remove the handlers for this.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-04 11:03:49 +01:00
Andrew F. Davis 9d3d9a57e4 iio: health/afe440x: Fix scan_index assignment
The LED channels are not scannable and so scan_index should
be negative, fix this here.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-04 11:03:01 +01:00
Andrew F. Davis 81f517270d iio: health/afe440x: Always use separate gain values
Locking the two gain stages to the same setting adds no value for us,
so initialize them as unlocked and remove the sysfs for unlocking them.
This also allows us to greatly simplify showing and setting the gain
registers.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-04 11:02:39 +01:00
Andrew F. Davis e85fa0338b iio: health/afe440x: Remove unneeded initializers
The drivers set some register values during initialization that can be
set at runtime, these defaults were used in testing but are not
necessary, remove these.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-04 10:59:47 +01:00
Andrew F. Davis daffd7a75c iio: health/afe440x: Remove of_match_ptr and ifdefs
The drivers DT tables are not built-in when OF is not enabled, this does
not save us enough to justify ugly ifdefs. Clean this up.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-04 10:59:04 +01:00
Andrew F. Davis f59e6b5ae0 iio: health/afe440x: Fix kernel-doc format
Fix kernel-doc formatting for structs, and while we are making little
fixes, clarify the module description and update the copywrite.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-04 10:57:58 +01:00
Matt Ranostay b74fccad75 iio: health: max30100: correct FIFO check condition
Correct issue that the last entry in FIFO was being read twice due
to an incorrect decrement of entry count variable before condition
check.

Signed-off-by: Matt Ranostay <mranostay@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-03-28 10:09:58 +01:00
Arnd Bergmann 0e6071ab76 iio: health/afe4404: mark suspend/resume functions __maybe_unused
The newly added afe4404 driver implements suspend/resume using the
SIMPLE_DEV_PM_OPS() macro, which leaves out references to the actual
functions when CONFIG_PM is disabled, causing a harmless warning:

health/afe4404.c:509:12: error: 'afe4404_suspend' defined but not used
health/afe4404.c:530:12: error: 'afe4404_resume' defined but not used

This marks the functions as __maybe_unused so we don't get those
warnings.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 87aec56e27 ("iio: health: Add driver for the TI AFE4404 heart monitor")
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-02-17 19:36:01 +00:00
Arnd Bergmann 9e8be75e27 iio: health/afe4403: mark suspend/resume functions __maybe_unused
The newly added afe4403 driver implements suspend/resume using the
SIMPLE_DEV_PM_OPS() macro, which leaves out references to the actual
functions when CONFIG_PM is disabled, causing a harmless warning:

health/afe4403.c:509:12: error: 'afe4403_suspend' defined but not used
health/afe4403.c:530:12: error: 'afe4403_resume' defined but not used

This marks the functions as __maybe_unused so we don't get those
warnings.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: eec96d1e2d ("iio: health: Add driver for the TI AFE4403 heart monitor")
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-02-17 19:35:28 +00:00
Arnd Bergmann f56293c75b iio: health/afe4403: select REGMAP_SPI
The newly added afe4403 driver uses the regmap facility to abstract
the I2C and SPI access. However, it fails to ensure that regmap_spi
is actually present:

drivers/iio/built-in.o: In function `afe4403_probe':
:(.text+0x9bf8): undefined reference to `__devm_regmap_init_spi'

This adds a Kconfig select statement like the afe4404 I2C driver
has.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: eec96d1e2d ("iio: health: Add driver for the TI AFE4403 heart monitor")
Acked-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-02-17 19:31:06 +00:00
Andrew F. Davis eec96d1e2d iio: health: Add driver for the TI AFE4403 heart monitor
Add driver for the TI AFE4403 heart rate monitor and pulse oximeter.
This device detects reflected LED light fluctuations and presents an ADC
value to the user space for further signal processing.

Data sheet located here:
http://www.ti.com/product/AFE4403/datasheet

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-02-06 21:55:32 +00:00
Andrew F. Davis 87aec56e27 iio: health: Add driver for the TI AFE4404 heart monitor
Add driver for the TI AFE4404 heart rate monitor and pulse oximeter.
This device detects reflected LED light fluctuations and presents an ADC
value to the user space for further signal processing.

Datasheet: http://www.ti.com/product/AFE4404/datasheet

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-02-06 18:57:09 +00:00