platform/kernel/linux-rpi.git
3 years agostaging: rtl8188eu: remove unused macros and definitions
Michael Straube [Tue, 29 Sep 2020 06:28:40 +0000 (08:28 +0200)]
staging: rtl8188eu: remove unused macros and definitions

Removep unused macros and definitions from rtw_security.h leftover
from previous cleanup patches.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20200929062847.23985-1-straube.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: vchiq: Fix an uninitialized variable
Dan Carpenter [Wed, 30 Sep 2020 12:30:36 +0000 (15:30 +0300)]
staging: vchiq: Fix an uninitialized variable

Smatch complains that "userdata" can be passed to vchiq_bulk_transfer()
without being initialized.  This leads to a potential information leak
later on.

Fixes: a4367cd2b231 ("staging: vchiq: convert compat bulk transfer")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20200930123036.GC4282@kadam
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8712: Fix enqueue_reorder_recvframe()
Dan Carpenter [Tue, 29 Sep 2020 10:35:48 +0000 (13:35 +0300)]
staging: rtl8712: Fix enqueue_reorder_recvframe()

The logic of this function was accidentally broken by a checkpatch
inspired cleanup.  I've modified the code to restore the original
behavior and also make checkpatch happy.

Fixes: 98fe05e21a6e ("staging: rtl8712: Remove unnecesary else after return statement.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20200929103548.GA493135@mwanda
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agoStaging: nvec: Removes repeated word typo in comment
Ryan Kosta [Sun, 27 Sep 2020 17:28:55 +0000 (10:28 -0700)]
Staging: nvec: Removes repeated word typo in comment

Fix a comment typo.

Signed-off-by: Ryan Kosta <ryanpkosta@gmail.com>
Link: https://lore.kernel.org/r/20200927172855.9813-1-ryanpkosta@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agoMerge tag 'iio-for-5.10c' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23...
Greg Kroah-Hartman [Tue, 29 Sep 2020 17:11:11 +0000 (19:11 +0200)]
Merge tag 'iio-for-5.10c' of https://git./linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

3rd set of new device support features and cleanup for IIO in the 5.10 cycle.

A late set given it seems the 5.10 cycle is going to start a bit later
than expected and quite a bit came in.  Includes some late breaking
fixes that can wait for the merge window.

New device support
* ad9467
  - ad9434 support including dt bindings update
  - ad9265 support including dt bindings update

Yaml conversion
* amlogic,meson-saradc

Core rework (heading towards multiple buffer support)
* refactor iio_device_register_eventset
* Null-ify IIO device's event_interface during unregister.

Features
* ad7291
  - convert from platform_data to devicetree including bindings doc.
* core
  - Add titles to a few IIO config symbols to allow simpler out of tree
    building.  It does little harm so why not enable it.

Fixes
* ad7292
  - Fix missing of_node_put()
* at91-sama5d2
  - Fix a crash due to missordering of dma enabling as a result of recent
    IIO wide rework.
* gyro-adc
  - Fix missing of_node_put()
* ltc2983
  - Fix missing of_node_put()
* stm32-adc
  - Fix an issue with runtime autosuspend related to parent autosuspending.

Cleanups
* counter/ti-eqep
  - Tidy up a , instead of ;
* buffer-dmaengine
  - Drop the unmanaged allocator functions as no one is using them.
* at91-sama5d2
  - devm_platform_get_and_ioremap_resouce() replacing boilerplate.
* cros_ec
  - move the hw fifo attributes setup into the cros_ec core.
* gp2ap002
  - comment typo
* microchip-tcb-capture:
  - consitifcation
* ssp
  - Use PLATFORM_DEVID_NONE instead of -1 to convey true meaning.
* stm32-dfsdm
  - devm_platform_get_and_ioremap_resouce() replacing boilerplate.

* tag 'iio-for-5.10c' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (25 commits)
  iio: adc: gyroadc: fix leak of device node iterator
  iio: adc: stm32-adc: fix runtime autosuspend delay when slow polling
  iio: adc: at91-sama5d2_adc: fix DMA conversion crash
  iio: ad7292: Fix of_node refcounting
  iio: ltc2983: Fix of_node refcounting
  counter: use semicolons rather than commas to separate statements
  iio: buffer: Kconfig: add title for IIO_TRIGGERED_BUFFER symbol
  iio: Kconfig: Provide title for IIO_TRIGGERED_EVENT symbol
  iio: dma-buffer: Kconfig: Provide titles for IIO DMA Kconfig symbols
  iio: cros_ec: unify hw fifo attributes into the core file
  dt-bindings: iio: ad9467: add entries for for AD9434 & AD9265 ADCs
  iio: adc: ad9467: add support for AD9265 high-speed ADC
  iio: adc: ad9467: add support for AD9434 high-speed ADC
  iio: adc: ad9467: wrap a axi-adc chip-info into a ad9467_chip_info type
  iio: buffer-dmaengine: remove non managed alloc/free
  iio: adc: stm32-dfsdm: Use devm_platform_get_and_ioremap_resource()
  iio: adc: at91-sama5d2_adc: Use devm_platform_get_and_ioremap_resource()
  iio: ssp: use PLATFORM_DEVID_NONE
  dt-bindings: iio: adc: ad7291: add binding
  iio: adc: ad7291: convert to device tree
  ...

3 years agoiio: adc: gyroadc: fix leak of device node iterator
Tobias Jordan [Sat, 26 Sep 2020 16:19:46 +0000 (18:19 +0200)]
iio: adc: gyroadc: fix leak of device node iterator

Add missing of_node_put calls when exiting the for_each_child_of_node
loop in rcar_gyroadc_parse_subdevs early.

Also add goto-exception handling for the error paths in that loop.

Fixes: 059c53b32329 ("iio: adc: Add Renesas GyroADC driver")
Signed-off-by: Tobias Jordan <kernel@cdqe.de>
Link: https://lore.kernel.org/r/20200926161946.GA10240@agrajag.zerfleddert.de
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: adc: stm32-adc: fix runtime autosuspend delay when slow polling
Fabrice Gasnier [Wed, 1 Jul 2020 14:55:28 +0000 (16:55 +0200)]
iio: adc: stm32-adc: fix runtime autosuspend delay when slow polling

When the ADC is runtime suspended and starting a conversion, the stm32-adc
driver calls pm_runtime_get_sync() that gets cascaded to the parent
(e.g. runtime resume of stm32-adc-core driver). This also kicks the
autosuspend delay (e.g. 2s) of the parent.
Once the ADC is active, calling pm_runtime_get_sync() again (upon a new
capture) won't kick the autosuspend delay for the parent (stm32-adc-core
driver) as already active.

Currently, this makes the stm32-adc-core driver go in suspend state
every 2s when doing slow polling. As an example, doing a capture, e.g.
cat in_voltageY_raw at a 0.2s rate, the auto suspend delay for the parent
isn't refreshed. Once it expires, the parent immediately falls into
runtime suspended state, in between two captures, as soon as the child
driver falls into runtime suspend state:
- e.g. after 2s, + child calls pm_runtime_put_autosuspend() + 100ms
  autosuspend delay of the child.
- stm32-adc-core switches off regulators, clocks and so on.
- They get switched on back again 100ms later in this example (at 2.2s).

So, use runtime_idle() callback in stm32-adc-core driver to call
pm_runtime_mark_last_busy() for the parent driver (stm32-adc-core),
to avoid this.

Fixes: 9bdbb1139ca1 ("iio: adc: stm32-adc: add power management support")
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/1593615328-5180-1-git-send-email-fabrice.gasnier@st.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: adc: at91-sama5d2_adc: fix DMA conversion crash
Eugen Hristev [Wed, 23 Sep 2020 12:17:48 +0000 (15:17 +0300)]
iio: adc: at91-sama5d2_adc: fix DMA conversion crash

After the move of the postenable code to preenable, the DMA start was
done before the DMA init, which is not correct.
The DMA is initialized in set_watermark. Because of this, we need to call
the DMA start functions in set_watermark, after the DMA init, instead of
preenable hook, when the DMA is not properly setup yet.

Fixes: f3c034f61775 ("iio: at91-sama5d2_adc: adjust iio_triggered_buffer_{predisable,postenable} positions")
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Link: https://lore.kernel.org/r/20200923121748.49384-1-eugen.hristev@microchip.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: ad7292: Fix of_node refcounting
Nuno Sá [Fri, 25 Sep 2020 09:10:45 +0000 (11:10 +0200)]
iio: ad7292: Fix of_node refcounting

When returning or breaking early from a
`for_each_available_child_of_node()` loop, we need to explicitly call
`of_node_put()` on the child node to possibly release the node.

Fixes: 506d2e317a0a0 ("iio: adc: Add driver support for AD7292")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20200925091045.302-2-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: ltc2983: Fix of_node refcounting
Nuno Sá [Fri, 25 Sep 2020 09:10:44 +0000 (11:10 +0200)]
iio: ltc2983: Fix of_node refcounting

When returning or breaking early from a
`for_each_available_child_of_node()` loop, we need to explicitly call
`of_node_put()` on the child node to possibly release the node.

Fixes: f110f3188e563 ("iio: temperature: Add support for LTC2983")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20200925091045.302-1-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agocounter: use semicolons rather than commas to separate statements
Julia Lawall [Sun, 27 Sep 2020 19:12:25 +0000 (21:12 +0200)]
counter: use semicolons rather than commas to separate statements

Replace commas with semicolons.  What is done is essentially described by
the following Coccinelle semantic patch (http://coccinelle.lip6.fr/):

// <smpl>
@@ expression e1,e2; @@
e1
-,
+;
e2
... when any
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Reviewed-by: David Lechner <david@lechnology.com>
Link: https://lore.kernel.org/r/1601233948-11629-16-git-send-email-Julia.Lawall@inria.fr
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: buffer: Kconfig: add title for IIO_TRIGGERED_BUFFER symbol
Alexandru Ardelean [Thu, 24 Sep 2020 11:17:58 +0000 (14:17 +0300)]
iio: buffer: Kconfig: add title for IIO_TRIGGERED_BUFFER symbol

For some embedded systems, a workflow involving external kernel modules
that implement IIO devices is more practical than working with in-tree
sources.

Kconfig symbols without any titles do not show up in menuconfig, and as
such are more difficult to configure granularly, as they need to be
selected by potentially unused/un-needed drivers.

This change adds a title to the IIO_TRIGGERED_BUFFER Kconfig symbol.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20200924111758.196367-4-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: Kconfig: Provide title for IIO_TRIGGERED_EVENT symbol
Alexandru Ardelean [Thu, 24 Sep 2020 11:17:57 +0000 (14:17 +0300)]
iio: Kconfig: Provide title for IIO_TRIGGERED_EVENT symbol

For some embedded systems, a workflow involving external kernel modules
that implement IIO devices is more practical than working with in-tree
sources.

Kconfig symbols without any titles do not show up in menuconfig, and as
such are more difficult to configure granularly, as they need to be
selected by potentially unused/un-needed drivers.

Albeit, the IIO_TRIGGERED_EVENT is used by a single mainline driver, this
could allow for some out-of-tree drivers to use this kmod.

This change adds a title to the IIO_TRIGGERED_EVENT Kconfig symbol.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20200924111758.196367-3-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: dma-buffer: Kconfig: Provide titles for IIO DMA Kconfig symbols
Alexandru Ardelean [Thu, 24 Sep 2020 11:17:56 +0000 (14:17 +0300)]
iio: dma-buffer: Kconfig: Provide titles for IIO DMA Kconfig symbols

For some embedded systems, a workflow involving external kernel modules
that implement IIO devices is more practical than working with in-tree
sources.

Kconfig symbols without any titles do not show up in menuconfig, and as
such are more difficult to configure granularly, as they need to be
selected by potentially unused/un-needed drivers.

This change adds titles to the IIO DMA Kconfig symbols to address this.

This change also updates DMAengine -> DMAEngine, which is the
correct/nitpick-y name of the framework.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20200924111758.196367-2-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: cros_ec: unify hw fifo attributes into the core file
Alexandru Ardelean [Wed, 23 Sep 2020 13:03:39 +0000 (16:03 +0300)]
iio: cros_ec: unify hw fifo attributes into the core file

The intent here is to minimize the use of iio_buffer_set_attrs(). Since we
are planning to add support for multiple IIO buffers per IIO device, the
issue has to do with:
1. Accessing 'indio_dev->buffer' directly (as is done with
   'iio_buffer_set_attrs(indio_dev->buffer, <attrs>)').
2. The way that the buffer attributes would get handled or expanded when
   there are more buffers per IIO device. Current a sysfs kobj_type expands
   into a 'device' object that expands into an 'iio_dev' object.
   We will need to change this, so that the sysfs attributes for IIO
   buffers expand into IIO buffers at some point.

Right now, the current IIO framework works fine for the
'1 IIO device == 1 IIO buffer' case (that is now).

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Link: https://lore.kernel.org/r/20200923130339.997902-1-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agodt-bindings: iio: ad9467: add entries for for AD9434 & AD9265 ADCs
Alexandru Ardelean [Thu, 24 Sep 2020 08:05:18 +0000 (11:05 +0300)]
dt-bindings: iio: ad9467: add entries for for AD9434 & AD9265 ADCs

Add entries for the AD9434 & AD9265 high-speed ADCs which are supported by
the 'ad9467' driver.
Better describe the family of ADCs similar to AD9467 in the description.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20200924080518.96410-5-alexandru.ardelean@analog.com
3 years agoiio: adc: ad9467: add support for AD9265 high-speed ADC
Michael Hennerich [Thu, 24 Sep 2020 08:05:17 +0000 (11:05 +0300)]
iio: adc: ad9467: add support for AD9265 high-speed ADC

The AD9265 is a 16-bit, 125 MSPS analog-to-digital converter (ADC). The
AD9265 is designed to support communications applications where high
performance combined with low cost, small size, and versatility is
desired.

The ADC core features a multistage, differential pipelined architecture
with integrated output error correction logic to provide 16-bit accuracy at
125 MSPS data rates and guarantees no missing codes over the full operating
temperature range.

The ADC features a wide bandwidth differential sample-and-hold analog input
amplifier supporting a variety of user-selectable input ranges. It is
suitable for multiplexed systems that switch full-scale voltage levels in
successive channels and for sampling single-channel inputs at frequencies
well beyond the Nyquist rate. Combined with power and cost savings over
previously available ADCs, the AD9265 is suitable for applications in
communications, instrumentation and medical imaging.

Link: https://www.analog.com/media/en/technical-documentation/data-sheets/AD9434.pdf
The driver supports the same register set as the AD9467, so the support for
this chip is added to the 'ad9467' driver.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20200924080518.96410-4-alexandru.ardelean@analog.com
3 years agoiio: adc: ad9467: add support for AD9434 high-speed ADC
Michael Hennerich [Thu, 24 Sep 2020 08:05:16 +0000 (11:05 +0300)]
iio: adc: ad9467: add support for AD9434 high-speed ADC

The AD9434 is a 12-bit monolithic sampling analog-to-digital converter
(ADC) optimized for high performance, low power, and ease of use. The part
operates at up to a 500 MSPS conversion rate and is optimized for
outstanding dynamic performance in wideband carrier and broadband systems.

All necessary functions, including a sample-and-hold and voltage reference,
are included on the chip to provide a complete signal conversion solution.
The VREF pin can be used to monitor the internal reference or provide an
external voltage reference (external reference mode must be enabled through
the SPI port).

The ADC requires a 1.8 V analog voltage supply and a differential clock
for full performance operation. The digital outputs are LVDS (ANSI-644)
compatible and support twos complement, offset binary format, or Gray code.
A data clock output is available for proper output data timing.

Link: https://www.analog.com/media/en/technical-documentation/data-sheets/AD9434.pdf
The driver supports the same register set as the AD9467, so the support for
this chip is added to the 'ad9467' driver.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20200924080518.96410-3-alexandru.ardelean@analog.com
3 years agoiio: adc: ad9467: wrap a axi-adc chip-info into a ad9467_chip_info type
Alexandru Ardelean [Thu, 24 Sep 2020 08:05:15 +0000 (11:05 +0300)]
iio: adc: ad9467: wrap a axi-adc chip-info into a ad9467_chip_info type

There are 2 chip constants that can be added to the chip-info part. The
default output-mode and the VREF mask.

When adding new chips to this driver, these can be easily omitted, because
these also need to be updated in 2 switch statements.

However, if adding them in the chip-info constants, they are updated in a
single place and propagated in both switch statements.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20200924080518.96410-2-alexandru.ardelean@analog.com
3 years agoiio: buffer-dmaengine: remove non managed alloc/free
Alexandru Ardelean [Wed, 23 Sep 2020 12:18:10 +0000 (15:18 +0300)]
iio: buffer-dmaengine: remove non managed alloc/free

This is to encourage the use of devm_iio_dmaengine_buffer_alloc().
Currently the managed version of the DMAEngine buffer alloc is the only
function used from this part of the framework.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20200923121810.944075-1-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: adc: stm32-dfsdm: Use devm_platform_get_and_ioremap_resource()
Wang ShaoBo [Fri, 18 Sep 2020 08:31:42 +0000 (16:31 +0800)]
iio: adc: stm32-dfsdm: Use devm_platform_get_and_ioremap_resource()

Make use of devm_platform_get_and_ioremap_resource() provided by
driver core platform instead of duplicated analogue, dev_err() is
removed because it has been done in devm_ioremap_resource().

Signed-off-by: Wang ShaoBo <bobo.shaobowang@huawei.com>
Link: https://lore.kernel.org/r/20200918083142.32816-1-bobo.shaobowang@huawei.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: adc: at91-sama5d2_adc: Use devm_platform_get_and_ioremap_resource()
Wang ShaoBo [Fri, 18 Sep 2020 08:28:37 +0000 (16:28 +0800)]
iio: adc: at91-sama5d2_adc: Use devm_platform_get_and_ioremap_resource()

Make use of devm_platform_get_and_ioremap_resource() provided by
driver core platform instead of duplicated analogue.

Signed-off-by: Wang ShaoBo <bobo.shaobowang@huawei.com>
Link: https://lore.kernel.org/r/20200918082837.32610-1-bobo.shaobowang@huawei.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: ssp: use PLATFORM_DEVID_NONE
Krzysztof Kozlowski [Mon, 21 Sep 2020 20:49:39 +0000 (22:49 +0200)]
iio: ssp: use PLATFORM_DEVID_NONE

Use PLATFORM_DEVID_NONE define instead of "-1" value because:
 - it brings some meaning,
 - it might point attention why auto device ID was not used.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Link: https://lore.kernel.org/r/20200921204939.20341-1-krzk@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agodt-bindings: iio: adc: ad7291: add binding
Michael Auchter [Tue, 22 Sep 2020 14:44:21 +0000 (09:44 -0500)]
dt-bindings: iio: adc: ad7291: add binding

Add device-tree binding for ADI AD7291 ADC.

Signed-off-by: Michael Auchter <michael.auchter@ni.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20200922144422.542669-2-michael.auchter@ni.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: adc: ad7291: convert to device tree
Michael Auchter [Tue, 22 Sep 2020 14:44:20 +0000 (09:44 -0500)]
iio: adc: ad7291: convert to device tree

There are no in-tree users of the platform data for this driver, so
remove it and convert the driver to use device tree instead.

Signed-off-by: Michael Auchter <michael.auchter@ni.com>
Link: https://lore.kernel.org/r/20200922144422.542669-1-michael.auchter@ni.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: event: NULL-ify IIO device's event_interface ref during unregister
Alexandru Ardelean [Mon, 21 Sep 2020 10:31:56 +0000 (13:31 +0300)]
iio: event: NULL-ify IIO device's event_interface ref during unregister

Though we know that the iio_device_unregister_eventset() call is followed
by the free-ing of the IIO device object, we should not make this
assumption in the iio_device_unregister_eventset() function. It should
allow for the clean unregistering of the event-set, allowing a re-register
should we decide to implement this at some point later.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20200921103156.194748-2-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: event: use short-hand variable in iio_device_{un}register_eventset functions
Alexandru Ardelean [Mon, 21 Sep 2020 10:31:55 +0000 (13:31 +0300)]
iio: event: use short-hand variable in iio_device_{un}register_eventset functions

With the recent 'iio_dev_opaque' variable name, these two functions are
looking a bit ugly.

This change uses an 'ev_int' variable for the
iio_device_{un}register_eventset functions to make the code a little easier
to read.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20200921103156.194748-1-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agodt-bindings:iio:adc:amlogic,meson-saradc yaml conversion
Jonathan Cameron [Sun, 20 Sep 2020 13:54:36 +0000 (14:54 +0100)]
dt-bindings:iio:adc:amlogic,meson-saradc yaml conversion

This binding is non trivial due to the range of different parts
supported having several subtle quirks. Martin has helped
clarify some of them.

Note, I haven't restricted the amlogic,hhi-sysctrl to only
be present on the relevant parts if nvmem stuff also is, but
it would seem to be rather odd if it were otherwise.

Perhaps we look to make this binding more restrictive at a later date.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Jerome Brunet <jbrunet@baylibre.com>
Link: https://lore.kernel.org/r/20200920135436.199003-2-jic23@kernel.org
3 years agoiio:light:gp2ap002 fix spelling typo in comments
Wang Qing [Tue, 22 Sep 2020 11:06:56 +0000 (19:06 +0800)]
iio:light:gp2ap002 fix spelling typo in comments

Change the comment typo: "definately" -> "definitely".

Signed-off-by: Wang Qing <wangqing@vivo.com>
Link: https://lore.kernel.org/r/1600772818-30882-1-git-send-email-wangqing@vivo.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agostaging: rtl8188eu: Reapply "staging:r8188eu: Use lib80211 to encrypt (CCMP) tx frames"
Michael Straube [Sun, 27 Sep 2020 08:35:35 +0000 (10:35 +0200)]
staging: rtl8188eu: Reapply "staging:r8188eu: Use lib80211 to encrypt (CCMP) tx frames"

Commit 515ce733e86e ("staging:r8188eu: Use lib80211 to encrypt (CCMP) tx frames")
was reverted because it caused scheduling while atomic bugs and hard
freezes. Experimentation showed that there were no freezes and no BUG
messages logged when lib80211_get_crypto_ops() was called directly
rather than indirectly through try_then_request_module().

Reapply "staging:r8188eu: Use lib80211 to encrypt (CCMP) tx frames"
with resolved revert conflicts and replace try_then_request_module()
with direct call to lib80211_get_crypto_ops().

Original commit message:
Put data to skb, decrypt with lib80211_crypt_ccmp, and place back to tx buffer.

Cc: Ivan Safonov <insafonov@gmail.com>
Signed-off-by: Michael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20200927083535.2895-1-straube.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: vchiq: avoid mixing kernel and user pointers
Arnd Bergmann [Fri, 25 Sep 2020 11:43:32 +0000 (13:43 +0200)]
staging: vchiq: avoid mixing kernel and user pointers

As found earlier, there is a problem in the create_pagelist() function
that takes a pointer argument that either points into vmalloc space or
into user space, with the pointer value controlled by user space allowing
a malicious user to trick the driver into accessing the kernel instead.

Avoid this problem by adding another function argument and passing
kernel pointers separately from user pointers. This makes it possible
to rely on sparse to point out invalid conversions, and it prevents
user space from faking a kernel pointer.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20200925114424.2647144-2-arnd@arndb.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: vchiq: fix __user annotations
Arnd Bergmann [Fri, 25 Sep 2020 11:43:31 +0000 (13:43 +0200)]
staging: vchiq: fix __user annotations

My earlier patches caused some new sparse warnings, but it turns out
that a number of those are actual bugs, or at least suspicous code.

Adding __user annotations to the data structures that are defined in
uapi headers helps avoid the new warnings, but that causes a different
set of warnings to show up, as some of these structures are used both
inside of the kernel and at the user interface but storing pointers to
different things there.

Duplicating the vchiq_service_params and vchiq_completion_data structures
in turn takes care of most of those, and then it turns out that there
is a 'data' pointer that can be any of a __user address, a dmd_addr_t
and a kernel pointer in vmalloc space at times.

I'm trying to annotate these as best I can without changing behavior,
but there still seems to be a serious bug when user space passes
a valid vmalloc space address instead of a user pointer. Adding
comments in the code there, and leaving the warnings in place that
seem to correspond to actual bugs.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20200925114424.2647144-1-arnd@arndb.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agocounter: microchip-tcb-capture: Constify mchp_tc_ops
Rikard Falkeborn [Tue, 22 Sep 2020 20:19:41 +0000 (22:19 +0200)]
counter: microchip-tcb-capture: Constify mchp_tc_ops

The only usage of mchp_tc_ops is to assign its address to the ops field
in the counter_device struct which is a const pointer. Make it const to
allow the compiler to put it in read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Link: https://lore.kernel.org/r/20200922201941.41328-1-rikard.falkeborn@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agostaging: r8188eu: replace WIFI_REASON_CODE enum with native ieee80211_reasoncode
Ivan Safonov [Sat, 19 Sep 2020 21:24:44 +0000 (00:24 +0300)]
staging: r8188eu: replace WIFI_REASON_CODE enum with native ieee80211_reasoncode

WIFI_REASON_CODE is duplication of enum ieee80211_reasoncode.

Signed-off-by: Ivan Safonov <insafonov@gmail.com>
Link: https://lore.kernel.org/r/20200919212443.264126-1-insafonov@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: hikey9xx: Fix incorrect assignment
Alex Dewar [Mon, 21 Sep 2020 21:21:47 +0000 (22:21 +0100)]
staging: hikey9xx: Fix incorrect assignment

In hi3670_phy_probe(), when reading property tx-vboost-lvl fails, its
default value is assigned to priv->eye_diagram_param, rather than to
priv->tx_vboost_lvl. Fix this.

Fixes: 8971a3b880b2 ("staging: hikey9xx: add USB physical layer for Kirin 3670")
Addresses-Coverity: CID 1497107: Incorrect expression (COPY_PASTE_ERROR)
Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
Link: https://lore.kernel.org/r/20200921212146.34662-1-alex.dewar90@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8192u: clean up comparsions to NULL
Michael Straube [Sat, 19 Sep 2020 15:08:23 +0000 (17:08 +0200)]
staging: rtl8192u: clean up comparsions to NULL

Clean up comparsions to NULL reported by checkpatch.
if (x == NULL) -> if (!x)
if (x != NULL) -> if (x)

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20200919150823.16923-3-straube.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8192u: correct placement of else if
Michael Straube [Sat, 19 Sep 2020 15:08:22 +0000 (17:08 +0200)]
staging: rtl8192u: correct placement of else if

Move 'else if' to the same line as the closing brace of the
corresponding 'if' to follow kernel coding style.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20200919150823.16923-2-straube.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8192u: clean up blank line style issues
Michael Straube [Sat, 19 Sep 2020 15:08:21 +0000 (17:08 +0200)]
staging: rtl8192u: clean up blank line style issues

Add missing and remove unnecessary blank lines to clear checkpatch
issues.

CHECK: Please use a blank line after function/struct/union/enum declarations
CHECK: Blank lines aren't necessary before a close brace '}'
CHECK: Please don't use multiple blank lines
CHECK: Blank lines aren't necessary after an open brace '{'

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20200919150823.16923-1-straube.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8188eu: clean up alignment style issues
Michael Straube [Sat, 19 Sep 2020 09:00:40 +0000 (11:00 +0200)]
staging: rtl8188eu: clean up alignment style issues

Clean up alignment style issues to follow kernel coding style
and clear checkpatch issues.

CHECK: Alignment should match open parenthesis

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20200919090040.9613-2-straube.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8188eu: clean up block comment style issues
Michael Straube [Sat, 19 Sep 2020 09:00:39 +0000 (11:00 +0200)]
staging: rtl8188eu: clean up block comment style issues

Clean up block comment style issues to follow kernel coding style
and clear checkpatch warnings.

WARNING: Block comments should align the * on each line
WARNING: Block comments use a trailing */ on a separate line
WARNING: Block comments use * on subsequent lines

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20200919090040.9613-1-straube.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8712: use shorter array initializations
Michael Straube [Sat, 19 Sep 2020 08:50:32 +0000 (10:50 +0200)]
staging: rtl8712: use shorter array initializations

Use empty brace syntax to initialize zero valued arrays.
Simplifies and shortens the code a little bit.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20200919085032.32453-2-straube.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: rtl8712: clean up comparsions to NULL
Michael Straube [Sat, 19 Sep 2020 08:50:31 +0000 (10:50 +0200)]
staging: rtl8712: clean up comparsions to NULL

Clean up comparsions to NULL Reported by checkpatch.
if (x == NULL) -> if (!x)
if (x != NULL) -> if (x)

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20200919085032.32453-1-straube.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: spmi: hisi-spmi-controller: Use devm_ version of ioremap().
Dan Carpenter [Fri, 18 Sep 2020 14:33:38 +0000 (17:33 +0300)]
staging: spmi: hisi-spmi-controller: Use devm_ version of ioremap().

The ioremap() was never unmapped in the probe error handling or in the
remove function.  The fix is to use the devm_ioremap() function so it
gets cleaned up automatically.

Fixes: 70f59c90c819 ("staging: spmi: add Hikey 970 SPMI controller driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20200918143338.GE909725@mwanda
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging/emxx_udc: fix indenting issue on a couple of statements
Colin Ian King [Fri, 18 Sep 2020 21:47:31 +0000 (22:47 +0100)]
staging/emxx_udc: fix indenting issue on a couple of statements

A couple of statements are indented too deeply, remove the
extraneous tabs.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20200918214731.48750-1-colin.king@canonical.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: vchiq: convert compat await_completion
Arnd Bergmann [Fri, 18 Sep 2020 09:54:41 +0000 (11:54 +0200)]
staging: vchiq: convert compat await_completion

Split out the ioctl implementation for VCHIQ_IOC_QUEUE_BULK_TRANSMIT
into a separate function so it can be shared with the compat
implementation.

This one is the trickiest conversion, as the compat implementation
is already quite different from the native one. By using a common
handler, the behavior is changed to be the same again: The
indirect __user pointer accesses are now handled through helper
functions that check for compat mode internally.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20200918095441.1446041-6-arnd@arndb.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: vchiq: convert compat bulk transfer
Arnd Bergmann [Fri, 18 Sep 2020 09:54:40 +0000 (11:54 +0200)]
staging: vchiq: convert compat bulk transfer

Split out the ioctl implementation for VCHIQ_IOC_QUEUE_BULK_TRANSMIT
into a separate function so it can be shared with the compat
implementation.

Here, the input data is converted separately in the compat
handler, while the output data is passed as a __user pointer
to thec vchiq_queue_bulk_transfer->mode word that is
compatible.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20200918095441.1446041-5-arnd@arndb.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: vchiq: convert compat dequeue_message
Arnd Bergmann [Fri, 18 Sep 2020 09:54:39 +0000 (11:54 +0200)]
staging: vchiq: convert compat dequeue_message

Split out the ioctl implementation for VCHIQ_IOC_DEQUEUE_MESSAGE
into a separate function so it can be shared with the compat
implementation.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20200918095441.1446041-4-arnd@arndb.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: vchiq: convert compat create_service
Arnd Bergmann [Fri, 18 Sep 2020 09:54:38 +0000 (11:54 +0200)]
staging: vchiq: convert compat create_service

Split out the ioctl implementation for VCHIQ_IOC_CREATE_SERVICE
into a separate function so it can be shared with the compat
implementation.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20200918095441.1446041-3-arnd@arndb.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agostaging: vchiq: rework compat handling
Arnd Bergmann [Fri, 18 Sep 2020 09:54:37 +0000 (11:54 +0200)]
staging: vchiq: rework compat handling

The compat handlers for VCHIQ_IOC_QUEUE_MESSAGE32 and
VCHIQ_IOC_GET_CONFIG32 can simply call the underlying implementations
that are already separate functions rather than using copy_in_user to
simulate the native 64-bit interface for the full ioctl handler.

vchiq_ioc_queue_message gets a small update to the calling
conventions to simplify the compat version by directly
returning a normal errno value.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20200918095441.1446041-2-arnd@arndb.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 years agoMerge tag 'iio-for-5.10b-take2' of https://git.kernel.org/pub/scm/linux/kernel/git...
Greg Kroah-Hartman [Tue, 22 Sep 2020 07:45:11 +0000 (09:45 +0200)]
Merge tag 'iio-for-5.10b-take2' of https://git./linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Second set of features and cleanups for IIO in 5.10

We have a couple of changes that apply to large sets of drivers, so
I have grouped those to keep this short.

There are a few late breaking fixes in here that can wait for the
merge window.

dt yaml conversions
-------------------

* adi,ad7768-1
* adi,ad7949
* aspeed,ast2400
* cosmic,10001-adc
* dlg,da9150-gpadc
* fsl,imx25-gcq
* fsl,imx7d-adc
* fsl,vf610
* holt,hi8435
* marvell,berlin2-adc
* motorola,cpcap-adc
* nuvoton,nau7802
* nuvoton,npcm750-adc
* nxp,lpc1850-adc
* nxp,lpc3220
* sprd,sc2720-adc
* st,stmpe-adc
* ti,adc12138
* ti,ads1015
* ti,ads7950
* ti,twl4030-madc

Features
--------

* adxrs290
  - Add triggered buffer support and expose data ready signal as a possible
    trigger. Includes updating bindings.
  - Add debugfs hooks for register access.
* mlx90632
  - Add a clear user interface to override the measured ambient temperature.
* vl53l0x
  - Add IRQ support including dt bindings.

Cleanups and minor fixes
------------------------
(groups)
Replace mlock with local lock:
  * adf4350
  * exynos-adc
  * fls-imx25-gcq
  * stm32-dac

devm use to simplify probe error handling and remove functions.
  * adis16201
  * adis16203
  * adis16209
  * adis16240
  * adis16136
  * adis16260
  * adis16400
  * adis16460
  * adis16480
  * adis library - drop unused adis_setup_buffer_and_trigger()

of_match_ptr removal and incorrect ACPI binding removal
  of_match_ptr() rarely makes sense in an IIO driver as space saving
  is trivial and it breaks ACPI PRP0001 based instantiation.
  Mostly this series is about removing examples that get copied into new
  drivers.
  * ad2s1200
  * ad5272
  * ad5446
  * ad5592r
  * ad5593r
  * ad5703
  * ak8974
  * ak8975
  * ams-iaq-core
  * as3935
  * atlas-sensor
  * ds1803
  * hdc100x
  * htu21
  * icp10100
  * lmp91000
  * pulsedlight
  * max30102
  * max5432
  * max5481
  * mcp4018
  * mcp4131
  * mcp4531
  * mcp4725
  * ms5611
  * ms5637
  * si7020
  * sgp30
  * ti-dac082s085
  * ti-dac5571
  * tmp007
  * tsys01
  * vz89x
  * zpa2326

kernel-doc fixes
  * iio-core
  * ad7303
  * ad7947
  * adis16080
  * adis16400
  * iio_dummy_evgen
  * sgp30

Fixes for buffer alignment when passed to iio_push_to_buffers_with_timestamp()
This is a long running effort.  There are a few more drivers to come.
  * inv_mpu6050
  * itg3200
  * si1145
  * st_lsm6dsx
  * ti-adc0832
  * ti-adc12138

(not driver focused)
* MAINTAINERS
  - Consolidate Analog Device IIO entries whilst removing Beniamin Bia.
  - Remove Hartmut Knaack as a listed IIO maintainer as he hasn't been
    active for a long time and people are getting intermitted bounces.
* Add __printf() markings to a few functions that were missing them.
* drop some rotted documentation from staging.
* rework buffer sysfs file creation (precursor to multiple buffer support)

(individual drivers)
* ad5592r
  - Fix use of true for IIO_SHARED_BY_TYPE
  - Tidy up locking and indentation.
* ad9467
  - Improve error message on chip-id missmatch.
  - Use more appropriate error value if chip-id not recognised.
* adis-library
  - Simplify burst mode handling.
* adxrs290
  - Make sure to switch device to standby mode during remove.
* as73211
  - Increase measurement timeout as seems some devices are slower.
* bma180
  - Fix use of true fo IIO_SHARED_BY_TYPE
* exynos_adc
  - Update binding to require second interrut with touch screen.
  - Update binding to not require syscon on S5Pv210
* hmc5843
  - Fix use of true for IIO_SHARED_BY_TYPE
* inv_mpu6050
  - Use regmap_noinc_read() for fifo reading.
* palmas_gpadc
  - Use module_platform_driver() to remove boilerplate.
* meson-saradc
  - style consistency fixes
* rockchip_saradc
  - Allow compile testing with !ARM.
* st_lsm6dsx
  - Changing scaling factor to use IIO_VAL_INT_PLUS_NANO to improve precision.
  - Fix an issue with unchecked return value.
* stm32-adc
  - Fix a missing return introduced in dev_err_probe() patch earlier in
    cycle.
* sx9310
  - Prefer async mode for probe as paticularly slow startup.
* vcnl4000
  - Add missing interrupt property to dt binding.

* tag 'iio-for-5.10b-take2' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (126 commits)
  dt-bindings: iio: vishay,vcnl4000: add interrupts property
  iio:imu:inv_mpu6050: Use regmap_noinc_read for fifo reads.
  iio:imu:inv_mpu6050 Fix dma and ts alignment and data leak issues.
  iio:adc:ti-adc12138 Fix alignment issue with timestamp
  iio:adc:ti-adc0832 Fix alignment issue with timestamp
  iio:imu:st_lsm6dsx Fix alignment and data leak issues
  iio:light:si1145: Fix timestamp alignment and prevent data leak.
  iio:gyro:itg3200: Fix timestamp alignment and prevent data leak.
  iio:imu:st_lsm6dsx: check st_lsm6dsx_shub_read_output return
  iio: adc: exynos_adc: Replace indio_dev->mlock with own device lock
  dt-bindings:iio:adc:holt,hi8435 yaml conversion
  dt-bindings:iio:adc:adi,ad7768-1 yaml conversion
  dt-bindings:iio:adc:adi,ad7949 yaml conversion
  dt-bindings:iio:adc:dlg,da9150-gpadc yaml conversion
  dt-bindings:iio:adc:motorola,cpcap-adc yaml conversion
  dt-bindings:iio:adc:nxp,lpc3220-adc yaml conversion
  dt-bindings:iio:adc:nxp,lpc1850-adc yaml conversion
  dt-bindings:iio:adc:fsl,imx25-gcq yaml conversion
  dt-bindings:iio:adc:fsl,imx7d-adc yaml conversion
  dt-bindings:iio:adc:ti,ads1015 yaml conversion
  ...

3 years agodt-bindings: iio: vishay,vcnl4000: add interrupts property
Krzysztof Kozlowski [Sun, 20 Sep 2020 20:38:45 +0000 (22:38 +0200)]
dt-bindings: iio: vishay,vcnl4000: add interrupts property

The dtschema should list all properties, including the common ones like
interrupts.  This fixes dtbs_check warnings like:

  arch/arm64/boot/dts/freescale/imx8mq-librem5-r3.dt.yaml:
    prox@60: 'interrupt-parent', 'interrupts' do not match any of the regexes: 'pinctrl-[0-9]+'

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Link: https://lore.kernel.org/r/20200920203845.17758-1-krzk@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio:imu:inv_mpu6050: Use regmap_noinc_read for fifo reads.
Jonathan Cameron [Wed, 22 Jul 2020 15:50:54 +0000 (16:50 +0100)]
iio:imu:inv_mpu6050: Use regmap_noinc_read for fifo reads.

We should not be assuming that we are reading a sequence of
registers as here we are doing a read of a lot of data from
a single register address.

Not marked for stable as by coincidence it being wrong doesn't
make any difference.

Suggested-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Link: https://lore.kernel.org/r/20200722155103.979802-19-jic23@kernel.org
3 years agoiio:imu:inv_mpu6050 Fix dma and ts alignment and data leak issues.
Jonathan Cameron [Wed, 22 Jul 2020 15:50:53 +0000 (16:50 +0100)]
iio:imu:inv_mpu6050 Fix dma and ts alignment and data leak issues.

This case is a bit different to the rest of the series.  The driver
was doing a regmap_bulk_read into a buffer that wasn't dma safe
as it was on the stack with no guarantee of it being in a cacheline
on it's own.   Fixing that also dealt with the data leak and
alignment issues that Lars-Peter pointed out.

Also removed some unaligned handling as we are now aligned.

Fixes tag is for the dma safe buffer issue. Potentially we would
need to backport timestamp alignment futher but that is a totally
different patch.

Fixes: fd64df16f40e ("iio: imu: inv_mpu6050: Add SPI support for MPU6000")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200722155103.979802-18-jic23@kernel.org
3 years agoiio:adc:ti-adc12138 Fix alignment issue with timestamp
Jonathan Cameron [Wed, 22 Jul 2020 15:51:01 +0000 (16:51 +0100)]
iio:adc:ti-adc12138 Fix alignment issue with timestamp

One of a class of bugs pointed out by Lars in a recent review.
iio_push_to_buffers_with_timestamp assumes the buffer used is aligned
to the size of the timestamp (8 bytes).  This is not guaranteed in
this driver which uses an array of smaller elements on the stack.

We move to a suitable structure in the iio_priv() data with alignment
explicitly requested.  This data is allocated with kzalloc so no
data can leak apart from previous readings. Note that previously
no leak at all could occur, but previous readings should never
be a problem.

In this case the timestamp location depends on what other channels
are enabled. As such we can't use a structure without misleading
by suggesting only one possible timestamp location.

Fixes: 50a6edb1b6e0 ("iio: adc: add ADC12130/ADC12132/ADC12138 ADC driver")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Akinobu Mita <akinobu.mita@gmail.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200722155103.979802-26-jic23@kernel.org
3 years agoiio:adc:ti-adc0832 Fix alignment issue with timestamp
Jonathan Cameron [Wed, 22 Jul 2020 15:51:00 +0000 (16:51 +0100)]
iio:adc:ti-adc0832 Fix alignment issue with timestamp

One of a class of bugs pointed out by Lars in a recent review.
iio_push_to_buffers_with_timestamp assumes the buffer used is aligned
to the size of the timestamp (8 bytes).  This is not guaranteed in
this driver which uses an array of smaller elements on the stack.

We fix this 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 apart from previous readings.
Note that previously no data could leak 'including' previous readings
but I don't think it is an issue to potentially leak them like
this now does.

In this case the postioning of the timestamp is depends on what
other channels are enabled. As such we cannot use a structure to
make the alignment explicit as it would be missleading by suggesting
only one possible location for the timestamp.

Fixes: 815bbc87462a ("iio: ti-adc0832: add triggered buffer support")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Akinobu Mita <akinobu.mita@gmail.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200722155103.979802-25-jic23@kernel.org
3 years agoiio:imu:st_lsm6dsx Fix alignment and data leak issues
Jonathan Cameron [Wed, 22 Jul 2020 15:50:52 +0000 (16:50 +0100)]
iio:imu:st_lsm6dsx Fix alignment and data leak issues

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

This data is allocated with kzalloc so no data can leak apart from
previous readings.

For the tagged path the data is aligned by using __aligned(8) for
the buffer on the stack.

There has been a lot of churn in this driver, so likely backports
may be needed for stable.

Fixes: 290a6ce11d93 ("iio: imu: add support to lsm6dsx driver")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200722155103.979802-17-jic23@kernel.org
3 years agoiio:light:si1145: Fix timestamp alignment and prevent data leak.
Jonathan Cameron [Wed, 22 Jul 2020 15:50:44 +0000 (16:50 +0100)]
iio:light:si1145: 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 24 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 array in the iio_priv() data with alignment
explicitly requested.  This data is allocated with kzalloc so no
data can leak appart from previous readings.

Depending on the enabled channels, the  location of the timestamp
can be at various aligned offsets through the buffer.  As such we
any use of a structure to enforce this alignment would incorrectly
suggest a single location for the timestamp.  Comments adjusted to
express this clearly in the code.

Fixes: ac45e57f1590 ("iio: light: Add driver for Silabs si1132, si1141/2/3 and si1145/6/7 ambient light, uv index and proximity sensors")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200722155103.979802-9-jic23@kernel.org
3 years agoiio:gyro:itg3200: Fix timestamp alignment and prevent data leak.
Jonathan Cameron [Wed, 22 Jul 2020 15:50:41 +0000 (16:50 +0100)]
iio:gyro:itg3200: 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 array of smaller elements on the stack.
This is fixed by using an explicit c structure. As there are no
holes in the structure, there is no possiblity of data leakage
in this case.

The explicit alignment of ts is not strictly necessary but potentially
makes the code slightly less fragile.  It also removes the possibility
of this being cut and paste into another driver where the alignment
isn't already true.

Fixes: 36e0371e7764 ("iio:itg3200: Use iio_push_to_buffers_with_timestamp()")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200722155103.979802-6-jic23@kernel.org
3 years agoiio:imu:st_lsm6dsx: check st_lsm6dsx_shub_read_output return
Tom Rix [Sun, 9 Aug 2020 17:55:51 +0000 (10:55 -0700)]
iio:imu:st_lsm6dsx: check st_lsm6dsx_shub_read_output return

Potential error return is not checked.  This can lead to use
of undefined data.

Detected by clang static analysis.

st_lsm6dsx_shub.c:540:8: warning: Assigned value is garbage or undefined
        *val = (s16)le16_to_cpu(*((__le16 *)data));
             ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fixes: c91c1c844ebd ("iio: imu: st_lsm6dsx: add i2c embedded controller support")
Signed-off-by: Tom Rix <trix@redhat.com
Cc: <Stable@vger.kernel.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20200809175551.6794-1-trix@redhat.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: adc: exynos_adc: Replace indio_dev->mlock with own device lock
Sergiu Cuciurean [Wed, 16 Sep 2020 09:31:23 +0000 (12:31 +0300)]
iio: adc: exynos_adc: Replace indio_dev->mlock with own device lock

As part of the general cleanup of indio_dev->mlock, this change replaces
it with a local lock, to protect potential concurrent access to the
completion callback during a conversion.

This is part of a bigger cleanup.
Link: https://lore.kernel.org/linux-iio/CA+U=Dsoo6YABe5ODLp+eFNPGFDjk5ZeQEceGkqjxXcVEhLWubw@mail.gmail.com/
Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Link: https://lore.kernel.org/r/20200916093123.78954-1-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agodt-bindings:iio:adc:holt,hi8435 yaml conversion
Jonathan Cameron [Wed, 9 Sep 2020 17:59:43 +0000 (18:59 +0100)]
dt-bindings:iio:adc:holt,hi8435 yaml conversion

Very simple binding.  I've changed the example to use the node
name threshold-detector@0 as sensor@0 seemed too generic.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
Link: https://lore.kernel.org/r/20200909175946.395313-18-jic23@kernel.org
3 years agodt-bindings:iio:adc:adi,ad7768-1 yaml conversion
Jonathan Cameron [Wed, 9 Sep 2020 17:59:41 +0000 (18:59 +0100)]
dt-bindings:iio:adc:adi,ad7768-1 yaml conversion

Fairly straight conversion.  The one oddity in the original binding
is that spi-cpha and spi-cpol were not marked as required, but were
in the example.  Looking at the datasheet, there isn't any documented
flexibility in the possible SPI modes, so I have moved these to requires.
For spi-max-frequency I have gone the other way.  I absolutely agree
that it is good to specify this in the dt-binding, but it's not
strictly required.

As Stefan's email is bouncing I have gone with Michael as maintainer
of this one as it falls under the ADI catch all entry in MAINTAINERS.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Link: https://lore.kernel.org/r/20200909175946.395313-16-jic23@kernel.org
3 years agodt-bindings:iio:adc:adi,ad7949 yaml conversion
Jonathan Cameron [Wed, 9 Sep 2020 17:59:40 +0000 (18:59 +0100)]
dt-bindings:iio:adc:adi,ad7949 yaml conversion

Simple SPI driver. I've added the #io-channel-cells
as an optional parameter to allow use of this device as a provider
of ADC capabilities to other devices.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Charles-Antoine Couret <charles-antoine.couret@essensium.com>
Link: https://lore.kernel.org/r/20200909175946.395313-15-jic23@kernel.org
3 years agodt-bindings:iio:adc:dlg,da9150-gpadc yaml conversion
Jonathan Cameron [Wed, 9 Sep 2020 17:59:38 +0000 (18:59 +0100)]
dt-bindings:iio:adc:dlg,da9150-gpadc yaml conversion

This is a small part of an MFD so perhaps ultimately it makes more
sense to document it with that MFD binding rather than separately.

In the meantime it's a straightforward conversion from txt to yaml.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Link: https://lore.kernel.org/r/20200909175946.395313-13-jic23@kernel.org
3 years agodt-bindings:iio:adc:motorola,cpcap-adc yaml conversion
Jonathan Cameron [Wed, 9 Sep 2020 17:59:37 +0000 (18:59 +0100)]
dt-bindings:iio:adc:motorola,cpcap-adc yaml conversion

Conversion from txt to yaml.
Slightly expanded example to give a bit more context.
Description lifted from the original driver commit.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Tony Lindgren <tony@atomide.com>
Link: https://lore.kernel.org/r/20200909175946.395313-12-jic23@kernel.org
3 years agodt-bindings:iio:adc:nxp,lpc3220-adc yaml conversion
Jonathan Cameron [Wed, 9 Sep 2020 17:59:36 +0000 (18:59 +0100)]
dt-bindings:iio:adc:nxp,lpc3220-adc yaml conversion

Renamed to remove the wild cards.  These go wrong far too often so
in general preferred to use the name of a specific part.  As this
binding only provides one compatible, I went with that.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Gregory Clement <gregory.clement@bootlin.com>
Link: https://lore.kernel.org/r/20200909175946.395313-11-jic23@kernel.org
3 years agodt-bindings:iio:adc:nxp,lpc1850-adc yaml conversion
Jonathan Cameron [Wed, 9 Sep 2020 17:59:35 +0000 (18:59 +0100)]
dt-bindings:iio:adc:nxp,lpc1850-adc yaml conversion

Most of the description in the original doc is effectively boilerplate
and does not bring much value so I have not carried it over into the yaml.

Added #io-channel-cells to simplify use of channels on this ADC by
consumer drivers.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Joachim Eastwood <manabian@gmail.com>
Link: https://lore.kernel.org/r/20200909175946.395313-10-jic23@kernel.org
3 years agodt-bindings:iio:adc:fsl,imx25-gcq yaml conversion
Jonathan Cameron [Wed, 9 Sep 2020 17:59:46 +0000 (18:59 +0100)]
dt-bindings:iio:adc:fsl,imx25-gcq yaml conversion

This binding has a few corners that would have been done different today
but hopefully the yaml schema captures the constraints correctly.

The child node names are not constrained hence the fairly open regexp.
I've also documented the defaults for the two references that the
driver seems to use and copied the value descriptions from the header
because I think they should be in the dt-binding itself.

This is part of a general effort to convert all the IIO bindings
over to yaml

Unfortunately I don't have a current address for Markus, so
have put myself as the maintainer for this binding until someone else
steps up!

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Link: https://lore.kernel.org/r/20200909175946.395313-21-jic23@kernel.org
3 years agodt-bindings:iio:adc:fsl,imx7d-adc yaml conversion
Jonathan Cameron [Wed, 9 Sep 2020 17:59:45 +0000 (18:59 +0100)]
dt-bindings:iio:adc:fsl,imx7d-adc yaml conversion

A nice simple binding.  Only real different from txt is that I dropped
some descriptions where the naming of the parameter was self explanatory

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Haibo Chen <haibo.chen@nxp.com>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Link: https://lore.kernel.org/r/20200909175946.395313-20-jic23@kernel.org
3 years agodt-bindings:iio:adc:ti,ads1015 yaml conversion
Jonathan Cameron [Wed, 9 Sep 2020 17:59:42 +0000 (18:59 +0100)]
dt-bindings:iio:adc:ti,ads1015 yaml conversion

This binding was moved over from hwmon some time ago so is a bit
unusual in terms of IIO bindings.  However, conversion was fairly
straight forwards.

I've listed both Dirk (who think wrote original binding) and Daniel
who added the IIO driver for this device.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Daniel Baluta <daniel.baluta@nxp.com>
Link: https://lore.kernel.org/r/20200909175946.395313-17-jic23@kernel.org
3 years agodt-bindings:iio:adc:cosmic,10001-adc yaml conversion
Jonathan Cameron [Wed, 9 Sep 2020 17:59:39 +0000 (18:59 +0100)]
dt-bindings:iio:adc:cosmic,10001-adc yaml conversion

I don't really know much about this one, hence the binding is
a simple conversion of what was in the txt file.

Note that I have taken on maintenance of this binding as I don't
have a recent address for Phani Movva.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20200909175946.395313-14-jic23@kernel.org
3 years agodt-bindings:iio:adc:nuvoton,npcm750-adc yaml conversion
Jonathan Cameron [Wed, 9 Sep 2020 17:59:34 +0000 (18:59 +0100)]
dt-bindings:iio:adc:nuvoton,npcm750-adc yaml conversion

Renamed the file to reflect the only compatible.
Added #io-channel-cells to make it easier to support consumers of the
ADC channels this device provides.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Tomer Maimon <tmaimon77@gmail.com>
Link: https://lore.kernel.org/r/20200909175946.395313-9-jic23@kernel.org
3 years agodt-bindings:iio:adc:nuvoton,nau7802 yaml conversion
Jonathan Cameron [Wed, 9 Sep 2020 17:59:33 +0000 (18:59 +0100)]
dt-bindings:iio:adc:nuvoton,nau7802 yaml conversion

A simple conversion from txt file to yaml.  I added the #io-channel-cells
property as optional to allow the channels of this ADCs to be used
to provide services to other drivers, for example if an analog
accelerometer is connected.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/20200909175946.395313-8-jic23@kernel.org
3 years agodt-bindings:iio:adc:sprd,sc2720-adc yaml conversion.
Jonathan Cameron [Wed, 9 Sep 2020 17:59:32 +0000 (18:59 +0100)]
dt-bindings:iio:adc:sprd,sc2720-adc yaml conversion.

I changed the name to reflect a specific part in line with normal
naming conventions. If there is a particularly strong reason to
keep the wild cards let me know.

Otherwise this was a fairly simple conversion as part of converting
all the IIO bindings to yaml.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Orson Zhai <orsonzhai@gmail.com>
Cc: Baolin Wang <baolin.wang7@gmail.com>
Cc: Chunyan Zhang <zhang.lyra@gmail.com>
Link: https://lore.kernel.org/r/20200909175946.395313-7-jic23@kernel.org
3 years agodt-bindings:iio:adc:marvell,berlin2-adc yaml conversion
Jonathan Cameron [Wed, 9 Sep 2020 17:59:31 +0000 (18:59 +0100)]
dt-bindings:iio:adc:marvell,berlin2-adc yaml conversion

Part of a general move of IIO bindings over to yaml.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Antoine Tenart <antoine.tenart@free-electrons.com>
Link: https://lore.kernel.org/r/20200909175946.395313-6-jic23@kernel.org
3 years agodt-bindings:iio:adc: aspeed,ast2400 yaml conversion
Jonathan Cameron [Wed, 9 Sep 2020 17:59:30 +0000 (18:59 +0100)]
dt-bindings:iio:adc: aspeed,ast2400 yaml conversion

Simple txt to yaml conversion. Part of a general move to convert
all the IIO bindings over to yaml.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Joel Stanley <joel@jms.id.au>
Cc: Rick Altherr <raltherr@google.com>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Andrew Jeffery <andrew@aj.id.au>
Link: https://lore.kernel.org/r/20200909175946.395313-5-jic23@kernel.org
3 years agodt-bindings:iio:adc:st,stmpe-adc yaml conversion
Jonathan Cameron [Wed, 9 Sep 2020 17:59:29 +0000 (18:59 +0100)]
dt-bindings:iio:adc:st,stmpe-adc yaml conversion

Conversion from freeform text to yaml.
One oddity in this binding is that, for historical reasons it requires
the node name to be stmpe_adc.  I've put that in the decription field
but I'm not sure if there is a better way to specify this?

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Stefan Agner <stefan@agner.ch>
Link: https://lore.kernel.org/r/20200909175946.395313-4-jic23@kernel.org
3 years agodt-bindings:iio:adc:ti,twl4030-madc yaml conversion
Jonathan Cameron [Wed, 9 Sep 2020 17:59:28 +0000 (18:59 +0100)]
dt-bindings:iio:adc:ti,twl4030-madc yaml conversion

Conversion from txt to yaml as part of a general move of IIO bindings
to the new format.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Sebastian Reichel <sre@kernel.org>
Link: https://lore.kernel.org/r/20200909175946.395313-3-jic23@kernel.org
3 years agodt-bindings:iio:adc:fsl,vf610-adc conversion to yaml.
Jonathan Cameron [Wed, 9 Sep 2020 17:59:27 +0000 (18:59 +0100)]
dt-bindings:iio:adc:fsl,vf610-adc conversion to yaml.

A simple conversion of this freescale ADC binding from txt to yaml.
For maintainer I went with Fugang Duan as the original author of the
binding. Would be great to have confirmation of this.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Link: https://lore.kernel.org/r/20200909175946.395313-2-jic23@kernel.org
3 years agoiio: imu: st_lsm6dsx: Scaling factor type set to IIO_VAL_INT_PLUS_NANO
Mario Tesi [Thu, 17 Sep 2020 16:47:16 +0000 (18:47 +0200)]
iio: imu: st_lsm6dsx: Scaling factor type set to IIO_VAL_INT_PLUS_NANO

Scaling factor values for Acc lead to an unacceptable rounding of the
full scale (FS) calculated by some SensorHAL on Android devices. For examples
setting FS to 4g the in_accel_x_scale, in_accel_y_scale and in_accel_z_scale
are 0.001196 on 6 decimal digits and the FS is
0.001196 × ((2^15) − 1) ~= 39.1893 m/s^2.

Android CTS R10 SensorParameterRangeTest test expects a value greater than
39.20 m/s^2 so this test fails (ACCELEROMETER_MAX_RANGE = 4 * 9.80).

Using 9 decimal digits the new scale factor is 0.001196411 and the FS now
is 0.001196411 × ((2^15)−1) ~= 39.2028 m/s^2.

This patch extends to IIO_VAL_INT_PLUS_NANO type the scaling factor to all
IMU devices where SensorParameterRangeTest CTS test fails.

Signed-off-by: Mario Tesi <mario.tesi@st.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/1600361236-2285-1-git-send-email-martepisa@gmail.com
3 years agoiio: adis. Drop adis_burst struct
Nuno Sá [Thu, 17 Sep 2020 15:52:23 +0000 (17:52 +0200)]
iio: adis. Drop adis_burst struct

As there are no users anymore of this structure, it can be safely
removed.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20200917155223.218500-5-nuno.sa@analog.com
3 years agoiio: adis16475: Drop adis_burst usage
Nuno Sá [Thu, 17 Sep 2020 15:52:22 +0000 (17:52 +0200)]
iio: adis16475: Drop adis_burst usage

Burst mode variables are now part of the `adis_data` struct. The driver
also has now to explicitly define the length of the burst buffer.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20200917155223.218500-4-nuno.sa@analog.com
3 years agoiio: adis16400: Drop adis_burst usage
Nuno Sá [Thu, 17 Sep 2020 15:52:21 +0000 (17:52 +0200)]
iio: adis16400: Drop adis_burst usage

Burst mode variables are now part of the `adis_data` struct. The driver
also has now to explicitly define the length of the burst buffer.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20200917155223.218500-3-nuno.sa@analog.com
3 years agoiio: adis: Move burst mode into adis_data
Nuno Sá [Thu, 17 Sep 2020 15:52:20 +0000 (17:52 +0200)]
iio: adis: Move burst mode into adis_data

Add burst mode variables in the per device specific data structure. As
some drivers support multiple devices with different burst sizes it
makes sense this data to be in `adis_data`. While moving the variables,
there are two main differences:

1. The `en`variable is dropped. If a device supports burst mode, it will
just use it as it will has better performance for almost all real use
cases.
2. Replace `extra_len` by `burst_len`. Users should now explicitly
define the length of the burst buffer as it is typically constant. This
also allows to remove the following line from the library:

```
/* All but the timestamp channel */
burst_length = (indio_dev->num_channels - 1) * sizeof(u16);
```

The library should not assume that a timestamp channel is defined.
Moreover, most parts also include some diagnostic data, crc, etc.. in
the burst buffer that needed to be included in an `extra_len` variable
which is not that nice. On top of this, some devices already start to
have some 32bit size channels ...

This patch is also a move to completely drop the `struct adis_burst`
from the library.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20200917155223.218500-2-nuno.sa@analog.com
3 years agoiio:accel:bma180: Fix use of true when should be iio_shared_by enum
Jonathan Cameron [Sun, 13 Sep 2020 12:12:27 +0000 (13:12 +0100)]
iio:accel:bma180: Fix use of true when should be iio_shared_by enum

Given a value of 1 corresponds to IIO_SHARE_BY_TYPE I have replaced
it with that.  Should cause no functional change.

Fixes: fdadbce0da42 ("iio: add Bosch BMA180 acceleration sensor driver")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Matt Ranostay <matt.ranostay@konsulko.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
Cc: Peter Meerwald <pmeerw@pmeerw.net>
Cc: Jonathan Bakker <xc-racer2@live.ca>
Link: https://lore.kernel.org/r/20200913121227.764626-1-jic23@kernel.org
3 years agoiio:magn:hmc5843: Fix passing true where iio_shared_by enum required.
Jonathan Cameron [Sun, 13 Sep 2020 11:25:46 +0000 (12:25 +0100)]
iio:magn:hmc5843: Fix passing true where iio_shared_by enum required.

So it's obvious that the code is wrong in passing true, but I'm assuming
that will actually evaluate to 1 and hence IIO_SHARED_BY_TYPE.
The documentation however has this attribute as IIO_SHARED_BY_ALL.
My current assumption is the documentation is wrong.
If anyone knows otherwise please shout out!

Fixes: 7247645f6865 ("iio: hmc5843: Move hmc5843 out of staging")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Matt Ranostay <matt.ranostay@konsulko.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Tested-by: H. Nikolaus Schaller <hns@goldelico.com>
Link: https://lore.kernel.org/r/20200913112546.715624-1-jic23@kernel.org
3 years agoiio: Add __printf() attributes to various allocation functions
Jonathan Cameron [Sun, 13 Sep 2020 13:21:14 +0000 (14:21 +0100)]
iio: Add __printf() attributes to various allocation functions

A partial set of these was added to IIO a long time back.
This fills in some gaps in coverage highlighted by building
with W=1

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20200913132115.800131-3-jic23@kernel.org
3 years agoiio:core: Tidy up kernel-doc.
Jonathan Cameron [Sun, 13 Sep 2020 13:21:15 +0000 (14:21 +0100)]
iio:core: Tidy up kernel-doc.

One comment isn't kernel-doc at all, but starts with /** and another
is simply missing a parameter that was introduced recently.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20200913132115.800131-4-jic23@kernel.org
3 years agoiio: dac: ad5592r: localize locks only where needed in ad5592r_read_raw()
Alexandru Ardelean [Mon, 6 Jul 2020 11:02:59 +0000 (14:02 +0300)]
iio: dac: ad5592r: localize locks only where needed in ad5592r_read_raw()

Since there was a recently discovered issue with these locks, it probably
makes sense to cleanup the code a bit, to prevent it from being used as an
example/reference.

This change moves the lock only where it is explicitly needed to protect
resources from potential concurrent accesses.

It also reworks the switch statements to do direct returns vs caching the
return value on a variable.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20200706110259.23947-3-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: dac: ad5592r: un-indent code-block for scale read
Alexandru Ardelean [Mon, 6 Jul 2020 11:02:58 +0000 (14:02 +0300)]
iio: dac: ad5592r: un-indent code-block for scale read

The next rework may require an unindentation of a code block in
ad5592r_read_raw(), which would make review a bit more difficult.

This change unindents the code block for reading the scale of the
non-temperature channels.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20200706110259.23947-2-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio:dac:ad5592r: Fix use of true for IIO_SHARED_BY_TYPE
Jonathan Cameron [Wed, 22 Jul 2020 14:25:15 +0000 (15:25 +0100)]
iio:dac:ad5592r: Fix use of true for IIO_SHARED_BY_TYPE

struct iio_chan_spec_ext_info shared element is of type
enum iio_shared_by, not boolean.   It's like the enum value
will for IIO_SHARED_BY_TYPE == 1 == true, hence no actual
problem has been observed.

  CC [M]  drivers/iio/dac/ad5592r-base.o
  491 |   .shared = true,
      |

Fixes: 56ca9db862bf ("iio: dac: Add support for the AD5592R/AD5593R ADCs/DACs")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20200722142515.897378-1-jic23@kernel.org
3 years agoiio: chemical: sgp30: Add description for sgp_read_cmd()'s 'duration_us'
Lee Jones [Thu, 16 Jul 2020 13:59:03 +0000 (14:59 +0100)]
iio: chemical: sgp30: Add description for sgp_read_cmd()'s 'duration_us'

Fixes the following W=1 kernel build warning(s):

 drivers/iio/chemical/sgp30.c:236: warning: Function parameter or member 'duration_us' not described in 'sgp_read_cmd'

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Cc: Andreas Brauchli <a.brauchli@elementarea.net>
Cc: Pascal Sachs <pascal.sachs@sensirion.com>
Link: https://lore.kernel.org/r/20200716135928.1456727-6-lee.jones@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: gyro: adis16080: Fix formatting issue
Lee Jones [Thu, 16 Jul 2020 13:59:10 +0000 (14:59 +0100)]
iio: gyro: adis16080: Fix formatting issue

Kerneldoc expects attributes/parameters to be in '@*.: ' format.

Fixes the following W=1 kernel build warning(s):

 drivers/iio/gyro/adis16080.c:49: warning: Function parameter or member 'lock' not described in 'adis16080_state'

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Cc: Barry Song <21cnbao@gmail.com>
Link: https://lore.kernel.org/r/20200716135928.1456727-13-lee.jones@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: dummy: iio_dummy_evgen: Demote file header and supply description for 'irq_sim_d...
Lee Jones [Thu, 16 Jul 2020 13:59:13 +0000 (14:59 +0100)]
iio: dummy: iio_dummy_evgen: Demote file header and supply description for 'irq_sim_domain'

File headers are not good candidates for kerneldoc.

Fixes the following W=1 kernel build warning(s):

 drivers/iio/dummy/iio_dummy_evgen.c:30: warning: Cannot understand  * @regs: irq regs we are faking
 on line 30 - I thought it was a doc line
 drivers/iio/dummy/iio_dummy_evgen.c:42: warning: Function parameter or member 'irq_sim_domain' not described in 'iio_dummy_eventgen'

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Link: https://lore.kernel.org/r/20200716135928.1456727-16-lee.jones@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: adc: ad7949: Fix misspelling issue
Lee Jones [Thu, 16 Jul 2020 13:59:15 +0000 (14:59 +0100)]
iio: adc: ad7949: Fix misspelling issue

Fixes the following W=1 kernel build warning(s):

 drivers/iio/adc/ad7949.c:58: warning: Function parameter or member 'indio_dev' not described in 'ad7949_adc_chip'

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Cc: Charles-Antoine Couret <charles-antoine.couret@essensium.com>
Link: https://lore.kernel.org/r/20200716135928.1456727-18-lee.jones@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: dac: ad5064: Fix a few kerneldoc misdemeanours
Lee Jones [Thu, 16 Jul 2020 13:59:17 +0000 (14:59 +0100)]
iio: dac: ad5064: Fix a few kerneldoc misdemeanours

Misspelling, missing description.

Fixes the following W=1 kernel build warning(s):

 drivers/iio/dac/ad5064.c:71: warning: bad line:                         internal vref.
 drivers/iio/dac/ad5064.c:83: warning: Function parameter or member 'channels' not described in 'ad5064_chip_info'
 drivers/iio/dac/ad5064.c:125: warning: Function parameter or member 'lock' not described in 'ad5064_state'

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20200716135928.1456727-20-lee.jones@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: dac: ad7303: Complete 'struct ad7303_state' doc
Lee Jones [Thu, 16 Jul 2020 13:59:28 +0000 (14:59 +0100)]
iio: dac: ad7303: Complete 'struct ad7303_state' doc

Fixes the following W=1 kernel build warning(s):

 drivers/iio/dac/ad7303.c:49: warning: Function parameter or member 'vdd_reg' not described in 'ad7303_state'
 drivers/iio/dac/ad7303.c:49: warning: Function parameter or member 'vref_reg' not described in 'ad7303_state'
 drivers/iio/dac/ad7303.c:49: warning: Function parameter or member 'lock' not described in 'ad7303_state'

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20200716135928.1456727-31-lee.jones@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: adc: fsl-imx25-gcq: Replace indio_dev->mlock with own device lock
Sergiu Cuciurean [Wed, 16 Sep 2020 09:29:28 +0000 (12:29 +0300)]
iio: adc: fsl-imx25-gcq: Replace indio_dev->mlock with own device lock

As part of the general cleanup of indio_dev->mlock, this change replaces
it with a local lock, to protect against any other accesses during the
reading of sample. Reading a sample requires multiple consecutive regmap
operations and a completion callback, so this requires that no other
read occurs until it completes.

This is part of a bigger cleanup.
Link: https://lore.kernel.org/linux-iio/CA+U=Dsoo6YABe5ODLp+eFNPGFDjk5ZeQEceGkqjxXcVEhLWubw@mail.gmail.com/
Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20200916092928.78026-1-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: proximity: vl53l0x: Add IRQ support
Ivan Drobyshevskyi [Wed, 16 Sep 2020 07:44:58 +0000 (10:44 +0300)]
iio: proximity: vl53l0x: Add IRQ support

VL53L0X can be configured to use interrupt pin (GPIO1)
to notify host about readiness of new measurement.

If interrupt pin is not specified, driver still uses polling.

Signed-off-by: Ivan Drobyshevskyi <drobyshevskyi@gmail.com>
Link: https://lore.kernel.org/r/20200916074458.873359-2-drobyshevskyi@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agodt-bindings: iio: proximity: vl53l0x: Add IRQ support
Ivan Drobyshevskyi [Wed, 16 Sep 2020 07:44:57 +0000 (10:44 +0300)]
dt-bindings: iio: proximity: vl53l0x: Add IRQ support

Since IRQ support was added to the driver, update bindings accordingly.

Signed-off-by: Ivan Drobyshevskyi <drobyshevskyi@gmail.com>
Link: https://lore.kernel.org/r/20200916074458.873359-1-drobyshevskyi@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>