]> git.ipfire.org Git - thirdparty/kernel/linux.git/log
thirdparty/kernel/linux.git
3 months agodocs: iio: fix wrong driver name in documentation
Lothar Rubusch [Fri, 21 Feb 2025 19:46:58 +0000 (19:46 +0000)] 
docs: iio: fix wrong driver name in documentation

The ADXL380/382 documentation uses in one place a wrong driver name.
Adds no functional change.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20250221194658.41358-1-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad4695: simplify getting oversampling_ratio
David Lechner [Tue, 18 Feb 2025 23:17:46 +0000 (17:17 -0600)] 
iio: adc: ad4695: simplify getting oversampling_ratio

We already have a local variable that holds a pointer to
st->channels_cfg[chan->scan_index]. Use that to simplify the code.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Trevor Gamblin <tgamblin@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250218-iio-adc-ad4695-fix-out-of-bounds-array-access-v1-2-57fef8c7a3fd@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad4695: fix out of bounds array access
David Lechner [Tue, 18 Feb 2025 23:17:45 +0000 (17:17 -0600)] 
iio: adc: ad4695: fix out of bounds array access

Fix some out of bounds array access of st->channels_cfg in the ad4695
driver. This array only has elements for voltage channels, but it was
also being accessed for the temperature channel in a few cases causing
reading past the end of the array.

In some cases, this was harmless because the value was read but not
used. However, the in_temp_sampling_frequency attribute shares code
with the in_voltageY_sampling_frequency attributes and was trying to
read the oversampling ratio from the st->channels_cfg array. This
resulted in a garbage value being used in the calculation and the
resulting in_temp_sampling_frequency value was incorrect.

To fix, make sure we always check that we are dealing with a voltage
channel before accessing the st->channels_cfg array and use an
oversampling ratio of 1 for the temperature channel (multiplicative
identity value) since that channel doesn't support oversampling.

Fixes: 67d63185db79 ("iio: adc: ad4695: add offload-based oversampling support")
Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Trevor Gamblin <tgamblin@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250218-iio-adc-ad4695-fix-out-of-bounds-array-access-v1-1-57fef8c7a3fd@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: adi-axi-adc: replace of.h with mod_devicetable.h
Nuno Sá [Tue, 18 Feb 2025 10:34:57 +0000 (10:34 +0000)] 
iio: adc: adi-axi-adc: replace of.h with mod_devicetable.h

Don't use of.h in order to include mod_devicetable.h. Use it directly as
there no direct dependency on OF.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250218-dev-axi-adc-fix-headers-v1-1-5ddc79221d8c@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: core: make use of simple_write_to_buffer()
Nuno Sá [Tue, 18 Feb 2025 10:31:26 +0000 (10:31 +0000)] 
iio: core: make use of simple_write_to_buffer()

Instead of open coding (kind of) simple_write_to_buffer(), use it.

While at it, use ascii representation to terminate the string as that is
the more common way of doing it.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250218-dev-iio-misc-v1-2-bf72b20a1eb8@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: backend: make sure to NULL terminate stack buffer
Nuno Sá [Tue, 18 Feb 2025 10:31:25 +0000 (10:31 +0000)] 
iio: backend: make sure to NULL terminate stack buffer

Make sure to NULL terminate the buffer in
iio_backend_debugfs_write_reg() before passing it to sscanf(). It is a
stack variable so we should not assume it will 0 initialized.

Fixes: cdf01e0809a4 ("iio: backend: add debugFs interface")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250218-dev-iio-misc-v1-1-bf72b20a1eb8@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Mon, 17 Feb 2025 14:16:29 +0000 (14:16 +0000)] 
iio: adc: Switch to sparse friendly iio_device_claim/release_direct()

Single patch for all the relatively simple cases.

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Cc: Olivier Moysan <olivier.moysan@foss.st.com>
Cc: Phil Reid <preid@electromag.com.au>
Reviewed-by: Mike Looijmans <mike.looijmans@topic.nl>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250217141630.897334-30-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: max11410: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Mon, 17 Feb 2025 14:16:26 +0000 (14:16 +0000)] 
iio: adc: max11410: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250217141630.897334-27-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: max11410: Factor out writing of sampling frequency to simplify errro paths.
Jonathan Cameron [Mon, 17 Feb 2025 14:16:25 +0000 (14:16 +0000)] 
iio: adc: max11410: Factor out writing of sampling frequency to simplify errro paths.

Introduce __max11410_write_samp_freq() helper and use guard() to avoid
need for manual unlock of the mutex. This allows direct returns and
simplifies the resulting error handling.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250217141630.897334-26-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: max1027: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Mon, 17 Feb 2025 14:16:24 +0000 (14:16 +0000)] 
iio: adc: max1027: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://patch.msgid.link/20250217141630.897334-25-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: max1027: Move claim of direct mode up one level and use guard()
Jonathan Cameron [Mon, 17 Feb 2025 14:16:23 +0000 (14:16 +0000)] 
iio: adc: max1027: Move claim of direct mode up one level and use guard()

Move iio_device_claim_direct_mode() into the read_raw() callback
and use guard() to release a mutex. This enables simpler error
handling via direct returns.

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://patch.msgid.link/20250217141630.897334-24-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: at91-sama5d2: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Mon, 17 Feb 2025 14:16:22 +0000 (14:16 +0000)] 
iio: adc: at91-sama5d2: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Reviewed-by: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Link: https://patch.msgid.link/20250217141630.897334-23-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: at91-sama5d2: Move claim of direct mode up a level and use guard()
Jonathan Cameron [Mon, 17 Feb 2025 14:16:21 +0000 (14:16 +0000)] 
iio: adc: at91-sama5d2: Move claim of direct mode up a level and use guard()

Move iio_device_claim_direct_mode() up one layer in the call stack,
and use guard() for scope based unlocking to simplify error handling
by allowing direct returns.

Reviewed-by: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Link: https://patch.msgid.link/20250217141630.897334-22-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad_sigma_delta: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Mon, 17 Feb 2025 14:16:20 +0000 (14:16 +0000)] 
iio: adc: ad_sigma_delta: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

This is a complex function with a lot more than the release of direct
mode to unwind on error. As such no attempt made to factor out
the inner code.

Cc: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250217141630.897334-21-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad799x: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Mon, 17 Feb 2025 14:16:19 +0000 (14:16 +0000)] 
iio: adc: ad799x: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250217141630.897334-20-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad7793: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Mon, 17 Feb 2025 14:16:18 +0000 (14:16 +0000)] 
iio: adc: ad7793: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250217141630.897334-19-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad7793: Factor out core of ad7793_write_raw() to simplify error handling
Jonathan Cameron [Mon, 17 Feb 2025 14:16:17 +0000 (14:16 +0000)] 
iio: adc: ad7793: Factor out core of ad7793_write_raw() to simplify error handling

Factor out everything under the direct mode claim allowing direct returns
in error paths.  Switch sense of matching in the loop and use a continue
to reduce code indent and improve readability.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250217141630.897334-18-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad7791: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Mon, 17 Feb 2025 14:16:16 +0000 (14:16 +0000)] 
iio: adc: ad7791: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250217141630.897334-17-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad7791: Factor out core of ad7791_write_raw() to simplify error handling
Jonathan Cameron [Mon, 17 Feb 2025 14:16:15 +0000 (14:16 +0000)] 
iio: adc: ad7791: Factor out core of ad7791_write_raw() to simplify error handling

Factor out everything under the direct mode claim allowing direct returns
in error paths.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250217141630.897334-16-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad7606: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Mon, 17 Feb 2025 14:16:14 +0000 (14:16 +0000)] 
iio: adc: ad7606: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

This driver got partly converted during removal of the _scoped form.
However some more cases got added in parallel.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250217141630.897334-15-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad7768-1: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Mon, 17 Feb 2025 14:16:13 +0000 (14:16 +0000)] 
iio: adc: ad7768-1: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250217141630.897334-14-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad7768-1: Move setting of val a bit later to avoid unnecessary return value...
Jonathan Cameron [Mon, 17 Feb 2025 14:16:12 +0000 (14:16 +0000)] 
iio: adc: ad7768-1: Move setting of val a bit later to avoid unnecessary return value check

The data used is all in local variables so there is no advantage
in setting *val = ret with the direct mode claim held.
Move it later to after error check.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250217141630.897334-13-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad7192: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Mon, 17 Feb 2025 14:16:11 +0000 (14:16 +0000)] 
iio: adc: ad7192: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Cc: Alisa-Dariana Roman <alisa.roman@analog.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250217141630.897334-12-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad7192: Factor out core of ad7192_write_raw() to simplify error handling.
Jonathan Cameron [Mon, 17 Feb 2025 14:16:10 +0000 (14:16 +0000)] 
iio: adc: ad7192: Factor out core of ad7192_write_raw() to simplify error handling.

Factor out everything under the lock, use guard() for the mutex to
avoid need to manually unlock, and switch sense of matching checks
in loops to reduce indent.

There are some functional changes in here as well as the code
no longer updates the filter_freq_available if no change has
been made to the oversampling ratio.

Cc: Alisa-Dariana Roman <alisa.roman@analog.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250217141630.897334-11-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad4030: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Mon, 17 Feb 2025 14:16:09 +0000 (14:16 +0000)] 
iio: adc: ad4030: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250217141630.897334-10-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: stm32-dfsdm: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Mon, 17 Feb 2025 14:16:08 +0000 (14:16 +0000)] 
iio: adc: stm32-dfsdm: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Reviewed-by: Olivier Moysan <olivier.moysan@foss.st.com>
Link: https://patch.msgid.link/20250217141630.897334-9-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: stm32-dfsdm: Factor out core of reading INFO_RAW
Jonathan Cameron [Mon, 17 Feb 2025 14:16:07 +0000 (14:16 +0000)] 
iio: adc: stm32-dfsdm: Factor out core of reading INFO_RAW

This allows the claim on direct mode to be release in one place
rather than a lot of error paths, simplifying code.

Reviewed-by: Olivier Moysan <olivier.moysan@foss.st.com>
Link: https://patch.msgid.link/20250217141630.897334-8-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: light: Add support for AL3000a illuminance sensor
Svyatoslav Ryhel [Mon, 17 Feb 2025 14:03:35 +0000 (16:03 +0200)] 
iio: light: Add support for AL3000a illuminance sensor

AL3000a is a simple I2C-based ambient light sensor, which is
closely related to AL3010 and AL3320a, but has significantly
different way of processing data generated by the sensor.

Tested-by: Robert Eckelmann <longnoserob@gmail.com>
Tested-by: Antoni Aloy Torrens <aaloytorrens@gmail.com>
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Reviewed-by: David Heidelberg <david@ixit.cz>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20250217140336.107476-3-clamor95@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agodt-bindings: iio: light: al3010: add al3000a support
Svyatoslav Ryhel [Mon, 17 Feb 2025 14:03:34 +0000 (16:03 +0200)] 
dt-bindings: iio: light: al3010: add al3000a support

AL3000a is an ambient light sensor quite closely related to
exising AL3010 and can reuse exising schema for AL3010.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Reviewed-by: David Heidelberg <david@ixit.cz>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20250217140336.107476-2-clamor95@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: accel: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Mon, 17 Feb 2025 14:01:35 +0000 (14:01 +0000)] 
iio: accel: Switch to sparse friendly iio_device_claim/release_direct()

Single patch for the simple cases in accelerometer drivers.

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Cc: Antoniu Miclaus <antoniu.miclaus@analog.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250217140135.896574-9-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: accel: msa311: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Mon, 17 Feb 2025 14:01:34 +0000 (14:01 +0000)] 
iio: accel: msa311: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250217140135.896574-8-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: accel: msa311: Fix failure to release runtime pm if direct mode claim fails.
Jonathan Cameron [Mon, 17 Feb 2025 14:01:33 +0000 (14:01 +0000)] 
iio: accel: msa311: Fix failure to release runtime pm if direct mode claim fails.

Reorder the claiming of direct mode and runtime pm calls to simplify
handling a little.  For correct error handling, after the reorder
iio_device_release_direct_mode() must be claimed in an error occurs
in pm_runtime_resume_and_get()

Fixes: 1ca2cfbc0c33 ("iio: add MEMSensing MSA311 3-axis accelerometer driver")
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250217140135.896574-7-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: accel: kx022a: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Mon, 17 Feb 2025 14:01:32 +0000 (14:01 +0000)] 
iio: accel: kx022a: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Cc: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250217140135.896574-6-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: accel: kx022a: Factor out guts of write_raw() to allow direct returns
Jonathan Cameron [Mon, 17 Feb 2025 14:01:31 +0000 (14:01 +0000)] 
iio: accel: kx022a: Factor out guts of write_raw() to allow direct returns

Create a new utility function for the actions taken when direct mode
is held. This allows for direct returns, simplifying the code flow.

Cc: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250217140135.896574-5-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: accel: mma8452: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Mon, 17 Feb 2025 14:01:30 +0000 (14:01 +0000)] 
iio: accel: mma8452: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250217140135.896574-4-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: accel: mma8452: Factor out guts of write_raw() to simplify locking
Jonathan Cameron [Mon, 17 Feb 2025 14:01:29 +0000 (14:01 +0000)] 
iio: accel: mma8452: Factor out guts of write_raw() to simplify locking

Factoring out those parts of write_raw() in which direct mode is held
allows for direct returns on errors, simplifying the code.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250217140135.896574-3-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: accel: mma8452: Ensure error return on failure to matching oversampling ratio
Jonathan Cameron [Mon, 17 Feb 2025 14:01:28 +0000 (14:01 +0000)] 
iio: accel: mma8452: Ensure error return on failure to matching oversampling ratio

If a match was not found, then the write_raw() callback would return
the odr index, not an error. Return -EINVAL if this occurs.
To avoid similar issues in future, introduce j, a new indexing variable
rather than using ret for this purpose.

Fixes: 79de2ee469aa ("iio: accel: mma8452: claim direct mode during write raw")
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250217140135.896574-2-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agodocs: iio: add documentation for adis16550 driver
Robert Budai [Mon, 17 Feb 2025 10:57:50 +0000 (12:57 +0200)] 
docs: iio: add documentation for adis16550 driver

Add documentation for adis16550 driver which describes the driver device
files and shows how the user may use the ABI for various scenarios
(configuration, measurement, etc.).

Co-developed-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Co-developed-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Signed-off-by: Robert Budai <robert.budai@analog.com>
Link: https://patch.msgid.link/20250217105753.605465-7-robert.budai@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: imu: adis16550: add adis16550 support
Robert Budai [Mon, 17 Feb 2025 10:57:49 +0000 (12:57 +0200)] 
iio: imu: adis16550: add adis16550 support

The ADIS16550 is a complete inertial system that includes a triaxis
gyroscope and a triaxis accelerometer. Each inertial sensor in the
ADIS16550 combines industry leading MEMS only technology with signal
conditioning that optimizes dynamic performance. The factory calibration
characterizes each sensor for sensitivity, bias, and alignment. As a
result, each sensor has its own dynamic compensation formulas that
provide accurate sensor measurements.

Co-developed-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Co-developed-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Co-developed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Robert Budai <robert.budai@analog.com>
Link: https://patch.msgid.link/20250217105753.605465-6-robert.budai@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agodt-bindings: iio: Add adis16550 bindings
Robert Budai [Mon, 17 Feb 2025 10:57:48 +0000 (12:57 +0200)] 
dt-bindings: iio: Add adis16550 bindings

Document the ADIS16550 device devicetree bindings.

Co-developed-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Co-developed-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Signed-off-by: Robert Budai <robert.budai@analog.com>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://patch.msgid.link/20250217105753.605465-5-robert.budai@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: imu: adis: Add DIAG_STAT register
Robert Budai [Mon, 17 Feb 2025 10:57:47 +0000 (12:57 +0200)] 
iio: imu: adis: Add DIAG_STAT register

Some devices may have more than 16 bits of status. This patch allows the
user to specify the size of the DIAG_STAT register. It defaults to 2 if
not specified. This is mainly for backward compatibility.

Co-developed-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Co-developed-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Co-developed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Robert Budai <robert.budai@analog.com>
Link: https://patch.msgid.link/20250217105753.605465-4-robert.budai@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: imu: adis: Add reset to custom ops
Robert Budai [Mon, 17 Feb 2025 10:57:46 +0000 (12:57 +0200)] 
iio: imu: adis: Add reset to custom ops

This patch allows the custom definition of reset functionality for adis object.
It is useful in cases where the driver does not need to sleep after the reset
since it is handled by the library.

Co-developed-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Co-developed-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Co-developed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Robert Budai <robert.budai@analog.com>
Link: https://patch.msgid.link/20250217105753.605465-3-robert.budai@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: imu: adis: Add custom ops struct
Robert Budai [Mon, 17 Feb 2025 10:57:45 +0000 (12:57 +0200)] 
iio: imu: adis: Add custom ops struct

This patch introduces a custom ops struct letting users define custom read and
write functions. Some adis devices might define a completely different spi
protocol from the one used in the default implementation.

Co-developed-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Co-developed-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Co-developed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Robert Budai <robert.budai@analog.com>
Link: https://patch.msgid.link/20250217105753.605465-2-robert.budai@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: resolver: ad2s1210: use bitmap_write
David Lechner [Mon, 10 Feb 2025 22:33:36 +0000 (16:33 -0600)] 
iio: resolver: ad2s1210: use bitmap_write

Replace bitmap array access with bitmap_write.

Accessing the bitmap array directly is not recommended and now there is
a helper function that can be used.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250210-gpio-set-array-helper-v3-10-d6a673674da8@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: resolver: ad2s1210: use gpiod_multi_set_value_cansleep
David Lechner [Mon, 10 Feb 2025 22:33:35 +0000 (16:33 -0600)] 
iio: resolver: ad2s1210: use gpiod_multi_set_value_cansleep

Reduce verbosity by using gpiod_multi_set_value_cansleep() instead of
gpiod_set_array_value().

These are not called in an atomic context, so changing to the cansleep
variant is fine.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250210-gpio-set-array-helper-v3-9-d6a673674da8@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: amplifiers: hmc425a: use gpiod_multi_set_value_cansleep
David Lechner [Mon, 10 Feb 2025 22:33:34 +0000 (16:33 -0600)] 
iio: amplifiers: hmc425a: use gpiod_multi_set_value_cansleep

Reduce verbosity by using gpiod_multi_set_value_cansleep() instead of
gpiod_set_array_value_cansleep().

Passing NULL as the 3rd argument to gpiod_set_array_value_cansleep()
only needs to be done if the array was constructed manually, which is
not the case here. This change effectively replaces that argument with
st->gpios->array_info. The possible side effect of this change is that
it could make setting the GPIOs more efficient.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250210-gpio-set-array-helper-v3-8-d6a673674da8@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: ad7606: use gpiod_multi_set_value_cansleep
David Lechner [Mon, 10 Feb 2025 22:33:33 +0000 (16:33 -0600)] 
iio: adc: ad7606: use gpiod_multi_set_value_cansleep

Reduce verbosity by using gpiod_multi_set_value_cansleep() instead of
gpiod_set_array_value().

These are not called in an atomic context, so changing to the cansleep
variant is fine.

Also drop unnecessary braces while we are at it.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250210-gpio-set-array-helper-v3-7-d6a673674da8@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoMerge tag 'gpio-set-array-helper-v6.15-rc1' into togreg
Jonathan Cameron [Mon, 17 Feb 2025 13:13:11 +0000 (13:13 +0000)] 
Merge tag 'gpio-set-array-helper-v6.15-rc1' into togreg

add gpiod_multi_set_value_cansleep() to GPIO core

4 months agoiio: Drop iio_device_claim_direct_scoped() and related infrastructure
Jonathan Cameron [Sun, 9 Feb 2025 18:06:24 +0000 (18:06 +0000)] 
iio: Drop iio_device_claim_direct_scoped() and related infrastructure

Scoped conditional automated cleanup turned out to be harder to work
with than expected. Despite several attempts to find a better solution
non have surfaced. As such rip it out of the IIO code.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250209180624.701140-28-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: light: bh1745: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:23 +0000 (18:06 +0000)] 
iio: light: bh1745: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context.

Reviewed-by: Mudit Sharma <muditsharma.info@gmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250209180624.701140-27-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: imu: bmi323: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:22 +0000 (18:06 +0000)] 
iio: imu: bmi323: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context.

Cc: Julien Stephan <jstephan@baylibre.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250209180624.701140-26-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: dummy: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:21 +0000 (18:06 +0000)] 
iio: dummy: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context. Introduce two new utility functions
to allow for direct returns with claim and release of direct mode
in the caller.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250209180624.701140-25-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: dac: ad8460: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:20 +0000 (18:06 +0000)] 
iio: dac: ad8460: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context.

Cc: Mariel Tinaco <Mariel.Tinaco@analog.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250209180624.701140-24-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: dac: ad3552r-hs: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:19 +0000 (18:06 +0000)] 
iio: dac: ad3552r-hs: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context.

Cc: Angelo Dureghello <adureghello@baylibre.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250209180624.701140-23-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: chemical: ens160: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:18 +0000 (18:06 +0000)] 
iio: chemical: ens160: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context.

Reviewed-by: Gustavo Silva <gustavograzs@gmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250209180624.701140-22-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: addac: ad74413r: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:17 +0000 (18:06 +0000)] 
iio: addac: ad74413r: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context. Includes moving a mutex lock
into a function rather than around it to simplify the error handling.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250209180624.701140-21-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: ti-ads1119: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:16 +0000 (18:06 +0000)] 
iio: adc: ti-ads1119: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context.

Cc: João Paulo Gonçalves <joao.goncalves@toradex.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250209180624.701140-20-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: ti-adc161s626: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:15 +0000 (18:06 +0000)] 
iio: adc: ti-adc161s626: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250209180624.701140-19-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: rtq6056: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:14 +0000 (18:06 +0000)] 
iio: adc: rtq6056: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context

Reviewed-by: ChiYuan Huang <cy_huang@richtek.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250209180624.701140-18-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: max1363: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:13 +0000 (18:06 +0000)] 
iio: adc: max1363: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250209180624.701140-17-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: ad9467: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:12 +0000 (18:06 +0000)] 
iio: adc: ad9467: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context. Also use guard() to simplify mutex
unlock paths.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250209180624.701140-16-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: ad7779: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:11 +0000 (18:06 +0000)] 
iio: adc: ad7779: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context.

Cc: Ramona Alexandra Nechita <ramona.nechita@analog.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250209180624.701140-15-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: ad7625: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:10 +0000 (18:06 +0000)] 
iio: adc: ad7625: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context.

Reviewed-by: Trevor Gamblin <tgamblin@baylibre.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250209180624.701140-14-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: ad7606: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:09 +0000 (18:06 +0000)] 
iio: adc: ad7606: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context.

Cc: Guillaume Stols <gstols@baylibre.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250209180624.701140-13-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: ad4695: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:08 +0000 (18:06 +0000)] 
iio: adc: ad4695: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context.  In some cases code is factored
out to utility functions that can do a direct return with the
claim and release around the call.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250209180624.701140-12-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: ad4130: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:07 +0000 (18:06 +0000)] 
iio: adc: ad4130: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context.

Cc: Cosmin Tanislav <demonsingur@gmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250209180624.701140-11-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: ad4000: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:06 +0000 (18:06 +0000)] 
iio: adc: ad4000: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context.

Reviewed-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Tested-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250209180624.701140-10-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: accel: adxl367: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:05 +0000 (18:06 +0000)] 
iio: accel: adxl367: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context

In some cases there is a convenient wrapper function to which
the handling can be moved. Do that instead of introducing
another layer of wrappers. In others an outer wrapper is added
which claims direct mode, runs the original function with the
scoped claim logic removed, releases direct mode and then checks
for errors.

Cc: Cosmin Tanislav <demonsingur@gmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250209180624.701140-9-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: proximity: sx9360: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:04 +0000 (18:06 +0000)] 
iio: proximity: sx9360: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context

Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250209180624.701140-8-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: proximity: sx9324: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:03 +0000 (18:06 +0000)] 
iio: proximity: sx9324: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context

Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250209180624.701140-7-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: proximity: sx9310: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:02 +0000 (18:06 +0000)] 
iio: proximity: sx9310: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context.

Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250209180624.701140-6-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: temperature: tmp006: Stop using iio_device_claim_direct_scoped()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:01 +0000 (18:06 +0000)] 
iio: temperature: tmp006: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context.

Cc: Antoni Pokusinski <apokusinski01@gmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250209180624.701140-5-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: chemical: scd30: Switch to sparse friendly claim/release_direct()
Jonathan Cameron [Sun, 9 Feb 2025 18:06:00 +0000 (18:06 +0000)] 
iio: chemical: scd30: Switch to sparse friendly claim/release_direct()

This driver caused a false positive with __cond_lock() style solution
but is fine with the simple boolean return approach now used.

Cc: Tomasz Duszynski <tomasz.duszynski@octakon.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250209180624.701140-4-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: chemical: scd30: Use guard(mutex) to allow early returns
Jonathan Cameron [Sun, 9 Feb 2025 18:05:59 +0000 (18:05 +0000)] 
iio: chemical: scd30: Use guard(mutex) to allow early returns

Auto cleanup based release of the lock allows for simpler code flow in a
few functions with large multiplexing style switch statements and no
common operations following the switch.

Suggested-by: David Lechner <dlechner@baylibre.com>
Cc: Tomasz Duszynski <tomasz.duszynski@octakon.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250209180624.701140-3-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: core: Rework claim and release of direct mode to work with sparse.
Jonathan Cameron [Sun, 9 Feb 2025 18:05:58 +0000 (18:05 +0000)] 
iio: core: Rework claim and release of direct mode to work with sparse.

Initial thought was to do something similar to __cond_lock()

do_iio_device_claim_direct_mode(iio_dev) ? : ({ __acquire(iio_dev); 0; })
+ Appropriate static inline iio_device_release_direct_mode()

However with that, sparse generates false positives. E.g.

drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c:1811:17: warning: context imbalance in 'st_lsm6dsx_read_raw' - unexpected unlock

So instead, this patch rethinks the return type and makes it more
'conditional lock like' (which is part of what is going on under the hood
anyway) and return a boolean - true for successfully acquired, false for
did not acquire.

To allow a migration path given the rework is now non trivial, take a leaf
out of the naming of the conditional guard we currently have for IIO
device direct mode and drop the _mode postfix from the new functions giving
iio_device_claim_direct() and iio_device_release_direct()

Whilst the kernel supports __cond_acquires() upstream sparse does not
yet do so.  Hence rely on sparse expanding a static inline wrapper
to explicitly see whether __acquire() is called.

Note that even with the solution here, sparse sometimes gives false
positives. However in the few cases seen they were complex code
structures that benefited from simplification anyway.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250209180624.701140-2-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: accel: kx022a: convert to use maple tree register cache
Bo Liu [Wed, 12 Feb 2025 07:52:23 +0000 (02:52 -0500)] 
iio: accel: kx022a: convert to use maple tree register cache

The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.

Signed-off-by: Bo Liu <liubo03@inspur.com>
Acked-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/20250212075223.4164-5-liubo03@inspur.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: accel: bmi088: convert to use maple tree register cache
Bo Liu [Wed, 12 Feb 2025 07:52:22 +0000 (02:52 -0500)] 
iio: accel: bmi088: convert to use maple tree register cache

The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.

Signed-off-by: Bo Liu <liubo03@inspur.com>
Link: https://patch.msgid.link/20250212075223.4164-4-liubo03@inspur.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: accel: bma400: convert to use maple tree register cache
Bo Liu [Wed, 12 Feb 2025 07:52:21 +0000 (02:52 -0500)] 
iio: accel: bma400: convert to use maple tree register cache

The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.

Signed-off-by: Bo Liu <liubo03@inspur.com>
Link: https://patch.msgid.link/20250212075223.4164-3-liubo03@inspur.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: accel: msa311: convert to use maple tree register cache
Bo Liu [Wed, 12 Feb 2025 07:52:20 +0000 (02:52 -0500)] 
iio: accel: msa311: convert to use maple tree register cache

The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.

Signed-off-by: Bo Liu <liubo03@inspur.com>
Link: https://patch.msgid.link/20250212075223.4164-2-liubo03@inspur.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: Add driver for ADS7128 / ADS7138
Tobias Sperling [Thu, 13 Feb 2025 15:58:58 +0000 (16:58 +0100)] 
iio: adc: Add driver for ADS7128 / ADS7138

Add driver for ADS7128 and ADS7138 12-bit, 8-channel analog-to-digital
converters. These ADCs have a wide operating range and a wide feature
set. Communication is based on the I2C interface.
ADS7128 differs in the addition of further hardware features, like a
root-mean-square (RMS) and a zero-crossing-detect (ZCD) module.

Signed-off-by: Tobias Sperling <tobias.sperling@softing.com>
Link: https://patch.msgid.link/20250213-adc_ml-v4-2-66b68f8fdb8c@softing.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agodt-bindings: iio: adc: Introduce ADS7138
Tobias Sperling [Thu, 13 Feb 2025 15:58:57 +0000 (16:58 +0100)] 
dt-bindings: iio: adc: Introduce ADS7138

Add documentation for the driver of ADS7128 and ADS7138 12-bit, 8-channel
analog-to-digital converters. These ADCs have a wide operating range and
a wide feature set. Communication is based on the I2C interface.
ADS7128 differs in the addition of further hardware features, like a
root-mean-square (RMS) and a zero-crossing-detect (ZCD) module.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Tobias Sperling <tobias.sperling@softing.com>
Link: https://patch.msgid.link/20250213-adc_ml-v4-1-66b68f8fdb8c@softing.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agodocs: iio: ad4030: add documentation
Esteban Blanc [Fri, 14 Feb 2025 12:22:36 +0000 (13:22 +0100)] 
docs: iio: ad4030: add documentation

This adds a new page to document how to use the ad4030 ADC driver

Signed-off-by: Esteban Blanc <eblanc@baylibre.com>
Link: https://patch.msgid.link/20250214-eblanc-ad4630_v1-v4-6-135dd66cab6a@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: ad4030: add support for ad4632-16 and ad4632-24
Esteban Blanc [Fri, 14 Feb 2025 12:22:35 +0000 (13:22 +0100)] 
iio: adc: ad4030: add support for ad4632-16 and ad4632-24

AD4632-24 and AD4632-16 are 2 channels ADCs. Both channels are
interleaved bit per bit on SDO line.

Both of them do not have evaluation board. As such, the support added
here can't be tested. Support is provided as best effort until someone get
their hands on one.

Signed-off-by: Esteban Blanc <eblanc@baylibre.com>
Link: https://patch.msgid.link/20250214-eblanc-ad4630_v1-v4-5-135dd66cab6a@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: ad4030: add support for ad4630-24 and ad4630-16
Esteban Blanc [Fri, 14 Feb 2025 12:22:34 +0000 (13:22 +0100)] 
iio: adc: ad4030: add support for ad4630-24 and ad4630-16

AD4630-24 and AD4630-16 are 2 channels ADCs. Both channels are
interleaved bit per bit on SDO line.

Signed-off-by: Esteban Blanc <eblanc@baylibre.com>
Link: https://patch.msgid.link/20250214-eblanc-ad4630_v1-v4-4-135dd66cab6a@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: ad4030: add averaging support
Esteban Blanc [Fri, 14 Feb 2025 12:22:33 +0000 (13:22 +0100)] 
iio: adc: ad4030: add averaging support

This add support for the averaging mode of AD4030 using oversampling IIO
attribute

Signed-off-by: Esteban Blanc <eblanc@baylibre.com>
Link: https://patch.msgid.link/20250214-eblanc-ad4630_v1-v4-3-135dd66cab6a@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: ad4030: add driver for ad4030-24
Esteban Blanc [Fri, 14 Feb 2025 12:22:32 +0000 (13:22 +0100)] 
iio: adc: ad4030: add driver for ad4030-24

This adds a new driver for the Analog Devices INC. AD4030-24 ADC.

The driver implements basic support for the AD4030-24 1 channel
differential ADC with hardware gain and offset control.

Signed-off-by: Esteban Blanc <eblanc@baylibre.com>
Link: https://patch.msgid.link/20250214-eblanc-ad4630_v1-v4-2-135dd66cab6a@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agodt-bindings: iio: adc: add ADI ad4030, ad4630 and ad4632
Esteban Blanc [Fri, 14 Feb 2025 12:22:31 +0000 (13:22 +0100)] 
dt-bindings: iio: adc: add ADI ad4030, ad4630 and ad4632

This adds a binding specification for the Analog Devices Inc. AD4030,
AD4630 and AD4632 families of ADCs.

- ad4030-24 is a 1 channel SAR ADC with 24 bits of precision and a
  sampling rate of 2M samples per second
- ad4032-24 is a 1 channel SAR ADC with 24 bits of precision and a
  sampling rate of 500K samples per second
- ad4630-16 is a 2 channels SAR ADC with 16 bits of precision and a
  sampling rate of 2M samples per second
- ad4630-24 is a 2 channels SAR ADC with 24 bits of precision and a
  sampling rate of 2M samples per second
- ad4632-16 is a 2 channels SAR ADC with 16 bits of precision and a
  sampling rate of 500K samples per second
- ad4632-24 is a 2 channels SAR ADC with 24 bits of precision and a
  sampling rate of 500K samples per second

Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Esteban Blanc <eblanc@baylibre.com>
Link: https://patch.msgid.link/20250214-eblanc-ad4630_v1-v4-1-135dd66cab6a@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: ad4851: add ad485x driver
Antoniu Miclaus [Fri, 14 Feb 2025 13:19:55 +0000 (15:19 +0200)] 
iio: adc: ad4851: add ad485x driver

Add support for the AD485X a fully buffered, 8-channel simultaneous
sampling, 16/20-bit, 1 MSPS data acquisition system (DAS) with
differential, wide common-mode range inputs.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://patch.msgid.link/20250214131955.31973-10-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agodt-bindings: iio: adc: add ad4851
Antoniu Miclaus [Fri, 14 Feb 2025 13:19:54 +0000 (15:19 +0200)] 
dt-bindings: iio: adc: add ad4851

Add devicetree bindings for ad485x family.

Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://patch.msgid.link/20250214131955.31973-9-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: adi-axi-adc: add oversampling
Antoniu Miclaus [Fri, 14 Feb 2025 13:19:53 +0000 (15:19 +0200)] 
iio: adc: adi-axi-adc: add oversampling

Add support for enabling/disabling oversampling.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://patch.msgid.link/20250214131955.31973-8-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: adi-axi-adc: set data format
Antoniu Miclaus [Fri, 14 Feb 2025 13:19:52 +0000 (15:19 +0200)] 
iio: adc: adi-axi-adc: set data format

Add support for selecting the data format within the AXI ADC ip.

Add separate complatible string for the custom AD485X IP and implement
the necessary changes.

Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://patch.msgid.link/20250214131955.31973-7-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agodt-bindings: iio: adc: add ad485x axi variant
Antoniu Miclaus [Fri, 14 Feb 2025 13:19:51 +0000 (15:19 +0200)] 
dt-bindings: iio: adc: add ad485x axi variant

Add a new compatible and related bindings for the fpga-based
AD485x AXI IP core, a variant of the generic AXI ADC IP.

The AXI AD485x IP is a very similar HDL (fpga) variant of the
generic AXI ADC IP, intended to control ad485x family.

Although this is not preferred, the wildcard naming is used to
match the published firmware under the same name.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://patch.msgid.link/20250214131955.31973-6-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: adi-axi-adc: add interface type
Antoniu Miclaus [Fri, 14 Feb 2025 13:19:50 +0000 (15:19 +0200)] 
iio: adc: adi-axi-adc: add interface type

Add support for getting the interface (CMOS or LVDS) used by the AXI ADC
IP.

Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://patch.msgid.link/20250214131955.31973-5-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: backend: add API for oversampling
Antoniu Miclaus [Fri, 14 Feb 2025 13:19:49 +0000 (15:19 +0200)] 
iio: backend: add API for oversampling

Add backend support for setting oversampling ratio.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://patch.msgid.link/20250214131955.31973-4-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: backend: add support for data size set
Antoniu Miclaus [Fri, 14 Feb 2025 13:19:48 +0000 (15:19 +0200)] 
iio: backend: add support for data size set

Add backend support for setting the data size used.
This setting can be adjusted within the IP cores interfacing devices.

Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://patch.msgid.link/20250214131955.31973-3-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: backend: add API for interface get
Antoniu Miclaus [Fri, 14 Feb 2025 13:19:47 +0000 (15:19 +0200)] 
iio: backend: add API for interface get

Add backend support for obtaining the interface type used.

Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://patch.msgid.link/20250214131955.31973-2-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agogpiolib: add gpiod_multi_set_value_cansleep()
David Lechner [Mon, 10 Feb 2025 22:33:27 +0000 (16:33 -0600)] 
gpiolib: add gpiod_multi_set_value_cansleep()

Add a new gpiod_multi_set_value_cansleep() helper function with fewer
parameters than gpiod_set_array_value_cansleep().

Calling gpiod_set_array_value_cansleep() can get quite verbose. In many
cases, the first arguments all come from the same struct gpio_descs, so
having a separate function where we can just pass that cuts down on the
boilerplate.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20250210-gpio-set-array-helper-v3-1-d6a673674da8@baylibre.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
4 months agoiio: adc: ad7606: add support for writing registers when using backend
Guillaume Stols [Mon, 10 Feb 2025 16:10:59 +0000 (17:10 +0100)] 
iio: adc: ad7606: add support for writing registers when using backend

Add the logic for effectively enabling the software mode for the
iio-backend, i.e. enabling the software mode channel configuration and
implementing the register writing functions.

Signed-off-by: Guillaume Stols <gstols@baylibre.com>
Co-developed-by: Angelo Dureghello <adureghello@baylibre.com>
Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
Link: https://patch.msgid.link/20250210-wip-bl-ad7606_add_backend_sw_mode-v4-9-160df18b1da7@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: ad7606: change channel macros parameters
Guillaume Stols [Mon, 10 Feb 2025 16:10:58 +0000 (17:10 +0100)] 
iio: adc: ad7606: change channel macros parameters

Add the possibility to pass the *_available parameters to the main
macro.
This is a preparation to add the new channels for software mode and
hardware mode in iio backend mode more easily.

Signed-off-by: Guillaume Stols <gstols@baylibre.com>
Link: https://patch.msgid.link/20250210-wip-bl-ad7606_add_backend_sw_mode-v4-8-160df18b1da7@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 months agoiio: adc: ad7606: protect register access
Angelo Dureghello [Mon, 10 Feb 2025 16:10:57 +0000 (17:10 +0100)] 
iio: adc: ad7606: protect register access

Protect register (and bus) access from concurrent
read / write. Needed in the backend operating mode.

Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
Link: https://patch.msgid.link/20250210-wip-bl-ad7606_add_backend_sw_mode-v4-7-160df18b1da7@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>