1
0
Fork 0
Commit Graph

117 Commits (1e1b6d63d6340764e00356873e5794225a2a03ea)

Author SHA1 Message Date
Jonathan Cameron f60e8bb842 iio:proximity:mb1232: 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 a 16 byte s16 array 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
ensured by use of an explicit c structure.  This data is allocated
with kzalloc so no data can leak appart from previous readings.

In this case the forced alignment of the ts is necessary to ensure
correct padding on x86_32 where the s64 would only be 4 byte aligned.

Fixes: 16b0526153 ("mb1232.c: add distance iio sensor with i2c")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: <Stable@vger.kernel.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-08-22 11:38:54 +01:00
Alexander A. Klimov 3593cd5396 Replace HTTP links with HTTPS ones: drivers/iio
Rationale:
Reduces attack surface on kernel devs opening the links for MITM
as HTTPS traffic is much harder to manipulate.

Deterministic algorithm:
For each file:
  If not .svg:
    For each line:
      If doesn't contain `\bxmlns\b`:
        For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`:
          If both the HTTP and HTTPS versions
          return 200 OK and serve the same content:
            Replace HTTP with HTTPS.

Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-13 15:05:59 +01:00
Lars-Peter Clausen f11d59d87b iio: Move attach/detach of the poll func to the core
All devices using a triggered buffer need to attach and detach the trigger
to the device in order to properly work. Instead of doing this in each and
every driver by hand move this into the core.

At this point in time, all drivers should have been resolved to
attach/detach the poll-function in the same order.

This patch removes all explicit calls of iio_triggered_buffer_postenable()
& iio_triggered_buffer_predisable() in all drivers, since the core handles
now the pollfunc attach/detach.

The more peculiar change is for the 'at91-sama5d2_adc' driver, since it's
not immediately obvious that removing the hooks doesn't break anything.
Eugen was able to test on at91-sama5d2-adc driver, sama5d2-xplained board.
All seems to be fine.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Tested-by: Eugen Hristev <eugen.hristev@microchip.com> #for at91-sama5d2-adc
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-20 17:34:44 +01:00
Alexandru Ardelean 8f73a13f74 iio: remove left-over parent assignments
These were found by doing some shell magic:
------------
for file in $(git grep -w devm_iio_device_alloc | cut -d: -f1 | sort | uniq) ; do
	if grep 'parent =' $file | grep -v trig | grep -vq devm_; then
		echo "$file -> $(grep "parent =" $file)"
	fi
done
-----------

The output is bearable [after the semantic patch is applied].
There is a mix of trigger assignments with some iio device parent
assignments that are removed via this patch.

JC: A few more added via inspection of all parent =
statements in drivers/iio. Some of these may just have crossed with this
series, others were less obvious to scripting due to some cross
file / module boundary calls.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:50:04 +01:00
Alexandru Ardelean d3be83244c iio: remove explicit IIO device parent assignment
This patch applies the semantic patch:
@@
expression I, P, SP;
@@
   I = devm_iio_device_alloc(P, SP);
   ...
-  I->dev.parent = P;

It updates 302 files and does 307 deletions.
This semantic patch also removes some comments like
'/* Establish that the iio_dev is a child of the i2c device */'

But this is is only done in case where the block is left empty.

The patch does not seem to cover all cases. It looks like in some cases a
different variable is used in some cases to assign the parent, but it
points to the same reference.
In other cases, the block covered by ... may be just too big to be covered
by the semantic patch.

However, this looks pretty good as well, as it does cover a big bulk of the
drivers that should remove the parent assignment.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:49:59 +01:00
Alexandru Ardelean 1ecca8a9a4 iio: proximity: ping: pass reference to IIO device as param to ping_read()
Since there will be some changes to how iio_priv_to_dev() is implemented,
it could be that the helper becomes a bit slower, as it will be hidden away
in the IIO core.

But even without that rework, this looks like it can pass the 'indio_dev'
object to ping_read() and obtain the state struct via iio_priv() which is a
preferred practice than going back-n-forth (getting the state-struct, then
using iio_priv_to_dev() to get the indio_dev object back).

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-05-21 19:39:25 +01:00
Ivan Mikhaylov ac101e6b31 iio: proximity: Add driver support for vcnl3020 proximity sensor
Proximity sensor driver based on light/vcnl4000.c code.
For now supports only the single on-demand measurement.

The VCNL3020 is a fully integrated proximity sensor. Fully
integrated means that the infrared emitter is included in the
package. It has 16-bit resolution. It includes a signal
processing IC and features standard I2C communication
interface. It features an interrupt function.

Datasheet: http://www.vishay.com/docs/84150/vcnl3020.pdf
Signed-off-by: Ivan Mikhaylov <i.mikhaylov@yadro.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-05-21 19:12:42 +01:00
Greg Kroah-Hartman 4e1d96306d First set of new IIO device support, features and cleanup for the 5.8 cycle
Usual mix of new drivers, new support in old drivers and lots of minor
 cleanup. Yaml conversions also continue to trickle in (plenty more to go!)
 
 New device support
 * ad7476
   - Add ad7091 support (ID only)
 * ad9467
   - New driver for this 200/250 MSPS adi-axi-adc and SPI attached ADC.
 * adi-axi-adc
   - New driver to support ADIs generic AXI ADC IP core, used to provide
     high speed interfaces to ADCs (JESD204B/C or parallel interfaces). Usually
     paired with a device using a slow configuration interface (spi etc)
     Includes DT bindings and some fixes for fpga headers.
 * bmg160
   - Add support for BMI088 (ID only)
 * max1241
   - New driver for this ADC.
 * st_sensors
   - Add support for LIS2HH12 accelerometer
 * sx9310
   - New driver supporting sx9310 and sx9311 proximity sensors.
 
 Yaml DT binding conversions
 * rockchip-saradc (including adding some missing parts)
 * stm32-dac
 * tsl2563
 * vcnl4000
 
 Features
 * st_lsm6dsx
   - Add LIS3MDL as a possible sensor hub device.
 * vcnl4000
   - Add new concept of near level (from DT) to provide to userspace which
     often needs to have some calibrated concept of 'near'.
 
 Cleanups, minor fixes etc.
 * core
   - Use snprintf for functions where strings are built and there is
     potential for overflow.
   - Correct docs to indicate mlock should not be used directly by drivers.
   - Fix up accidental dropping of a patch to use bitmap_zalloc.
   - Stop allowing enabling of buffers with no channels enabled.
   - Drop unused 'stufftoread' from iio_buffer.
   - Drop scan_el_attrs form iio_buffer as unused.
   - Reorder sanity checks in __iio_device_register to fail earlier.
   - Drop all the devm_ runregister / free functions from IIO as they
     were never used and encourage poor design.
 * dma-buffer
   - Tidy up includes.
 * dma-engine-buffer
   - Provide dev-managed allocator.
   - Fix an issue with printing a size_t
 * cross subsystem (kxsd9, bmg160, mpu3050, bmi160, mpu6050, bmc150)
   - Replace some unnecessary casts of error ptrs and whilst there.
     use the %pe printf parameter to print them in a more useful fashion.
 * cross subsystem
   - Drop casts in calls to regmap_bulk_read as they make no sense.
   - Use devm_platform_ioremap_resource to reduce boilerplate.
   - Fix typos in Analog Devices.
 * counters/104-quad
   - Add Syed Nayyar Waris as an additional maintainer.
 * ad7476
   - Generate CONVST signal internally rather than requiring external
     trigger.  Add sysfs read back as can now do so.
   - use devm_add_action_or_reset to tidy up error and remove handling.
 * ad7793
   - Switch to read_avail from explicit attribute. Mostly done to avoid
     confusing people with a - sign (without surounding spaces) that
     was correct but checkpatch didn't like.
 * adis library
   - Add missing newlines at end of error messages.
 * adis16400
   - Use DEFINE_DEBUGS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTR.
 * adis16460
   - Use DEFINE_DEBUGS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTR.
 * ad_sigma_delta
   - Move some channel definitions into individual drivers to avoid
     having to deal with complex options.
 * ak8974
   - Silence an error on deffered probe.
 * bmp280
   - Harden against IRQ before registration.
   - Convert to read_avail instead of opencoding the equivalent.
   - Explicitly mark GPIO as optional.
   - Cleanup casts.
   - Remove line breaks from strings.
 * htts221
   - Replace direct access to platform_data with dev_get_platdata().
   - Use device properties rather than device tree ones to allow ACPI
     probing.
   - Casting cleanups.
 * intel_mrfld_adc
   - Don't use unaligned accessor for aligned data.
 * isl29125
   - Reorder buer pre and post hooks to allow for coming core rework.
 * ltc2983
   - Remove comp to bool.
 * max1363
   - Stop using mlock from the iio_dev directly in favour of a local lock
     with clearly defined scope.
 * max30100
   - Use generic device properties to allow ACPI probe.
 * mpu6050
   - Convert to i2c_new_client_device.
   - Add debugfs register access.
 * st_lsm6dsx
   - Provide means of configuring full scale on slave device if supported.
   - Drop include of st_sensors header to get one value. Its not otherwise
     used by this driver.
 * st-sensors
   - Replace direct access to platform_data with dev_get_platdata().
   - Casting cleanups.
   - Avoid splitting strings.
 * st_uvis25
   - Casting cleanups.
 * tsl2563
   - Typo fix.
 * tsl2772
   - scnprintf in a non obvious string building usecase. Note also 'fixes'
     a wrong calculation of remaining space that couldn't actually cause
     any trouble as there was lots of room.
 * xilinx-xadc
   - Fix Lars-Peter spelling his own name wrong :) + additional typos.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAl6gicARHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0Foj3ig//XRAAHRSfzXFpvYxITVKDIGwP/giYdp91
 OflGw/0aOZFExr72ENLmCArXZPOT2qAZyNNoDNvuJ9SkcVDf4bT3w9gYwWtJ1sd7
 Hhh+1JpPspSo6vS85FMjm37UDfSbmYqB6wC57cZ5pKQIiJwi6W2hGsyOoOXmfLLc
 57d3mlg4g3KLl9Hl4UTU84gE1ushKQgNxVH21Y71pOTa8p+xbWWcspWjR2Jf+kVZ
 qPr2+2rP/AjeAVLu9SKfdBiczYQCNR3uFWKkOKsBE9fq3sbcN6NT5DktrSJUH+qU
 zfUGmShCEP908/9fARazXQZcTOX1tIUOnrpHG9l54GNPh3S2Qk9xGaZxvQy5sguC
 AmC4p+MaIMrMcgWMk9po+nE5INJq7HBV/0jnADG307wEhFrKrjh/2PtP4f9k/Mcv
 sHB7K1+dcJAUwFb5gccdDBfmKMnwfnGS8OFGLXZZKBIDqSvptmIs/pmavjEPgqhV
 GwGTDPyZKeyDnyhTXGafxii03Q2I62Zte5l4jcZ+q8Q4UMxQovEkX6IvUpXwA0Kk
 eoxedbgdvzxrDNiNrXa0k6CLzqSQW+aVHgJG+HEig4IXQse8zXb11HCs35zq5r4j
 JI2UjLk3zUHLiNR/Ir9fKAbPwWSWv3IWkfmFEEUWvUFjM+Xot1Hg+61vBTFKo4iK
 EIqqPZmd5Mk=
 =DyTF
 -----END PGP SIGNATURE-----

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

Jonathan writes:

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

Usual mix of new drivers, new support in old drivers and lots of minor
cleanup. Yaml conversions also continue to trickle in (plenty more to go!)

New device support
* ad7476
  - Add ad7091 support (ID only)
* ad9467
  - New driver for this 200/250 MSPS adi-axi-adc and SPI attached ADC.
* adi-axi-adc
  - New driver to support ADIs generic AXI ADC IP core, used to provide
    high speed interfaces to ADCs (JESD204B/C or parallel interfaces). Usually
    paired with a device using a slow configuration interface (spi etc)
    Includes DT bindings and some fixes for fpga headers.
* bmg160
  - Add support for BMI088 (ID only)
* max1241
  - New driver for this ADC.
* st_sensors
  - Add support for LIS2HH12 accelerometer
* sx9310
  - New driver supporting sx9310 and sx9311 proximity sensors.

Yaml DT binding conversions
* rockchip-saradc (including adding some missing parts)
* stm32-dac
* tsl2563
* vcnl4000

Features
* st_lsm6dsx
  - Add LIS3MDL as a possible sensor hub device.
* vcnl4000
  - Add new concept of near level (from DT) to provide to userspace which
    often needs to have some calibrated concept of 'near'.

Cleanups, minor fixes etc.
* core
  - Use snprintf for functions where strings are built and there is
    potential for overflow.
  - Correct docs to indicate mlock should not be used directly by drivers.
  - Fix up accidental dropping of a patch to use bitmap_zalloc.
  - Stop allowing enabling of buffers with no channels enabled.
  - Drop unused 'stufftoread' from iio_buffer.
  - Drop scan_el_attrs form iio_buffer as unused.
  - Reorder sanity checks in __iio_device_register to fail earlier.
  - Drop all the devm_ runregister / free functions from IIO as they
    were never used and encourage poor design.
* dma-buffer
  - Tidy up includes.
* dma-engine-buffer
  - Provide dev-managed allocator.
  - Fix an issue with printing a size_t
* cross subsystem (kxsd9, bmg160, mpu3050, bmi160, mpu6050, bmc150)
  - Replace some unnecessary casts of error ptrs and whilst there.
    use the %pe printf parameter to print them in a more useful fashion.
* cross subsystem
  - Drop casts in calls to regmap_bulk_read as they make no sense.
  - Use devm_platform_ioremap_resource to reduce boilerplate.
  - Fix typos in Analog Devices.
* counters/104-quad
  - Add Syed Nayyar Waris as an additional maintainer.
* ad7476
  - Generate CONVST signal internally rather than requiring external
    trigger.  Add sysfs read back as can now do so.
  - use devm_add_action_or_reset to tidy up error and remove handling.
* ad7793
  - Switch to read_avail from explicit attribute. Mostly done to avoid
    confusing people with a - sign (without surounding spaces) that
    was correct but checkpatch didn't like.
* adis library
  - Add missing newlines at end of error messages.
* adis16400
  - Use DEFINE_DEBUGS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTR.
* adis16460
  - Use DEFINE_DEBUGS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTR.
* ad_sigma_delta
  - Move some channel definitions into individual drivers to avoid
    having to deal with complex options.
* ak8974
  - Silence an error on deffered probe.
* bmp280
  - Harden against IRQ before registration.
  - Convert to read_avail instead of opencoding the equivalent.
  - Explicitly mark GPIO as optional.
  - Cleanup casts.
  - Remove line breaks from strings.
* htts221
  - Replace direct access to platform_data with dev_get_platdata().
  - Use device properties rather than device tree ones to allow ACPI
    probing.
  - Casting cleanups.
* intel_mrfld_adc
  - Don't use unaligned accessor for aligned data.
* isl29125
  - Reorder buer pre and post hooks to allow for coming core rework.
* ltc2983
  - Remove comp to bool.
* max1363
  - Stop using mlock from the iio_dev directly in favour of a local lock
    with clearly defined scope.
* max30100
  - Use generic device properties to allow ACPI probe.
* mpu6050
  - Convert to i2c_new_client_device.
  - Add debugfs register access.
* st_lsm6dsx
  - Provide means of configuring full scale on slave device if supported.
  - Drop include of st_sensors header to get one value. Its not otherwise
    used by this driver.
* st-sensors
  - Replace direct access to platform_data with dev_get_platdata().
  - Casting cleanups.
  - Avoid splitting strings.
* st_uvis25
  - Casting cleanups.
* tsl2563
  - Typo fix.
* tsl2772
  - scnprintf in a non obvious string building usecase. Note also 'fixes'
    a wrong calculation of remaining space that couldn't actually cause
    any trouble as there was lots of room.
* xilinx-xadc
  - Fix Lars-Peter spelling his own name wrong :) + additional typos.

* tag 'iio-for-5.8a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (101 commits)
  iio: magnetometer: ak8974: Silence deferred-probe error
  Documentation: ABI: document IIO in_proximity_nearlevel file
  iio: vcnl4000: Export near level property for proximity sensor
  dt-bindings: iio: light: vcnl4000: Add proximity-near-level
  dt-bindings: iio: Introduce common properties for iio sensors
  dt-bindings: iio: vcnl4000: convert bindings to YAML format
  iio: Fix misspellings of "Analog Devices"
  iio: light: isl29125: fix iio_triggered_buffer_{predisable,postenable} positions
  iio: adc: fsl-imx25-gcq: Use devm_platform_ioremap_resource
  iio: adc: at91-adc: Use devm_platform_ioremap_resource
  iio: adc: sun4i-gpadc-iio: Use devm_platform_ioremap_resource
  iio:light:ltr501: Drop unnecessary cast of parameter in regmap_bulk_read
  iio:magn:mmc35240: Drop unnecessary casts of val parameter in regmap_bulk*
  iio:imu:mpu6050: Tidy up parameters to regmap_bulk functions.
  iio:chemical:bme680: Tidy up parameters to regmap_bulk_read
  iio:chemical:atlas-sensor: Drop unnecessary explicit casts in regmap_bulk_read calls
  iio:accel:mxc4005: Drop unnecessary explicit casts in regmap_bulk_read calls
  iio: imu: st_lsm6dsx: drop huge include in sensor-hub driver
  iio: buffer: drop devm_iio_kfifo_free() API call
  iio: buffer: drop devm_iio_hw_consumer_free() API call
  ...
2020-04-23 11:06:48 +02:00
Greg Kroah-Hartman 6203da9803 Merge 5.6-rc7 into staging-next
We need the staging/iio fixes in here as well

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-23 08:01:20 +01:00
Daniel Campello 72ad02b15d iio: Add SEMTECH SX9310/9311 sensor driver
Add SEMTECH SX9310/9311 driver.

The device has the following entry points:

Usual frequency:
- sampling_frequency
- sampling_frequency_available

Instant reading of current values for different sensors:
- in_proximity0_raw
- in_proximity1_raw
- in_proximity2_raw
- in_proximity3_comb_raw
and associated events in events/

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Signed-off-by: Enrico Granata <egranata@chromium.org>
Signed-off-by: Daniel Campello <campello@chromium.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-21 10:28:20 +00:00
YueHaibing 10856d88f7 iio: ping: set pa_laser_ping_cfg in of_ping_match
pa_laser_ping_cfg should be set in of_ping_match
instead of pa_ping_cfg.

Fixes: 7bb501f49d ("iio: ping: add parallax ping sensors")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 16:21:23 +00:00
Andreas Klinger 2251157b33 iio: srf04: add power management feature
Add suspend and resume operations for being used by optional power
management.

The suspend function is switching off an GPIO which can be used by the
hardware to switch power off. The resume function is switching the GPIO
on and sleeps an adjustable time to give the device a chance to be up
and running.

If activated the driver gets into autosuspend after some time of
inactivity.

Suggested-by: Franz Parzer <rpi-receiver@htl-steyr.ac.at>
Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-02-14 12:08:23 +00:00
Linus Walleij b4cc7e83df iio: as3935: Drop GPIO includes
The driver includes <linux/gpio.h> and <linux/of_gpio.h> yet
fails to use symbols from any of the include files, so drop
these includes.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-15 11:42:15 +00:00
Andreas Klinger 7bb501f49d iio: ping: add parallax ping sensors
Add support for parallax ping and laser ping sensors with just one pin
for trigger and echo signal.

This driver is based on srf04. In contrast to it it's necessary to
change direction of the pin and to request the irq just for the period
when the echo is rising and falling. Because this adds a lot of cases
there is this individual driver for handling this type of sensors.

Add a new configuration variable CONFIG_PING to Kconfig and Makefile.

Julia reported an issue with failing to unlock a mutex in some error
paths.

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-01 10:23:04 +00:00
Greg Kroah-Hartman f0cb9b5dfd Merge 5.4-rc7 into staging-next
We want the staging fixes in here, and it resolves some merge issues.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-11-11 06:23:37 +01:00
Jonathan Cameron d2080a87a3 iio: proximity: pulsedlight v2: Tidy up an endian issue
Sparse identified the following
CHECK   drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c:144:24: warning: cast to restricted __be16
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c:144:24: warning: cast to restricted __be16
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c:144:24: warning: cast to restricted __be16
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c:144:24: warning: cast to restricted __be16

This cleans up by adding a local variable to hold the value whilst
it is __be16 before applying endian converstion into eventual destination.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
2019-10-18 19:57:47 +01:00
Andreas Klinger 431f7667bd iio: srf04: fix wrong limitation in distance measuring
The measured time value in the driver is limited to the maximum distance
which can be read by the sensor. This limitation was wrong and is fixed
by this patch.

It also takes into account that we are supporting a variety of sensors
today and that the recently added sensors have a higher maximum
distance range.

Changes in v2:
- Added a Tested-by

Suggested-by: Zbyněk Kocur <zbynek.kocur@fel.cvut.cz>
Tested-by: Zbyněk Kocur <zbynek.kocur@fel.cvut.cz>
Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Cc:<Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-12 14:31:09 +01:00
Alexandru Ardelean 3cfd6464fe iio: proximity: sx9500: fix iio_triggered_buffer_{predisable,postenable} positions
The iio_triggered_buffer_predisable() should be called last, to detach the
poll func after the devices has been suspended.

This change re-organizes things a bit so that the postenable & predisable
are symmetrical. It also converts the preenable() to a postenable().

Not stable material as there is no known problem with the current
code, it's just not consistent with the form we would like all the
IIO drivers to adopt so as to allow subsystem wide changes.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-07 21:31:19 +01:00
Christophe JAILLET 4a5e353c16 Kconfig: Fix the reference to the RFD77402 ToF sensor in the 'help' section
This should be RFD77402, not RFD77420.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-08-25 19:08:36 +01:00
Thomas Gleixner d2912cb15b treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500
Based on 2 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 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 #

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Enrico Weigelt <info@metux.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-19 17:09:55 +02:00
Thomas Gleixner 36edc93958 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 330
Based on 1 normalized pattern(s):

  this file is subject to the terms and conditions of version 2 of the
  gnu general public license see the file copying in the main
  directory of this archive 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 55 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190530000436.108941081@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-05 17:37:06 +02: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
Andreas Klinger 21cf20a84a Kconfig: change configuration of srf04 ultrasonic iio sensor
reword configuration option for SRF04

list supported types in help text

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-14 14:08:48 +01:00
Andreas Klinger bb208037ae srf04.c: add maxbotix ultrasonic sensors
add Maxbotix LV ultrasonic sensor types mb1000, mb1010, mb1020, mb1030
and mb1040

add a configuration struct with the different trigger pulse lengths

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-14 14:05:31 +01:00
Andreas Klinger 16b0526153 mb1232.c: add distance iio sensor with i2c
Add I2CXL-MaxSonar ultrasonic distance sensors of types mb1202, mb1212,
mb1222, mb1232, mb1242, mb7040, mb7137 using an i2c interface

Implemented functionality:
- reading the distance via in_distance_raw
- buffered mode with trigger
- make use of interrupt to announce completion of ranging

Add mb1232 driver to Kconfig and Makefile

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04 20:20:17 +01:00
Sven Van Asbroeck 11362b7a43 iio: proximity: as3935: fix use-after-free on device remove
This driver's probe() uses a mix of devm_ and non-devm_ functions. This
means that the remove order will not be the exact opposite of the probe
order.

Remove order:
1. remove() executes:
	iio_device_unregister
	iio_triggered_buffer_cleanup
	iio_trigger_unregister
	(A)
2. core frees devm resources in reverse order:
	free_irq
	iio_trigger_free
	iio_device_free

In (A) the trigger has been unregistered, but the irq handler is still
registered and active, so the trigger may still be touched via
interrupt -> as3935_event_work. This is a potential use-after-unregister.

Given that the delayed work is never canceled explicitly, it may run even
after iio_device_free. This is a potential use-after-free.

Solution: convert all probe functions to their devm_ equivalents.
Add a devm callback, called by the core on remove right after irq_free,
which explicitly cancels the delayed work. This will guarantee that all
resources are freed in the correct order.

As an added bonus, some boilerplate code can be removed.

Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04 20:19:56 +01:00
Song Qiang 6eb17c6c8a iio: proximity: Add driver support for ST's VL53L0X ToF ranging sensor.
This driver was originally written by ST in 2016 as a misc input device
driver, and hasn't been maintained for a long time. I grabbed some code
from it's API and reformed it into an iio proximity device driver.
This version of driver uses i2c bus to talk to the sensor and
polling for measuring completes, so no irq line is needed.
It can be tested with reading from
/sys/bus/iio/devices/iio:deviceX/in_distance_input

Signed-off-by: Song Qiang <songqiang1304521@gmail.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-09-22 16:42:56 +01:00
Geert Uytterhoeven 24493cce03 iio: light: isl29501: Simplify code to kill compiler warning
With gcc 4.1.2:

    drivers/iio/proximity/isl29501.c: In function ‘isl29501_register_write’:
    drivers/iio/proximity/isl29501.c:235: warning: ‘msb’ may be used uninitialized in this function

While this is a false positive, it can easily be avoided by removing the
"msb" intermediate variable.
Remove the "lsb" intermediate variable for consistency.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-09-02 09:56:49 +01:00
Mathieu Othacehe 1c28799257 iio: light: isl29501: Add support for the ISL29501 ToF sensor.
This patch adds support for the ISL29501 Time of Flight sensor.

Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-07-23 19:18:10 +01:00
Greg Kroah-Hartman 6761f0ac66 Second set of new device support, features and cleanup for IIO in the 4.17 cycle
The uptick in staging cleanup is partly due to GSoC Applications
 process being underway and one of Daniel's tasks being to try
 cleaning up an IIO driver to move out of staging.
 Naturally there is some normal staging cleanup progress in here
 as well.
 
 New device support
 * Microchip mcp4018
   - New driver supproting MCP4017, MCP4018 and MCP4019 digital pots.
 * On Semiconductor lv0104cs
   - New driver to support this ambient light sensor.
 
 Cleanup
 * axp20x_adc
   - remove a !! in favour of clear ternary operator.
 * ad2s1210 (staging cleanup)
   - Reorganise to avoid ending a line with [
   - Remove some unnecessary defines.
   - Remove unsed variable.
 * ad5380
   - Replace magic 0 with IIO_CHAN_INFO_RAW
 * ad5764
   - Replace magic 0 with IIO_CHA_INFO_RAW
 * ad7150 (staging cleanup)
   - Align arguements with parenthesis.
 * ad7152 (staging cleanup)
   - Align arguements.
 * ad7746 (staging cleanup)
   - Align arguements.
 * ad7816
   - Remove pointless void pointer cast.
 * ade7753
   - Replace IIO_DEV_ATTR_CH_OFF with equivalent to avoid confusing
     checkpatch (this macro didn't really help anyway).  Also drop the
     macro from the meter.h header.
 * ade7754 (staging cleanup)
   - Add names to funciton definition arguements.
   - Align arguements with open parenthesis where possible.
 * ade7758 (staging cleanup)
   - Remove __func__ from dev_dbg statements as provided by dynamic
     debug anyway.
   - Align arguements with open parenthesis where possible.
 * ade7759 (staging cleanup)
   - Replace IIO_DEV_ATTR_CH_OFF with equiavalent to avoid confusing
     checkpatch.
 * adis16201 (staging cleanup)
   - Headers in alphabetical order.
   - Blank lines before returns.
 * adis16209 (staging cleanup)
   - Headers in alphabetical order
   - Change some definition names to make them more meaningful (2 rounds
     of this).
   - Add explicit _REG prefix to register names to make them
     obviously different from fields within those registers.
   - Remove some superflous comments and group definitions better.
   - Use a switch statement to make it semantically obvious that we
     only have two options (rather than an unlimited 'else').
   - Use sign_extent32 instead of open coding.
 * adt7316 (staging cleanup)
   - Move an export next to symbol.
 * bmc150
   - drop redundant __func__ in dynamic debug.
 * ccs811
   - Rename varaible to better reflect what it does.
 * cros_ec
   - Reduce sampling frequency before suspending to avoid preventing
     suspend.
 * dummy
   - Correct whitespace in Kconfig.
   - Add extra description in Kconfig.
 * ds1803
   - Remove a VLA which we always know is 2 long.
 * hid-sensor-accel
   - Replace magic number 0 by IIO_CHAN_INFO_RAW.
 * hid-sensor-gyro
   - Replace magic number 0 by IIO_CHAN_INFO_RAW.
 * hid-sensor-light
   - Replace magic number 0 by IIO_CHAN_INFO_RAW.
 * hid-sensor-magn
   - Replace magic number 0 by IIO_CHAN_INFO_RAW.
 * lm3533
   - Replace magic number 0 by IIO_CHAN_INFO_RAW
 * mlx90632
   - Squash a smatch warning - no runtime effect.
 * stm32_dfsdm:
   - Cleanup the dt bindings.
 * sx9500
   - Add GPIO ACPI mapping table to behave correctly when firmware
     doesn't provide the mapping.
 * tsl2x7x (staging cleanup)
   - Fix the proximity sensor functionality.
   - Remove platform data provided power functions.  There are much
     better ways to do this these days.
   - Introduce some common functions to avoid various repititions.
   - Stop using mutex_trylock when mutex_lock and wait a bit is fine.
   - Improve error handling in various places.
   - Drop some 'Camel case' (which wasn't actually strickly camel case
     but was a bit odd.
   - Drop some _available sysfs attributes for things that don't exist
     (for particular supported parts).
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAlqlObQRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FoissQ/+IQjcyxNdtOhHagvRgZ5z+6GYj6JzIX8s
 Qqnep34sc6yUaygbJBXdcBQ5qdnPjrTk2CD3VYANOdC1bqXa80yuTGCGN6lBIBEr
 /qBso6UbUiobA1PXektUj7Qel5HfVfYCyQ4NssSwKbdza6pyqoZA+iPzwiztWAwE
 JsU5EdsTVxB/39kMOnoQJM6l5Lc5Ljg5pS3Du++3U49neiDk1Z/+VXsimFSPK3zt
 FrSmMehNRYr0iFPwi7IZf8beG5ixmpRyY+KZzdM45Gm4hrpgE9ZIMd7A8B+ypx5N
 WM1HJxu3PC6xHc7DIbcJG82sQ9DDrIeCkN4wN29ESE0JUt/GPvySSFZRAhsVp+xO
 8rObv0r9Va+ones5WhZeAx/x3FowommZ2Jn+0FpX5H0X0mgi34au4YiOOAhg2gz5
 9fnj39k7WarYozn1VVY8D8copO6C7j/UQVup/qfjmufkc7bDrQMml3rBWZbNxSUC
 0TfZZJ9k+bxw2fvIedrjU/CFYbJJSpkRF/Sm3TZW28OMpxt/3qmAECtREOXVLyl2
 cJnJpw8ERWbyeHJxhULurc2ekJVFeOS1sZ+sWU7P0LFt+J3dkOgZP1GJpXXhCWQa
 GmgIm7vYYtAsVjDZ+FwH4ir/wSUeufscFEHs1oVhmIRh7jRCaJWycgLKZcK+rVRK
 docrwE4wGrk=
 =6eOr
 -----END PGP SIGNATURE-----

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

Jonathan writes:

Second set of new device support, features and cleanup for IIO in the 4.17 cycle

The uptick in staging cleanup is partly due to GSoC Applications
process being underway and one of Daniel's tasks being to try
cleaning up an IIO driver to move out of staging.
Naturally there is some normal staging cleanup progress in here
as well.

New device support
* Microchip mcp4018
  - New driver supproting MCP4017, MCP4018 and MCP4019 digital pots.
* On Semiconductor lv0104cs
  - New driver to support this ambient light sensor.

Cleanup
* axp20x_adc
  - remove a !! in favour of clear ternary operator.
* ad2s1210 (staging cleanup)
  - Reorganise to avoid ending a line with [
  - Remove some unnecessary defines.
  - Remove unsed variable.
* ad5380
  - Replace magic 0 with IIO_CHAN_INFO_RAW
* ad5764
  - Replace magic 0 with IIO_CHA_INFO_RAW
* ad7150 (staging cleanup)
  - Align arguements with parenthesis.
* ad7152 (staging cleanup)
  - Align arguements.
* ad7746 (staging cleanup)
  - Align arguements.
* ad7816
  - Remove pointless void pointer cast.
* ade7753
  - Replace IIO_DEV_ATTR_CH_OFF with equivalent to avoid confusing
    checkpatch (this macro didn't really help anyway).  Also drop the
    macro from the meter.h header.
* ade7754 (staging cleanup)
  - Add names to funciton definition arguements.
  - Align arguements with open parenthesis where possible.
* ade7758 (staging cleanup)
  - Remove __func__ from dev_dbg statements as provided by dynamic
    debug anyway.
  - Align arguements with open parenthesis where possible.
* ade7759 (staging cleanup)
  - Replace IIO_DEV_ATTR_CH_OFF with equiavalent to avoid confusing
    checkpatch.
* adis16201 (staging cleanup)
  - Headers in alphabetical order.
  - Blank lines before returns.
* adis16209 (staging cleanup)
  - Headers in alphabetical order
  - Change some definition names to make them more meaningful (2 rounds
    of this).
  - Add explicit _REG prefix to register names to make them
    obviously different from fields within those registers.
  - Remove some superflous comments and group definitions better.
  - Use a switch statement to make it semantically obvious that we
    only have two options (rather than an unlimited 'else').
  - Use sign_extent32 instead of open coding.
* adt7316 (staging cleanup)
  - Move an export next to symbol.
* bmc150
  - drop redundant __func__ in dynamic debug.
* ccs811
  - Rename varaible to better reflect what it does.
* cros_ec
  - Reduce sampling frequency before suspending to avoid preventing
    suspend.
* dummy
  - Correct whitespace in Kconfig.
  - Add extra description in Kconfig.
* ds1803
  - Remove a VLA which we always know is 2 long.
* hid-sensor-accel
  - Replace magic number 0 by IIO_CHAN_INFO_RAW.
* hid-sensor-gyro
  - Replace magic number 0 by IIO_CHAN_INFO_RAW.
* hid-sensor-light
  - Replace magic number 0 by IIO_CHAN_INFO_RAW.
* hid-sensor-magn
  - Replace magic number 0 by IIO_CHAN_INFO_RAW.
* lm3533
  - Replace magic number 0 by IIO_CHAN_INFO_RAW
* mlx90632
  - Squash a smatch warning - no runtime effect.
* stm32_dfsdm:
  - Cleanup the dt bindings.
* sx9500
  - Add GPIO ACPI mapping table to behave correctly when firmware
    doesn't provide the mapping.
* tsl2x7x (staging cleanup)
  - Fix the proximity sensor functionality.
  - Remove platform data provided power functions.  There are much
    better ways to do this these days.
  - Introduce some common functions to avoid various repititions.
  - Stop using mutex_trylock when mutex_lock and wait a bit is fine.
  - Improve error handling in various places.
  - Drop some 'Camel case' (which wasn't actually strickly camel case
    but was a bit odd.
  - Drop some _available sysfs attributes for things that don't exist
    (for particular supported parts).
2018-03-14 12:32:11 +01:00
Andy Shevchenko b61d8e630a iio: proximity: sx9500: Add GPIO ACPI mapping table
In order to satisfy GPIO ACPI library requirements convert users of
gpiod_get_index() to correctly behave when there no mapping is provided
by firmware.

Here we add explicit mapping between _CRS GpioIo() resources and
their names used in the driver.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-03 15:11:27 +00:00
Greg Kroah-Hartman 36e9f7203e Merge 4.16-rc3 into staging-next
We want the IIO/Staging fixes in here, and to resolve a merge problem
with the move of the fsl-mc code.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-26 15:32:00 +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
Andreas Klinger 511051d509 iio: srf08: fix link error "devm_iio_triggered_buffer_setup" undefined
Functions for triggered buffer support are needed by this module.
If they are not defined accidentally by another driver, there's an error
thrown out while linking.

Add a select of IIO_BUFFER and IIO_TRIGGERED_BUFFER in the Kconfig file.

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Fixes: a831959371 ("iio: srf08: add triggered buffer support")
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-02-04 11:13:00 +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
Andy Shevchenko e53111ad5d iio: proximity: sx9500: Assign interrupt from GpioIo()
The commit 0f0796509c

("iio: remove gpio interrupt probing from drivers that use a single interrupt")

removed custom IRQ assignment for the drivers which are enumerated via
ACPI or OF. Unfortunately, some ACPI tables have IRQ line defined as
GpioIo() resource and thus automatic IRQ allocation will fail.

Partially revert the commit 0f0796509c to restore original behaviour.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 11:15:13 +00:00
Andy Shevchenko b87935552e iio: proximity: sx9500: Add another ACPI ID
Add new ACPI ID for sx9500 as had been found on prototype board.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-12-02 10:40:00 +00:00
Linus Torvalds 449fcf3ab0 Staging/IIO patches for 4.15-rc1
Here is the "big" staging and IIO driver update for 4.15-rc1.
 
 Lots and lots of little changes, almost all minor code cleanups as the
 Outreachy application process happened during this development cycle.
 Also happened was a lot of IIO driver activity, and the typec USB code
 moving out of staging to drivers/usb (same commits are in the USB tree
 on a persistent branch to not cause merge issues.)
 
 Overall, it's a wash, I think we added a few hundred more lines than
 removed, but really only a few thousand were modified at all.
 
 All of these have been in linux-next for a while.  There might be a
 merge issue with Al's vfs tree in the pi433 driver (take his changes,
 they are always better), and the media tree with some of the odd atomisp
 cleanups (take the media tree's version).
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWgnFrg8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ymxbwCgtNlBkqD2JJYpLRKvI/C4w1vzZsEAnA2THRkt
 g3ioPBqmqC/2DSbldr2o
 =/ebw
 -----END PGP SIGNATURE-----

Merge tag 'staging-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging and IIO updates from Greg KH:
 "Here is the "big" staging and IIO driver update for 4.15-rc1.

  Lots and lots of little changes, almost all minor code cleanups as the
  Outreachy application process happened during this development cycle.
  Also happened was a lot of IIO driver activity, and the typec USB code
  moving out of staging to drivers/usb (same commits are in the USB tree
  on a persistent branch to not cause merge issues.)

  Overall, it's a wash, I think we added a few hundred more lines than
  removed, but really only a few thousand were modified at all.

  All of these have been in linux-next for a while. There might be a
  merge issue with Al's vfs tree in the pi433 driver (take his changes,
  they are always better), and the media tree with some of the odd
  atomisp cleanups (take the media tree's version)"

* tag 'staging-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (507 commits)
  staging: lustre: add SPDX identifiers to all lustre files
  staging: greybus: Remove redundant license text
  staging: greybus: add SPDX identifiers to all greybus driver files
  staging: ccree: simplify ioread/iowrite
  staging: ccree: simplify registers access
  staging: ccree: simplify error handling logic
  staging: ccree: remove dead code
  staging: ccree: handle limiting of DMA masks
  staging: ccree: copy IV to DMAable memory
  staging: fbtft: remove redundant initialization of buf
  staging: sm750fb: Fix parameter mistake in poke32
  staging: wilc1000: Fix bssid buffer offset in Txq
  staging: fbtft: fb_ssd1331: fix mirrored display
  staging: android: Fix checkpatch.pl error
  staging: greybus: loopback: convert loopback to use generic async operations
  staging: greybus: operation: add private data with get/set accessors
  staging: greybus: loopback: Fix iteration count on async path
  staging: greybus: loopback: Hold per-connection mutex across operations
  staging: greybus/loopback: use ktime_get() for time intervals
  staging: fsl-dpaa2/eth: Extra headroom in RX buffers
  ...
2017-11-13 20:53:28 -08:00
Greg Kroah-Hartman b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.

By default all files without license information are under the default
license of the kernel, which is GPL version 2.

Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier.  The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.

This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.

How this work was done:

Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
 - file had no licensing information it it.
 - file was a */uapi/* one with no licensing information in it,
 - file was a */uapi/* one with existing licensing information,

Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.

The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne.  Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.

The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed.  Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.

Criteria used to select files for SPDX license identifier tagging was:
 - Files considered eligible had to be source code files.
 - Make and config files were included as candidates if they contained >5
   lines of source
 - File already had some variant of a license header in it (even if <5
   lines).

All documentation files were explicitly excluded.

The following heuristics were used to determine which SPDX license
identifiers to apply.

 - when both scanners couldn't find any license traces, file was
   considered to have no license information in it, and the top level
   COPYING file license applied.

   For non */uapi/* files that summary was:

   SPDX license identifier                            # files
   ---------------------------------------------------|-------
   GPL-2.0                                              11139

   and resulted in the first patch in this series.

   If that file was a */uapi/* path one, it was "GPL-2.0 WITH
   Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:

   SPDX license identifier                            # files
   ---------------------------------------------------|-------
   GPL-2.0 WITH Linux-syscall-note                        930

   and resulted in the second patch in this series.

 - if a file had some form of licensing information in it, and was one
   of the */uapi/* ones, it was denoted with the Linux-syscall-note if
   any GPL family license was found in the file or had no licensing in
   it (per prior point).  Results summary:

   SPDX license identifier                            # files
   ---------------------------------------------------|------
   GPL-2.0 WITH Linux-syscall-note                       270
   GPL-2.0+ WITH Linux-syscall-note                      169
   ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
   ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
   LGPL-2.1+ WITH Linux-syscall-note                      15
   GPL-1.0+ WITH Linux-syscall-note                       14
   ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
   LGPL-2.0+ WITH Linux-syscall-note                       4
   LGPL-2.1 WITH Linux-syscall-note                        3
   ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
   ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1

   and that resulted in the third patch in this series.

 - when the two scanners agreed on the detected license(s), that became
   the concluded license(s).

 - when there was disagreement between the two scanners (one detected a
   license but the other didn't, or they both detected different
   licenses) a manual inspection of the file occurred.

 - In most cases a manual inspection of the information in the file
   resulted in a clear resolution of the license that should apply (and
   which scanner probably needed to revisit its heuristics).

 - When it was not immediately clear, the license identifier was
   confirmed with lawyers working with the Linux Foundation.

 - If there was any question as to the appropriate license identifier,
   the file was flagged for further research and to be revisited later
   in time.

In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.

Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights.  The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.

Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.

In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.

Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
 - a full scancode scan run, collecting the matched texts, detected
   license ids and scores
 - reviewing anything where there was a license detected (about 500+
   files) to ensure that the applied SPDX license was correct
 - reviewing anything where there was no detection but the patch license
   was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
   SPDX license was correct

This produced a worksheet with 20 files needing minor correction.  This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.

These .csv files were then reviewed by Greg.  Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected.  This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.)  Finally Greg ran the script using the .csv files to
generate the patches.

Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-02 11:10:55 +01:00
Greg Kroah-Hartman 7706abf5a0 Merge 4.14-rc6 into staging-next
We want the IIO and staging driver fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-23 14:29:43 +02:00
Peter Meerwald-Stadler 79e6418866 iio: proximity: Add rfd77402 driver
Driver for RF Digital RFD77402 VCSEL (vertical-cavity surface-emitting
laser) Time-of-Flight (ToF) sensor to measure distance up to 2 m with
millimeter precision

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-10-14 18:28:51 +01:00
Matt Ranostay eb35279dd7 iio: proximity: as3935: noise detection + threshold changes
Most applications are too noisy to allow the default noise and
watchdog settings, and thus need to be configurable via DT
properties.

Also default settings to POR defaults on a reset, and register
distuber interrupts as noise since it prevents proper usage.

Cc: devicetree@vger.kernel.org
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-25 19:49:21 +01:00
Jonathan Cameron a62e256b14 iio:proximity: 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 22:14:51 +01:00
Andreas Klinger dc2696ba46 iio: srf08: add support for srf02 in i2c mode
srf02 added with support for i2c interface

Attributes for setting max range or sensitivity are omitted for the case of
srf02 type sensor, because they are not supported by the hardware.

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-08-18 08:04:17 +01:00
Andreas Klinger c5bf4a0446 iio: srf08: add sensor type srf10
Ultrasonic sensor srf10 is quite similar to srf08 and now also supported by
the driver as device tree compatible string.

It was necessary to prepare the source for supplementary sensors. This is
done by enum srf08_sensor_type.

The most significiant difference between srf08 and srf10 is another range
and values of register gain (in the driver it's call sensitivity).
Therefore the array of it is extended and dependent of the sensor type.

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-08-18 08:01:58 +01:00
Andreas Klinger a831959371 iio: srf08: add triggered buffer support
Add support for triggered buffers.

Data format is quite simple:
  distance     16 Bit
  alignment    48 Bit
  timestamp    64 Bit

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-08-18 08:00:17 +01:00
Andreas Klinger c02b3a113d iio: srf08: add device tree table
Added MODULE_DEVICE_TABLE for device tree bindings.

It used to work without it by using the i2c_device_id table, but adding the
table makes everything clear and documented.

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-08-18 07:59:07 +01:00
Greg Kroah-Hartman dd36a2d9ad Second set of IIO new device support, features and cleanups for the 4.13 cycle.
A few reverts here. One was a general failure to notice a device was already
 supported by another driver.  The second is due to a review comment pointing
 out that the original patch was a bad idea and would break existing systems.
 
 Reverts
 * bma180
   - Revert addition of support for the BMA250E it is already supported by
     the bmc150-accel and better supported at that. Oops.
 * hi8435
   - The fix for cleanup of the reset gpio stuff isn't a good way to go.  It
     breaks systems where an inverting level convertor is used.  The right fix
     is to make the original devicetree correct - even if it involves patching
     the devicetree in kernel.
 
 New Device Support
 * stm32-adc
   - STM32H7 support and bindings.
 
 Features
 * core
   - add a hardware triggered operating mode for systems in which the actual
     trigger is never seen by the kernel.  This is typically only used when
     a device 'can' use other triggers, but if a particular magic one is
     enabled the interrupt is effectively handled in hardware and we never see
     it.
 * st-lsm6dsx
   - support active low interrupts.
 * stm32-adc
   - Make the core adc clock optional as not all hardware supported requires it.
   - Make the bus clock optional in the per instance driver as it may be shared
     by all instances of the ADC and is handled by the core.
   - Rework to have a data structure representing the device type specific
     elements.
 * stm32-trigger (and counter)
   - Use the INDIO_HARDWARE_TRIGGERED_MODE where appropriate.
   - Add an attribute to configure device modes for quadrature counting etc.
 
 Clean ups and minor fixes
 * IIO core.
   - use __sysfs_match_string() helper rather than open coding the same.
 * ad7791
   - use sysfs_match_string() helper rather than open coding the same.
 * aspeed-adc
   - handle return value of clk_prepare_enable
 * cpcap
   - Fix default register values and ensure the battery thermistor is enabled
     correctly.
   - Fix the reported die temperature where we can - docs are lacking.
   - Remove the hung interrupt quirk as no longer happens due to fix in the
     mfd driver.
 * hi8435
   - Remove &s from hi8435_info definition as unneeded and inconsistent.
 * hid-sensor-trgger
   - Add kconfig depends on IIO_BUFFER (fixes patch in previous series)
 * ina2xx
   - Make the use of iio_info_mask* elements consistent for all channels.
     This doesn't have any visible effect, but acts as clear documentation of
     which channels various resulting attributes apply to.
 * lpc32xx
   - handle the return value of clk_prepare_enable.
 * meson-saradc
   - NULL instead of 0 for pointer.
 * mma9551
   - use NULL for GPIO connection ID to aid implementation fo ACPI support.
     Here the connection ID doesn't actually tell us anything and it is much
     easier to deal with the driver if it's not there.
 * mpu6050
   - Fix lock issues through use of a local mux.
   - Replace sprintf with scnprintf as appropriate.
   - Check whoami against all known values.  This allows for a small number of
     boards where we are really fishing for the part not being present at all.
     It is unfortunately common to have undescribed changes to use newer chips.
     We paper over this but just emitting a warning for those cases as long as
     we know about.
 * mxs-lradc
   - Fix some non static warnings.
 * rcar-adc
   - Part of making the naming for this part consistent across the kernel.
 * st_accel
   - drop some spi_device_id entries for variants with no SPI support
 * st_magn
   - drop some spi_device_id entries for variants with no SPI support.
 * sx9500
   - Use devm_gpiod_get instead of indexed value with an index of 0 on all
     occasions.
 * twl4030
   - Drop unused twl4030_get_madc_conversion as callers removed now throughout
     kernel.
   - Unexport twl4030_madc_conversion() as no used only within this driver.
   - Drop twl4030_madc_user_params as not used now.
   - Drop twl4030_madc_request.func_cb as not used now.
   - Fold the twl4030-madc.h header into the driver as no longer used anywhere
     else in the kernel.
 * xilinx
   - Handle the return value of clk_prepare_enable
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAllJSCURHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FogTTQ//bbAzHKB0qTwusFN5jrz1JqjGj3+bMXH/
 KumP4nj7NzwKBe4tDe40FsdkZ4c+Um8pK2Aj7iJZojwTcCi02VVjbM++Gj0akMTZ
 MIlrEkTvqVsmVFG085hloSiFU2xXfTnfQmp19M9QtyDnHkgBMo9sOFnBK3EG+Se4
 NIliUvq8PJzCjTRVafSeSFNoDMwXXQTIKhfq8TDSeOG9o5mCTgAdy8yGiZ2ag/Ok
 peFfwauGs9Gg6tRour7UxccawuLnuzPNzwzUUSG3gkdIUTQVD6YHAzXzwblnB5P6
 0ZcErJpGSLAYcHQH310ZRTizhhW+vi+ftWUkps81xqpmFp3+EydVnJS0MZXYgM2o
 Cv6wbohp9w22I5/B9TMEfL7vnj1i4iZoJfi00Su1HBDHBiNpXISRc/fnkRMWavhr
 gvypyxngQmXm1JN/R8UMbJQsSpH3TN07AYF1qx0Tktfyx4S18rdW4hwt+kBNe9ni
 5G9xQU8IhmN8yvHMsTvZHbAmbuOR6iaghx3arf65qdHPvKSQ/nTSlran9U1JPvyJ
 tWVKtPaY5zEGgkQBmWee+qWkWOBGYDC4nmTwijB0u61Deq+5hGg55cZPd0fSXLMg
 6ecNg2v7zrdYldulOpfdNUEOrXa/NYBEAuYUNvccp8DArOqdazkCyO3DlDFDUXRw
 RKNE7Btx/rU=
 =2fJI
 -----END PGP SIGNATURE-----

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

Jonathan writes:

Second set of IIO new device support, features and cleanups for the 4.13 cycle.

A few reverts here. One was a general failure to notice a device was already
supported by another driver.  The second is due to a review comment pointing
out that the original patch was a bad idea and would break existing systems.

Reverts
* bma180
  - Revert addition of support for the BMA250E it is already supported by
    the bmc150-accel and better supported at that. Oops.
* hi8435
  - The fix for cleanup of the reset gpio stuff isn't a good way to go.  It
    breaks systems where an inverting level convertor is used.  The right fix
    is to make the original devicetree correct - even if it involves patching
    the devicetree in kernel.

New Device Support
* stm32-adc
  - STM32H7 support and bindings.

Features
* core
  - add a hardware triggered operating mode for systems in which the actual
    trigger is never seen by the kernel.  This is typically only used when
    a device 'can' use other triggers, but if a particular magic one is
    enabled the interrupt is effectively handled in hardware and we never see
    it.
* st-lsm6dsx
  - support active low interrupts.
* stm32-adc
  - Make the core adc clock optional as not all hardware supported requires it.
  - Make the bus clock optional in the per instance driver as it may be shared
    by all instances of the ADC and is handled by the core.
  - Rework to have a data structure representing the device type specific
    elements.
* stm32-trigger (and counter)
  - Use the INDIO_HARDWARE_TRIGGERED_MODE where appropriate.
  - Add an attribute to configure device modes for quadrature counting etc.

Clean ups and minor fixes
* IIO core.
  - use __sysfs_match_string() helper rather than open coding the same.
* ad7791
  - use sysfs_match_string() helper rather than open coding the same.
* aspeed-adc
  - handle return value of clk_prepare_enable
* cpcap
  - Fix default register values and ensure the battery thermistor is enabled
    correctly.
  - Fix the reported die temperature where we can - docs are lacking.
  - Remove the hung interrupt quirk as no longer happens due to fix in the
    mfd driver.
* hi8435
  - Remove &s from hi8435_info definition as unneeded and inconsistent.
* hid-sensor-trgger
  - Add kconfig depends on IIO_BUFFER (fixes patch in previous series)
* ina2xx
  - Make the use of iio_info_mask* elements consistent for all channels.
    This doesn't have any visible effect, but acts as clear documentation of
    which channels various resulting attributes apply to.
* lpc32xx
  - handle the return value of clk_prepare_enable.
* meson-saradc
  - NULL instead of 0 for pointer.
* mma9551
  - use NULL for GPIO connection ID to aid implementation fo ACPI support.
    Here the connection ID doesn't actually tell us anything and it is much
    easier to deal with the driver if it's not there.
* mpu6050
  - Fix lock issues through use of a local mux.
  - Replace sprintf with scnprintf as appropriate.
  - Check whoami against all known values.  This allows for a small number of
    boards where we are really fishing for the part not being present at all.
    It is unfortunately common to have undescribed changes to use newer chips.
    We paper over this but just emitting a warning for those cases as long as
    we know about.
* mxs-lradc
  - Fix some non static warnings.
* rcar-adc
  - Part of making the naming for this part consistent across the kernel.
* st_accel
  - drop some spi_device_id entries for variants with no SPI support
* st_magn
  - drop some spi_device_id entries for variants with no SPI support.
* sx9500
  - Use devm_gpiod_get instead of indexed value with an index of 0 on all
    occasions.
* twl4030
  - Drop unused twl4030_get_madc_conversion as callers removed now throughout
    kernel.
  - Unexport twl4030_madc_conversion() as no used only within this driver.
  - Drop twl4030_madc_user_params as not used now.
  - Drop twl4030_madc_request.func_cb as not used now.
  - Fold the twl4030-madc.h header into the driver as no longer used anywhere
    else in the kernel.
* xilinx
  - Handle the return value of clk_prepare_enable
2017-06-26 07:09:23 +02:00
Greg Kroah-Hartman 7bf1e44f86 Merge 4.12-rc5 into staging-next
We want the IIO fixes and other staging driver fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-12 08:20:47 +02:00