]> git.ipfire.org Git - thirdparty/kernel/linux.git/log
thirdparty/kernel/linux.git
3 months agoDocumentation: ABI: add wideband filter type to sysfs-bus-iio
Jonathan Santos [Thu, 6 Mar 2025 21:01:37 +0000 (18:01 -0300)] 
Documentation: ABI: add wideband filter type to sysfs-bus-iio

The Wideband Low Ripple filter is used for AD7768-1 Driver.
Document wideband filter option into filter_type_available
attribute.

Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Link: https://patch.msgid.link/b390ec6d92dd742ace93bd8e40a0df4379b98e23.1741268122.git.Jonathan.Santos@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad7768-1: set MOSI idle state to prevent accidental reset
Jonathan Santos [Thu, 6 Mar 2025 21:00:43 +0000 (18:00 -0300)] 
iio: adc: ad7768-1: set MOSI idle state to prevent accidental reset

Datasheet recommends Setting the MOSI idle state to high in order to
prevent accidental reset of the device when SCLK is free running.
This happens when the controller clocks out a 1 followed by 63 zeros
while the CS is held low.

Check if SPI controller supports SPI_MOSI_IDLE_HIGH flag and set it.

Fixes: a5f8c7da3dbe ("iio: adc: Add AD7768-1 ADC basic support")
Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Link: https://patch.msgid.link/c2a2b0f3d54829079763a5511359a1fa80516cfb.1741268122.git.Jonathan.Santos@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad7768-1: Fix conversion result sign
Sergiu Cuciurean [Thu, 6 Mar 2025 21:00:29 +0000 (18:00 -0300)] 
iio: adc: ad7768-1: Fix conversion result sign

The ad7768-1 ADC output code is two's complement, meaning that the voltage
conversion result is a signed value.. Since the value is a 24 bit one,
stored in a 32 bit variable, the sign should be extended in order to get
the correct representation.

Also the channel description has been updated to signed representation,
to match the ADC specifications.

Fixes: a5f8c7da3dbe ("iio: adc: Add AD7768-1 ADC basic support")
Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com>
Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com>
Cc: <Stable@vger.kernel.org>
Link: https://patch.msgid.link/505994d3b71c2aa38ba714d909a68e021f12124c.1741268122.git.Jonathan.Santos@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad7124: Benefit of dev = indio_dev->dev.parent in ad7124_parse_channel_config()
Uwe Kleine-König [Tue, 4 Mar 2025 09:41:09 +0000 (10:41 +0100)] 
iio: adc: ad7124: Benefit of dev = indio_dev->dev.parent in ad7124_parse_channel_config()

Since commit a6eaf02b8274 ("iio: adc: ad7124: Switch from of specific to
fwnode based property handling") the function
ad7124_parse_channel_config() has a parameter `dev` that holds
the value `indio_dev->dev.parent`. Make use of that to shorten two code
lines.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/v7l2skqj65vbku3ebjsfndfj3atl6iqpodamios2do6q6kcagf@whmuir6fwede
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad7124: Implement system calibration
Uwe Kleine-König [Mon, 3 Mar 2025 11:47:06 +0000 (12:47 +0100)] 
iio: adc: ad7124: Implement system calibration

Allow triggering both zero-scale and full-scale calibration via sysfs in
the same way as it's done for ad7173.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/20250303114659.1672695-18-u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad7124: Implement internal calibration at probe time
Uwe Kleine-König [Mon, 3 Mar 2025 11:47:05 +0000 (12:47 +0100)] 
iio: adc: ad7124: Implement internal calibration at probe time

Use the calibration function provided by the ad_sigma_delta shim to
calibrate all channels at probe time.

For measurements with gain 1 (i.e. if CONFIG_x.PGA = 0) full-scale
calibrations are not supported and the reset default value of the GAIN
register is supposed to be used then.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/20250303114659.1672695-17-u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad_sigma_delta: Add error checking for ad_sigma_delta_set_channel()
Uwe Kleine-König [Mon, 3 Mar 2025 11:47:04 +0000 (12:47 +0100)] 
iio: adc: ad_sigma_delta: Add error checking for ad_sigma_delta_set_channel()

All other calls to ad_sigma_delta_set_channel() in ad_sigma_delta.c
check the return value afterwards. Do it for all calls.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/20250303114659.1672695-16-u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad4130: Adapt internal names to match official filter_type ABI
Uwe Kleine-König [Mon, 3 Mar 2025 11:47:03 +0000 (12:47 +0100)] 
iio: adc: ad4130: Adapt internal names to match official filter_type ABI

Recently the interface to to select a filter was officially blessed to
use "filter_type". Adapt the naming of several functions accordingly to
make the new standard more present and so make the driver a better
template for other drivers. Apart from the comment update this is just
s/filter_mode/filter_type/.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/20250303114659.1672695-15-u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad7173: Fix comparison of channel configs
Uwe Kleine-König [Mon, 3 Mar 2025 11:47:02 +0000 (12:47 +0100)] 
iio: adc: ad7173: Fix comparison of channel configs

Checking the binary representation of two structs (of the same type)
for equality doesn't have the same semantic as comparing all members for
equality. The former might find a difference where the latter doesn't in
the presence of padding or when ambiguous types like float or bool are
involved. (Floats typically have different representations for single
values, like -0.0 vs +0.0, or 0.5 * 2² vs 0.25 * 2³. The type bool has
at least 8 bits and the raw values 1 and 2 (probably) both evaluate to
true, but memcmp finds a difference.)

When searching for a channel that already has the configuration we need,
the comparison by member is the one that is needed.

Convert the comparison accordingly to compare the members one after
another. Also add a static_assert guard to (somewhat) ensure that when
struct ad7173_channel_config::config_props is expanded, the comparison
is adapted, too.

This issue is somewhat theoretic, but using memcmp() on a struct is a
bad pattern that is worth fixing.

Fixes: 76a1e6a42802 ("iio: adc: ad7173: add AD7173 driver")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/20250303114659.1672695-14-u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad7124: Fix comparison of channel configs
Uwe Kleine-König [Mon, 3 Mar 2025 11:47:01 +0000 (12:47 +0100)] 
iio: adc: ad7124: Fix comparison of channel configs

Checking the binary representation of two structs (of the same type)
for equality doesn't have the same semantic as comparing all members for
equality. The former might find a difference where the latter doesn't in
the presence of padding or when ambiguous types like float or bool are
involved. (Floats typically have different representations for single
values, like -0.0 vs +0.0, or 0.5 * 2² vs 0.25 * 2³. The type bool has
at least 8 bits and the raw values 1 and 2 (probably) both evaluate to
true, but memcmp finds a difference.)

When searching for a channel that already has the configuration we need,
the comparison by member is the one that is needed.

Convert the comparison accordingly to compare the members one after
another. Also add a static_assert guard to (somewhat) ensure that when
struct ad7124_channel_config::config_props is expanded, the comparison
is adapted, too.

This issue is somewhat theoretic, but using memcmp() on a struct is a
bad pattern that is worth fixing.

Fixes: 7b8d045e497a ("iio: adc: ad7124: allow more than 8 channels")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/20250303114659.1672695-13-u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad4130: Fix comparison of channel setups
Uwe Kleine-König [Mon, 3 Mar 2025 11:47:00 +0000 (12:47 +0100)] 
iio: adc: ad4130: Fix comparison of channel setups

Checking the binary representation of two structs (of the same type)
for equality doesn't have the same semantic as comparing all members for
equality. The former might find a difference where the latter doesn't in
the presence of padding or when ambiguous types like float or bool are
involved. (Floats typically have different representations for single
values, like -0.0 vs +0.0, or 0.5 * 2² vs 0.25 * 2³. The type bool has
at least 8 bits and the raw values 1 and 2 (probably) both evaluate to
true, but memcmp finds a difference.)

When searching for a channel that already has the configuration we need,
the comparison by member is the one that is needed.

Convert the comparison accordingly to compare the members one after
another. Also add a static_assert guard to (somewhat) ensure that when
struct ad4130_setup_info is expanded, the comparison is adapted, too.

This issue is somewhat theoretic, but using memcmp() on a struct is a
bad pattern that is worth fixing.

Fixes: 62094060cf3a ("iio: adc: ad4130: add AD4130 driver")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/20250303114659.1672695-12-u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad_sigma_delta: Disable channel after calibration
Uwe Kleine-König [Mon, 3 Mar 2025 11:46:59 +0000 (12:46 +0100)] 
iio: adc: ad_sigma_delta: Disable channel after calibration

The function ad_sd_calibrate() enables the channel to calibrate at
function entry but doesn't disable it on exit. This is problematic
because if two (or more) channels are calibrated in a row, the second
calibration isn't executed as intended as the first (still enabled)
channel is recalibrated and after the first irq (i.e. when the
calibration of the first channel completed) the calibration is aborted.

This currently affects ad7173 only, as the other drivers using
ad_sd_calibrate() never have more than one channel enabled at a time.

To fix this, disable the calibrated channel after calibration.

Fixes: 031bdc8aee01 ("iio: adc: ad7173: add calibration support")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/20250303114659.1672695-11-u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agodocs: iio: add AD7191
Alisa-Dariana Roman [Fri, 28 Feb 2025 14:06:02 +0000 (16:06 +0200)] 
docs: iio: add AD7191

Add documentation for AD7191 driver.

Signed-off-by: Alisa-Dariana Roman <alisa.roman@analog.com>
Reviewed-by: David Lechner<dlechner@baylibre.com>
Link: https://patch.msgid.link/20250228141327.262488-4-alisa.roman@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad7191: add AD7191
Alisa-Dariana Roman [Fri, 28 Feb 2025 14:06:01 +0000 (16:06 +0200)] 
iio: adc: ad7191: add AD7191

AD7191 is a pin-programmable, ultra-low noise 24-bit sigma-delta ADC
designed for precision bridge sensor measurements. It features two
differential analog input channels, selectable output rates,
programmable gain, internal temperature sensor and simultaneous
50Hz/60Hz rejection.

Signed-off-by: Alisa-Dariana Roman <alisa.roman@analog.com>
Reviewed-by: David Lechner<dlechner@baylibre.com>
Link: https://patch.msgid.link/20250228141327.262488-3-alisa.roman@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agodt-bindings: iio: adc: add AD7191
Alisa-Dariana Roman [Fri, 28 Feb 2025 14:06:00 +0000 (16:06 +0200)] 
dt-bindings: iio: adc: add AD7191

AD7191 is a pin-programmable, ultra-low noise 24-bit sigma-delta ADC
designed for precision bridge sensor measurements. It features two
differential analog input channels, selectable output rates,
programmable gain, internal temperature sensor and simultaneous
50Hz/60Hz rejection.

Signed-off-by: Alisa-Dariana Roman <alisa.roman@analog.com>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Reviewed-by: David Lechner<dlechner@baylibre.com>
Link: https://patch.msgid.link/20250228141327.262488-2-alisa.roman@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agostaging: iio: accel: adis16240: Drop driver for this impact sensor
Jonathan Cameron [Sat, 22 Feb 2025 15:20:21 +0000 (15:20 +0000)] 
staging: iio: accel: adis16240: Drop driver for this impact sensor

Whilst an interesting part, no one has done significant work on this
driver since 2019.  The recent changes are all as a result of adis library
improvements having to incorporate this device.

https://www.analog.com/en/products/adis16240.html now lists this part
as obsolete so the chances of anyone working on it are likely to be greatly
reduced.

So drop it.  We can always bring it back if anyone does have interest in
this device and is willing to invest the time to make it suitable for a
staging graduation.  How to handle the hardware triggered short bursts
of capture has never been resolved and is a somewhat challenging ABI design
problem.

Cc: Nuno Sa <nuno.sa@analog.com>
Cc: Rodrigo Carvalho <rodrigorsdc@gmail.com>
Link: https://patch.msgid.link/20250222152021.1039675-1-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad7192: Grab direct mode for calibration
Uwe Kleine-König [Thu, 27 Feb 2025 11:35:28 +0000 (12:35 +0100)] 
iio: adc: ad7192: Grab direct mode for calibration

While a calibration is running, better don't make the device do anything
else.

To enforce that, grab direct mode during calibration.

Fixes: 42776c14c692 ("staging: iio: adc: ad7192: Add system calibration support")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/8aade802afca6a89641e24c1ae1d4b8d82cff58d.1740655250.git.u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad7173: Grab direct mode for calibration
Uwe Kleine-König [Thu, 27 Feb 2025 11:35:27 +0000 (12:35 +0100)] 
iio: adc: ad7173: Grab direct mode for calibration

While a calibration is running, better don't make the device do anything
else.

To enforce that, grab direct mode during calibration.

Fixes: 031bdc8aee01 ("iio: adc: ad7173: add calibration support")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/8319fa2dc881c9899d60db4eba7fe8e984716617.1740655250.git.u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agodocs: iio: ad7380: add adaq4381-4
Julien Stephan [Wed, 26 Feb 2025 14:50:05 +0000 (15:50 +0100)] 
docs: iio: ad7380: add adaq4381-4

adaq4381-4 is the 14 bits version of adaq4380-1 chip. Add it to the
documentation.

Signed-off-by: Julien Stephan <jstephan@baylibre.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250226-ad7380-add-adaq4381-4-support-v1-3-f350ab872d37@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agodt-bindings: iio: adc: ad7380: add adaq4381-4 compatible parts
Julien Stephan [Wed, 26 Feb 2025 14:50:04 +0000 (15:50 +0100)] 
dt-bindings: iio: adc: ad7380: add adaq4381-4 compatible parts

adaq4381-4 is the 14 bits version of adaq4380-1 chip. Add support for
it.

Signed-off-by: Julien Stephan <jstephan@baylibre.com>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250226-ad7380-add-adaq4381-4-support-v1-2-f350ab872d37@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad7380: add adaq4381-4 support
Julien Stephan [Wed, 26 Feb 2025 14:50:03 +0000 (15:50 +0100)] 
iio: adc: ad7380: add adaq4381-4 support

adaq4381-4 is the 14 bits version of adaq4380-1 chip. Add support for
it.

Signed-off-by: Julien Stephan <jstephan@baylibre.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250226-ad7380-add-adaq4381-4-support-v1-1-f350ab872d37@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: rockchip_saradc: add rk3562
Simon Xue [Thu, 27 Feb 2025 11:03:43 +0000 (19:03 +0800)] 
iio: adc: rockchip_saradc: add rk3562

rk3562 is using v2 saradc with 8 channels.

Signed-off-by: Simon Xue <xxm@rock-chips.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Link: https://patch.msgid.link/20250227110343.2342017-2-kever.yang@rock-chips.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agodt-bindings: iio: adc: Add rockchip,rk3562-saradc string
Kever Yang [Thu, 27 Feb 2025 11:03:42 +0000 (19:03 +0800)] 
dt-bindings: iio: adc: Add rockchip,rk3562-saradc string

Add rockchip,rk3562-saradc compatible string.
The saradc on rk3562 is v2 controller, with 10bit width which is different
with rk3588.

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://patch.msgid.link/20250227110343.2342017-1-kever.yang@rock-chips.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad4030: fix error pointer dereference in probe()
Dan Carpenter [Fri, 28 Feb 2025 09:35:40 +0000 (12:35 +0300)] 
iio: adc: ad4030: fix error pointer dereference in probe()

The intention here was obviously to return an error if devm_regmap_init()
fails, but the return statement was accidentally left out.  This leads to
an error pointer dereference when we call:

ret = ad4030_detect_chip_info(st);

Add the return statement.

Fixes: ec25cf6f1ee3 ("iio: adc: ad4030: add support for ad4632-16 and ad4632-24")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/cc67cee7-9c65-46d2-aae3-f860fc3cc461@stanley.mountain
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: light: Fix spelling mistake "regist" -> "register"
Colin Ian King [Fri, 28 Feb 2025 09:02:28 +0000 (09:02 +0000)] 
iio: light: Fix spelling mistake "regist" -> "register"

There are spelling mistakes in dev_err messages. Fix them.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Link: https://patch.msgid.link/20250228090228.679535-1-colin.i.king@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: buffer-dma: Fix docstrings
Folker Schwesinger [Thu, 27 Feb 2025 19:27:53 +0000 (20:27 +0100)] 
iio: buffer-dma: Fix docstrings

Fix a typo in the docstring of iio_dma_buffer_read() and fix what looks
like a copy-and-paste error in the iio_dma_buffer_write() docstring.

Signed-off-by: Folker Schwesinger <dev@folker-schwesinger.de>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/D83IPSTKYWNB.1PUBV1530XI86@folker-schwesinger.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: rockchip_saradc: Add support for RK3528
Jonas Karlman [Thu, 27 Feb 2025 18:40:51 +0000 (18:40 +0000)] 
iio: adc: rockchip_saradc: Add support for RK3528

The Successive Approximation ADC (SARADC) in RK3528 uses the v2
controller and support:
- 10-bit resolution
- Up to 1MS/s sampling rate
- 4 single-ended input channels
- Current consumption: 0.5mA @ 1MS/s

Add support for the 4 channels of 10-bit resolution supported by SARADC
in RK3528.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Link: https://patch.msgid.link/20250227184058.2964204-3-jonas@kwiboo.se
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agodt-bindings: iio: adc: Add rockchip,rk3528-saradc variant
Jonas Karlman [Thu, 27 Feb 2025 18:40:50 +0000 (18:40 +0000)] 
dt-bindings: iio: adc: Add rockchip,rk3528-saradc variant

The Successive Approximation ADC (SARADC) in RK3528 uses the v2
controller and support:
- 10-bit resolution
- Up to 1MS/s sampling rate
- 4 single-ended input channels
- Current consumption: 0.5mA @ 1MS/s

Add a rockchip,rk3562-saradc compatible string for the 4 channels of
10-bit resolution supported by SARADC in RK3528.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Link: https://patch.msgid.link/20250227184058.2964204-2-jonas@kwiboo.se
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoMAINTAINERS: remove adi,ad7606.yaml from SEPS525
David Lechner [Mon, 3 Mar 2025 14:39:57 +0000 (14:39 +0000)] 
MAINTAINERS: remove adi,ad7606.yaml from SEPS525

Remove Documentation/devicetree/bindings/iio/adc/adi,ad7606.yaml from
STAGING - SEPS525 LCD CONTROLLER DRIVERS. This was likley a copy/paste
mistake. There is no bindings file for SEPS525 since it is only in
staging.

The removed file matches Documentation/devicetree/bindings/iio/*/adi,*
under ANALOG DEVICES INC IIO DRIVERS already so wasn't just misplaced.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250303-maintainers-remove-adi-ad7606-yaml-from-seps525-lcd-controller-v1-1-a4e4f1b824ab@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: imu: adis: fix uninitialized symbol warning
sunliming [Tue, 4 Mar 2025 06:05:18 +0000 (14:05 +0800)] 
iio: imu: adis: fix uninitialized symbol warning

Fix below kernel warning:
smatch warnings:
drivers/iio/imu/adis.c:319 __adis_check_status() error: uninitialized symbol 'status_16'.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: sunliming <sunliming@kylinos.cn>
Link: https://patch.msgid.link/20250304060518.1834910-1-sunliming@linux.dev
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: ad4851: Fix signedness bug in ad4851_calibrate()
Dan Carpenter [Fri, 28 Feb 2025 09:36:42 +0000 (12:36 +0300)] 
iio: adc: ad4851: Fix signedness bug in ad4851_calibrate()

The "c" variable is used to store error codes from ad4851_find_opt()
so it has to be signed for the error handling to work.  Change it
to type int.

Fixes: 6250803fe2ec ("iio: adc: ad4851: add ad485x driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/f5e260e9-d7a8-4dae-b7ea-f1bbb1760e60@stanley.mountain
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: accel: adxl345: reorganize irq handler
Lothar Rubusch [Thu, 20 Feb 2025 10:42:22 +0000 (10:42 +0000)] 
iio: accel: adxl345: reorganize irq handler

Reorganize the IRQ handler. Move the overrun handling to the bottom.
Overrun leads to reset the interrupt register. This also happens at
evaluation of a particular interrupt event. First evaluate an event
if possible, then fall back to overrun handling. Additionally simplify
fetching the interrupt status function.

Both is in preparation to build interrupt handling up for the handling
of different detected events, implemented in follow up patches.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20250220104234.40958-4-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: accel: adxl345: add debug register access
Lothar Rubusch [Thu, 20 Feb 2025 10:42:21 +0000 (10:42 +0000)] 
iio: accel: adxl345: add debug register access

Add the possibility to verify the content of the configuration
registers of the sensor in preparation for upcomming feature
implementations.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20250220104234.40958-3-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: accel: adxl345: reorganize measurement enable
Lothar Rubusch [Thu, 20 Feb 2025 10:42:20 +0000 (10:42 +0000)] 
iio: accel: adxl345: reorganize measurement enable

Move the measurement enable function up in order to have it generically
available.

This is a preparation for upcomming patches. Particular features need
to have measuring off while changing settings, and turned on again
afterwards.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20250220104234.40958-2-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: imu: bmi270: add support for data ready interrupt trigger
Gustavo Silva [Fri, 28 Feb 2025 23:03:50 +0000 (20:03 -0300)] 
iio: imu: bmi270: add support for data ready interrupt trigger

The BMI270 sensor provides two interrupt pins that can be used for
different interrupt sources, including a data ready signal. Add support
for configuring one the pins as a trigger source.

The interrupt pin can be configured with various options: active high or
low, push-pull or open-drain, and latched or non-latched.

Acked-by: Alex Lanzano <lanzano.alex@gmail.com>
Signed-off-by: Gustavo Silva <gustavograzs@gmail.com>
Link: https://patch.msgid.link/20250228-bmi270-irq-v2-3-3f97a4e8f551@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: imu: bmi270: rename variable bmi270_device to data
Gustavo Silva [Fri, 28 Feb 2025 23:03:49 +0000 (20:03 -0300)] 
iio: imu: bmi270: rename variable bmi270_device to data

Rename all instances of 'struct bmi270_data' to 'data', to ensure
consistency across the driver.
Also rename bmi270_data::data to bmi270_data::buffer to avoid naming
conflicts.

Acked-by: Alex Lanzano <lanzano.alex@gmail.com>
Signed-off-by: Gustavo Silva <gustavograzs@gmail.com>
Link: https://patch.msgid.link/20250228-bmi270-irq-v2-2-3f97a4e8f551@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoDocumentation: iio: Add ADC documentation
Marcelo Schmitt [Wed, 19 Feb 2025 21:00:56 +0000 (18:00 -0300)] 
Documentation: iio: Add ADC documentation

ADC inputs can be classified into a few different types according to how
they measure the input signal, how restrained the signal is, and number of
input pins. Even though datasheets tend to provide many details about their
inputs and measurement procedures, it may not always be clear how to model
those inputs into IIO channels.

For example, some differential ADCs can have their inputs configured into
pseudo-differential channels. In that configuration, only one input
connects to the signal of interest as opposed to using two inputs of a
differential input configuration. Datasheets sometimes also refer to
pseudo-differential inputs as single-ended inputs even though they have
distinct physical configuration and measurement procedure.

Document consolidated ADC input types and how they are usually described
and supported in device tree and IIO, respectively.

Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/e6ac2a595f06ba2d5ff0eb86e5895479c9dd797f.1739998491.git.marcelo.schmitt@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: adc: Include cleanup.h when using guard()
Matti Vaittinen [Fri, 28 Feb 2025 13:14:03 +0000 (15:14 +0200)] 
iio: adc: Include cleanup.h when using guard()

Directly include the cleanup.h for the guard() instead of relying it to
be included via other files.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/5b352ce7241e5904a317dd26950c7cd4daa59fc0.1740748394.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: imu: bmi270: move private struct declaration to source file
Gustavo Silva [Wed, 19 Feb 2025 23:54:45 +0000 (20:54 -0300)] 
iio: imu: bmi270: move private struct declaration to source file

The device's private data struct is currently declared in the header
file, but it does not need to be exposed there. Move it to the driver's
core source file to avoid unnecessary #include directives or forward
declarations in the header.

Signed-off-by: Gustavo Silva <gustavograzs@gmail.com>
Acked-by: Alex Lanzano <lanzano.alex@gmail.com>
Link: https://patch.msgid.link/20250219-bmi270-irq-v1-1-145d02bbca3b@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: dac: adi-axi-dac: add io_mode check
Angelo Dureghello [Wed, 19 Feb 2025 18:57:43 +0000 (19:57 +0100)] 
iio: dac: adi-axi-dac: add io_mode check

Add safe check to the high bound of the enum values,

Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
Link: https://patch.msgid.link/20250219-wip-bl-axi-dac-add-enum-check-v1-1-8de9db0b3b1b@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 months agoiio: gyro: bmg160_i2c: add BMI088 to of_match_table
Jun Yan [Thu, 20 Feb 2025 16:50:01 +0000 (00:50 +0800)] 
iio: gyro: bmg160_i2c: add BMI088 to of_match_table

BMI088 is missing from the of_match_table. Let's complete it.

Signed-off-by: Jun Yan <jerrysteve1101@gmail.com>
Link: https://patch.msgid.link/20250220165001.273325-3-jerrysteve1101@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
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>
3 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>
3 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>
3 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>
3 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>
3 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>