Antoniu Miclaus [Mon, 2 Feb 2026 11:25:51 +0000 (13:25 +0200)]
iio: adc: ad4080: remove unused dec_rate field
Remove unused dec_rate field from ad4080_state struct.
The driver reads/writes decimation rate directly from
hardware registers via ad4080_get_dec_rate() and
ad4080_set_dec_rate() functions.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
iio: sca3000: manage device registration with devm helper
Convert the iio registration to use devm_* helpers so the probe no
longer needs a separate cleanup path and remove callback can also drop
the unregister. After this there is no need for having a remove
callback, so remote it.
No functional change intended.
Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com> Reviewed-by: David Lechner <dlechner@baylibe.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
iio: sca3000: stop interrupts via devm_add_action_or_reset()
Used devm_add_action_or_reset() for shutting down the interrupts.
Make sca3000_stop_all_interrupts() return void now that it always hooks
into devm cleanup.
No functional change intended.
Suggested-by: David Lechner <dlechner@baylibre.com> Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Convert the threaded IRQ registration to devm_request_threaded_irq() so
that the probe and remove paths can drop manual freeing of irqs.
No functionality change.
Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Andy Shevchenko [Sun, 9 Nov 2025 19:24:36 +0000 (20:24 +0100)]
iio: imu: inv_icm42600: Convert to uXX and sXX integer types
The driver has a some use of intXX_t and uintXX_t types which is
not the pattern we use in the IIO subsystem. Switch the driver
to use kernel internal types for that. No functional changes.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Antoniu Miclaus [Thu, 29 Jan 2026 18:14:52 +0000 (20:14 +0200)]
iio: pressure: hsc030pa: Improve i2c_transfer return value handling
The i2c_transfer() function returns the number of messages
successfully transferred. The function sends 1 message but checks
for ret == 2, which can never be true.
In practice this has no impact since the caller checks ret < 0,
and the erroneous return value of 1 is not treated as an error.
Improve the return value handling to properly distinguish between
I2C errors and unexpected transfer counts.
Antoniu Miclaus [Fri, 30 Jan 2026 13:50:05 +0000 (15:50 +0200)]
iio: frequency: admv4420: return proper error code from admv4420_calc_parameters()
Return -EINVAL instead of -1 when no valid PLL parameters solution is
found. Using standard kernel error codes ensures consistency and proper
error propagation through the call chain.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Neel Bullywon [Sat, 28 Feb 2026 17:23:20 +0000 (12:23 -0500)]
iio: magnetometer: bmc150_magn: use automated cleanup for mutex
Use guard() and scoped_guard() to replace manual mutex lock/unlock
calls. This simplifies error handling and ensures RAII-style cleanup.
guard() is used in read_raw, write_raw, trig_reen, and
trigger_set_state. Case blocks using guard() in read_raw and write_raw
are wrapped in braces at the case label level to ensure clear scope for
the cleanup guards.
A bmc150_magn_set_power_mode_locked() helper is added to deduplicate
the lock-call-unlock pattern used by remove, runtime_suspend, suspend,
and resume.
The trigger_handler function is left unchanged as mixing guard() with
goto error paths can be fragile.
Signed-off-by: Neel Bullywon <neelb2403@gmail.com> Acked-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Bruno Martins [Sun, 1 Mar 2026 21:28:26 +0000 (21:28 +0000)]
staging: iio: ad7816: Replace sprintf() with sysfs_emit()
As stated in Documentation/filesystems/sysfs.rst:
'New implementations of show() methods should only use sysfs_emit() or
sysfs_emit_at() when formatting the value to be returned to user space.'
Replace sprintf with sysfs_emit in the following sysfs show functions:
- ad7816_show_mode()
- ad7816_show_available_modes()
- ad7816_show_channel()
- ad7816_show_value()
- ad7816_show_oti()
Signed-off-by: Bruno Martins <ehanoc@protonmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
The ADE9000_ST_ERROR macro references ADE9000_ST1_ERROR0
through ADE9000_ST1_ERROR3, but the actual defined symbols
use the BIT suffix. Since this macro is currently unused
in the driver, remove it entirely rather than fixing the names.
It can be reintroduced in a future patch when it is actually needed.
The individual error bit definitions (bits 28-31 of the STATUS1
register at 0x403) are retained as they follow the convention of
defining all register fields.
Reference: ADE9000 datasheet (Rev. B, Page 61), STATUS1 register
(0x403), bits 28-31 define ERROR0 through ERROR3 status flags.
Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Felix Gu [Mon, 2 Mar 2026 17:07:29 +0000 (01:07 +0800)]
iio: adc: ti-ads1119: Drop redundant error message
devm_request_threaded_irq already prints an error message when failure,
so the error message is redundant, drop it.
Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Felix Gu <ustc.gu@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Bhargav Joshi [Sat, 28 Feb 2026 19:14:00 +0000 (00:44 +0530)]
iio: hid-sensor-gyro-3d: fix typo in array name
The array 'gryo_3d_sensitivity_addresses' has a clear spelling mistake
in its prefix. Rename it to 'gyro_3d_sensitivity_addresses' to correctly
match the naming convention.
Signed-off-by: Bhargav Joshi <rougueprince47@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Jonathan Santos [Mon, 23 Feb 2026 11:59:53 +0000 (08:59 -0300)]
iio: adc: ad7768-1: add support for SPI offload
The AD7768-1 family supports sampling rates up to 1 MSPS, which exceeds
the capabilities of conventional triggered buffer operations due to SPI
transaction overhead and interrupt latency.
Add SPI offload support to enable hardware-accelerated data acquisition
that bypasses software SPI transactions using continuous data streaming.
Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Jonathan Santos [Mon, 23 Feb 2026 11:59:44 +0000 (08:59 -0300)]
iio: adc: ad7768-1: disable IRQ autoenable
The device continuously converts data while powered up, generating
interrupts in the background. Configure the IRQ to be enabled and
disabled manually as needed to avoid unnecessary CPU load.
Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Jonathan Santos [Mon, 23 Feb 2026 11:59:35 +0000 (08:59 -0300)]
iio: adc: ad7768-1: remove switch to one-shot mode
wideband low ripple FIR Filter is not available in one-shot mode. In
order to make direct reads work for all filter options, remove the
switch for one-shot mode and guarantee device is always in continuous
conversion mode.
Fixes: fb1d3b24ebf5 ("iio: adc: ad7768-1: add filter type and oversampling ratio attributes") Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Jonathan Santos [Mon, 23 Feb 2026 11:59:26 +0000 (08:59 -0300)]
iio: adc: ad7768-1: fix one-shot mode data acquisition
According to the datasheet, one-shot mode requires a SYNC_IN pulse to
trigger a new sample conversion. In the current implementation, No sync
pulse was sent after switching to one-shot mode and reinit_completion()
was called before mode switching, creating a race condition where spurious
interrupts during mode change could trigger completion prematurely.
Fix by sending a sync pulse after configuring one-shot mode and
reinit_completion() to ensure it only waits for the actual conversion
completion.
Fixes: a5f8c7da3dbe ("iio: adc: Add AD7768-1 ADC basic support") Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Marcelo Schmitt [Mon, 23 Feb 2026 17:10:23 +0000 (14:10 -0300)]
iio: adc: ad4030: Add support for ADAQ4216 and ADAQ4224
ADAQ4216 and ADAQ4224 are similar to AD4030, but feature a PGA circuitry
that scales the analog input signal prior to it reaching the ADC. The PGA
is controlled through a pair of pins (A0 and A1) whose state define the
gain that is applied to the input signal.
Add support for ADAQ4216 and ADAQ4224. Provide a list of PGA options
through the IIO device channel scale available interface and enable control
of the PGA through the channel scale interface.
Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Marcelo Schmitt [Mon, 23 Feb 2026 17:10:01 +0000 (14:10 -0300)]
dt-bindings: iio: adc: adi,ad4030: Add ADAQ4216 and ADAQ4224
ADAQ4216 and ADAQ4224 are similar to AD4030 except that ADAQ devices have a
PGA (programmable gain amplifier) that scales the input signal prior to it
reaching the ADC inputs. The PGA is controlled through a couple of pins (A0
and A1) that set one of four possible signal gain configurations.
Marcelo Schmitt [Mon, 23 Feb 2026 17:09:47 +0000 (14:09 -0300)]
iio: adc: ad4030: Add SPI offload support
AD4030 and similar ADCs can capture data at sample rates up to 2 mega
samples per second (MSPS). Not all SPI controllers are able to achieve such
high throughputs and even when the controller is fast enough to run
transfers at the required speed, it may be costly to the CPU to handle
transfer data at such high sample rates. Add SPI offload support for AD4030
and similar ADCs to enable data capture at maximum sample rates.
Note that a pair of PWM devices are used for the supported setup. One of
the PWM goes to the ADC CNV pin to initiate conversions while the other PWM
is connected to the SPI offload trigger to signal when to fetch data from
the peripheral. Note also that the PWMs must be somewhat synchronized such
to make the controller run transfers only when ADC sample data is
available. See Documentation/iio/ad4030.rst for details.
Reviewed-by: David Lechner <dlechner@baylibre.com> Co-developed-by: Trevor Gamblin <tgamblin@baylibre.com> Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com> Co-developed-by: Axel Haslam <ahaslam@baylibre.com> Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Marcelo Schmitt [Mon, 23 Feb 2026 17:09:31 +0000 (14:09 -0300)]
dt-bindings: iio: adc: adi,ad4030: Add PWM
In setups designed for high speed data rate capture, a PWM is used to
generate the CNV signal that issues data captures from the ADC. Document
the use of a PWM for AD4030 and similar devices.
Reviewed-by: David Lechner <dlechner@baylibre.com> Acked-by: Conor Dooley <conor.dooley@microchip.com> Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Taha Ed-Dafili [Thu, 26 Feb 2026 15:11:06 +0000 (15:11 +0000)]
docs: iio: adxl345: update event attributes and scaling math
Update the documentation to reflect the recent driver additions for
event scaling and the double tap threshold value, alongside correcting
existing technical errors in scale calculations.
Key changes:
- Fix the 62.5 g/LSB typo to 62.5 mg/LSB and add SI unit conversion.
- Correct decimal precision of in_accel_scale and
in_accel_scale_available to match the actual SI unit (m/s^2)
values reported by the driver.
- Document the newly generated event scale attributes in the ABI table
(e.g., in_accel_mag_rising_scale, in_accel_gesture_singletap_scale).
- Document the newly exposed in_accel_gesture_doubletap_value attribute.
- Add a sysfs example showing how to read and interpret the newly
implemented event scale factor.
Suggested-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Taha Ed-Dafili <0rayn.dev@gmail.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Taha Ed-Dafili [Thu, 26 Feb 2026 15:11:05 +0000 (15:11 +0000)]
iio: accel: adxl345: Implement event scaling for ABI compliance
The ADXL345 uses a fixed threshold resolution of 62.5 mg/LSB for
event-related registers. Previously, the driver reported raw
values without a scale factor.
Implement IIO_EV_INFO_SCALE for all event types to provide the
conversion factor (0.612915 m/s^2) as required by the IIO ABI.
Consequently, remove the obsolete comment in adxl345_read_event_value()
which stated that the scale factor is not applied.
Add explicit write rejection for IIO_EV_INFO_SCALE in
adxl345_write_event_value() returning -EINVAL.
Suggested-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Taha Ed-Dafili <0rayn.dev@gmail.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Taha Ed-Dafili [Thu, 26 Feb 2026 15:11:04 +0000 (15:11 +0000)]
iio: accel: adxl345: Expose IIO_EV_INFO_VALUE for double tap
The ADXL345 uses a single hardware register (ADXL345_REG_THRESH_TAP) to
store the threshold for both single tap and double tap events.
Currently, the driver only exposes the IIO_EV_INFO_VALUE attribute for
the single tap event.
However, the IIO ABI dictates that if an event is supported, its
associated configuration attributes should be exposed to userspace. This
applies even if writing to one channel property alters the value of
another due to shared underlying hardware state.
Add IIO_EV_INFO_VALUE to the double tap event specification to ensure
full ABI compliance.
Suggested-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Taha Ed-Dafili <0rayn.dev@gmail.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Taha Ed-Dafili [Thu, 26 Feb 2026 15:11:03 +0000 (15:11 +0000)]
iio: core: Add IIO_EV_INFO_SCALE to event info
Implement support for IIO_EV_INFO_SCALE in the internal enum
iio_event_info to allow proper ABI compliance.
This allows drivers (like the ADXL345) to expose event scale
attributes using the standard IIO ABI rather than manual
device attributes.
Signed-off-by: Taha Ed-Dafili <0rayn.dev@gmail.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Taha Ed-Dafili [Thu, 26 Feb 2026 15:11:02 +0000 (15:11 +0000)]
docs: iio: adxl345: grammar and formatting cleanups
Correct several grammatical errors, typos, and pluralization issues
throughout the ADXL345 documentation.
Key changes include:
- Changing 'generic' to 'general-purpose'
- Correcting 'axis' to 'axes' in multiple tables and descriptions
- Improving phrasing in the device attributes section
- Fixing 'latent' to 'latency' in usage examples
- Sorting the existing event attribute table alphabetically for
better readability and to establish a clean baseline for future
additions.
Suggested-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Taha Ed-Dafili <0rayn.dev@gmail.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Randy Dunlap [Thu, 26 Feb 2026 05:12:57 +0000 (21:12 -0800)]
iio: tsl2772: fix all kernel-doc warnings
Use the correct kernel-doc notation for struct members to eliminate
kernel-doc warnings:
Warning: include/linux/platform_data/tsl2772.h:88 struct member
'prox_diode' not described in 'tsl2772_settings'
Warning: include/linux/platform_data/tsl2772.h:88 struct member
'prox_power' not described in 'tsl2772_settings'
Signed-off-by: Randy Dunlap <rdunlap@infradead.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Bhargav Joshi [Thu, 26 Feb 2026 23:10:57 +0000 (04:40 +0530)]
iio: frequency: ad9523: use octal permissions
The driver currently defines device attributes using symbolic permission
flags (S_IRUGO and S_IWUSR). Update these to use octal permissions (0444
and 0200) to resolve checkpatch warnings.
Signed-off-by: Bhargav Joshi <rougueprince47@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Platform data pointer dereferences for pll1_charge_pump_current_nA and
pll2_charge_pump_current_nA were split across multiple lines. Bring the
dereference chains onto a single line.
This resolves the following checkpatch.pl warnings:
WARNING: Avoid multiple line dereference - prefer 'pdata->pll1_charge_pump_current_nA'
WARNING: Avoid multiple line dereference - prefer 'pdata->pll2_charge_pump_current_nA'
Signed-off-by: Bhargav Joshi <rougueprince47@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
The macros AD9523_CLK_DIST_DIV_PHASE_REV(x) and
AD9523_CLK_DIST_DIV_REV(x) implicitly relied on the variable named 'ret'
instead of using passed argument '(x)'. Update the macros to explicitly
use the argument '(x)' for their operations.
This also resolves the following checkpatch.pl warning: Argument '(x)'
is not used in function-like macro.
Signed-off-by: Bhargav Joshi <rougueprince47@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Remove the AD9000_CHANNELS_PER_PHASE macro which is unused, has a
misspelled prefix (AD9000 instead of ADE9000), and has an incorrect
value (10 instead of 11, there are 33 total channels and 3 phases, so 11
per phase).
Signed-off-by: Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Antoniu Miclaus [Fri, 27 Feb 2026 14:01:40 +0000 (16:01 +0200)]
iio: filter: admv8818: add dev variable
Introduce a local struct device pointer in functions that reference
&spi->dev for device-managed resource calls and device property reads,
improving code readability.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Antoniu Miclaus [Fri, 27 Feb 2026 14:01:38 +0000 (16:01 +0200)]
iio: dac: ad7293: add dev variable
Introduce a local struct device pointer in functions that reference
&spi->dev for device-managed resource calls and device property reads,
improving code readability.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Introduce a local struct device pointer in functions that reference
&spi->dev for device-managed resource calls and device property reads,
improving code readability.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Antoniu Miclaus [Fri, 27 Feb 2026 14:01:34 +0000 (16:01 +0200)]
iio: frequency: admv1013: add dev variable
Introduce a local struct device pointer in functions that reference
&spi->dev for device-managed resource calls and device property reads,
improving code readability.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Antoniu Miclaus [Fri, 27 Feb 2026 14:01:32 +0000 (16:01 +0200)]
iio: frequency: admv1014: add dev variable
Introduce a local struct device pointer in functions that reference
&spi->dev for device-managed resource calls and device property reads,
improving code readability.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Antoniu Miclaus [Fri, 27 Feb 2026 14:01:30 +0000 (16:01 +0200)]
iio: frequency: adrf6780: add dev variable
Introduce a local struct device pointer in functions that reference
&spi->dev for device-managed resource calls and device property reads,
improving code readability.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
iio: adc: ad7173: move opening brace to a separate line
Place the opening brace of ad7173_calc_openwire_thrsh_raw() on its own
line to comply with the kernel coding style for function definitions.
Issue found by checkpatch.
Signed-off-by: Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Andy Shevchenko [Mon, 23 Feb 2026 03:40:14 +0000 (21:40 -0600)]
iio: light: gp2ap020a00f: Return directly from the switch cases
Return directly from the switch cases which makes code easier to follow.
In some cases convert pieces to the standard pattern which also unifies
it with the accepted kernel practices.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Andy Shevchenko [Mon, 23 Feb 2026 03:40:13 +0000 (21:40 -0600)]
iio: light: gp2ap020a00f: Use correct types for 16-bit LE data
Instead of using byte arrays and then explicit castings, change
the types of byte arrays to be __le16 and update the endianness
conversions accordingly.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Ethan Tidmore [Mon, 23 Feb 2026 03:40:12 +0000 (21:40 -0600)]
iio: light: gp2ap020a00f: correct return type to int
The function gp2ap020a00f_get_thresh_reg() can return -EINVAL in its
error path. Yet, the function has return type of u8. Added error
checking for gp2ap020a00f_get_thresh_reg() return value.
Detected by Smatch:
drivers/iio/light/gp2ap020a00f.c:1013 gp2ap020a00f_get_thresh_reg() warn:
signedness bug returning '(-22)'
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Ethan Tidmore [Mon, 23 Feb 2026 03:40:11 +0000 (21:40 -0600)]
iio: light: gp2ap020a00f: simplify locking with guard()
Use the guard() cleanup handler to manage the device lock.
This simplifies the code by removing the need for manual unlocking
and goto error handling paths.
Suggested-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Antoniu Miclaus [Mon, 2 Feb 2026 11:57:30 +0000 (13:57 +0200)]
iio: adc: at91_adc: change at91_ts_sample to return void
The return value of at91_ts_sample() is never checked by its caller.
Change the return type to void to make this explicit. The error
conditions are already logged via dev_err() which provides sufficient
visibility into hardware issues.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Rodrigo Alencar [Mon, 16 Feb 2026 17:10:55 +0000 (17:10 +0000)]
iio: amplifiers: ad8366: update device support
Add support for the following digital step attenuators:
- HMC271A: 1dB LSB 5-Bit Digital Attenuator SMT, 0.7 - 3.7 GHz
- ADRF5720: 0.5 dB LSB, 6-Bit, Digital Attenuator, 9 kHz to 40 GHz
- ADRF5730: 0.5 dB LSB, 6-Bit, Digital Attenuator, 100 MHz to 40 GHz
- ADRF5731: 2 dB LSB, 4-Bit, Digital Attenuator, 100 MHz to 40 GHz
- HMC1018A: 1.0 dB LSB GaAs MMIC 5-BIT DIGITAL ATTENUATOR, 0.1 - 30 GHz
- HMC1019A: 0.5 dB LSB GaAs MMIC 5-BIT DIGITAL ATTENUATOR, 0.1 - 30 GHz
Additionally, copyright notice was updated with current year.
Co-developed-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Co-developed-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Rodrigo Alencar [Mon, 16 Feb 2026 17:10:53 +0000 (17:10 +0000)]
iio: amplifiers: ad8366: add device tree support
Drop the enum ID, split chip info table into per-device structs and add
of_match_table. Additionally, add 'name' field into the chip info struct,
dropping the usage of spi_get_device_id().
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Rodrigo Alencar [Mon, 16 Feb 2026 17:10:52 +0000 (17:10 +0000)]
iio: amplifiers: ad8366: prepare for device-tree support
Drop switch case on the enum ID in favor of extended chip info table,
containing:
- gain_step, indicating with sign the start of the code range;
- num_channels, to indicate the number IIO channels;
- pack_code() function to describe how SPI buffer is populated;
Which allowed for a simplified read_raw() and write_raw() callbacks. The
probe() function was adjusted accordingly. The linux/array_size.h include
is removed as number of channels is provided by chip info table.
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Rodrigo Alencar [Mon, 16 Feb 2026 17:10:51 +0000 (17:10 +0000)]
iio: amplifiers: ad8366: replace reset-gpio with reset controller
Remove reset_gpio from the device state struct and use the reset_control
interface instead, using a local variable, as it is not being used
anywhere else. The reset controller init is moved out from the switch case
and optionally initialized for every device variant. Although not all
devices have a reset pin the code does not need to change if it is not
wired.
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Adhere modern device resource management with the following:
- Voltage regulator managed and enabled internally;
- IIO device registration handled with devm_iio_device_register();
- removal of goto's from the probe function;
- ad8366_remove() removed as it is not needed anymore;
With the drop of goto's dev_err_probe() is used to report probe errors.
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Rodrigo Alencar [Mon, 16 Feb 2026 17:10:49 +0000 (17:10 +0000)]
iio: amplifiers: ad8366: use devm_mutex_init() and drop mutex_init()
Adopt proper mutex lifecycle with devm_mutex_init(), replacing
mutex_init(). Mutex init is moved up (before regulator init),
so that goto statement in the error path is avoided (which will
be cleaned up later).
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Rodrigo Alencar [Mon, 16 Feb 2026 17:10:48 +0000 (17:10 +0000)]
iio: amplifiers: ad8366: add local dev pointer to the probe function
Create local device pointer in the probe function to shorten lines, making
the code easier to read. The local device pointer replaces &spi->dev and
will be reused across other probe function places in later patches.
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Rodrigo Alencar [Mon, 16 Feb 2026 17:10:47 +0000 (17:10 +0000)]
iio: amplifiers: ad8366: refactor include headers
Apply IWYU principle, removing the following headers:
- linux/device.h: no usage of devm_add_action_or_reset, device_attr...
- linux/kernel.h: no usage of container_of, kasprintf, ...
- linux/slab.h: memory management handled by iio
- linux/sysfs.h: sysfs interaction is managed by iio
- linux/iio/sysfs.h: not using iio device attributes in this driver
Adding the following missing headers:
+ linux/array_size.h: for ARRAY_SIZE
+ linux/bits.h: for BIT
+ linux/dev_printk.h: for dev_err
+ linux/math.h: for abs
+ linux/mutex.h: for mutex_lock, mutex_unlock
+ linux/mod_devicetable.h: for spi_device_id
+ linux/types.h for NULL, __aligned
Additionally, those include directives are alphabetically sorted.
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Rodrigo Alencar [Mon, 16 Feb 2026 17:10:46 +0000 (17:10 +0000)]
dt-bindings: iio: amplifiers: Add AD8366 support
Add device tree binding documentation for amplifiers and digital
attenuators. This covers different device variants with similar
SPI control. Each device has its own gain range and step, hence
no fallback compatibles are used.
Andy Shevchenko [Fri, 20 Feb 2026 13:25:19 +0000 (14:25 +0100)]
iio: core: Simplify IIO core managed APIs
Use devm_add_action_or_reset() instead of devres_alloc() and
devres_add(), which works the same. This will simplify the
code. There is no functional changes.
While at it, inline devm_iio_kfifo_allocate() into its only user.
Reviewed-by: Nuno Sá <nuno.sa@analog.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Salah Triki [Sat, 21 Feb 2026 07:32:42 +0000 (08:32 +0100)]
iio: core: Clean up device correctly on viio_trigger_alloc() failure
Move device_initialize() after all error paths in viio_trigger_alloc().
Previously, put_device() should have been called on all error paths after
device_initialize(), but that was not done.
Rather than adding put_device(), move device_initialize() to avoid
needing to unwind it on error.
In addition move trig->dev initialization to just before device_initialize()
to related code together.
Signed-off-by: Salah Triki <salah.triki@gmail.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Archit Anant [Wed, 18 Feb 2026 12:53:27 +0000 (18:23 +0530)]
staging: iio: impedance-analyzer: ad5933: use div64_ul() instead of do_div()
Replace do_div() with div64_ul() since the remainder is not used.
div64_ul() is the preferred API for 64-bit by 32-bit division when
only the quotient is needed.
Also replace explicit casting and shifting with the BIT_ULL(27) macro
for clarity.
Note: A mathematical simplification to `(freq * BIT_ULL(29)) / mclk` was
suggested during review to improve precision. However, as confirmed by
maintainers, the original driver's truncation via `(mclk / 4)` might
be intentional or relied upon by userspace. Since hardware is not
available for verification, this patch preserves the original logic
to avoid regression risk in the absence of testing.
Issue identified by coccicheck using do_div.cocci.
Signed-off-by: Archit Anant <architanant5@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Jishnu Prakash [Fri, 30 Jan 2026 11:54:20 +0000 (17:24 +0530)]
iio: adc: Add support for QCOM PMIC5 Gen3 ADC
The ADC architecture on PMIC5 Gen3 is similar to that on PMIC5 Gen2,
with all SW communication to ADC going through PMK8550 which
communicates with other PMICs through PBS.
One major difference is that the register interface used here is that
of an SDAM (Shared Direct Access Memory) peripheral present on PMK8550.
There may be more than one SDAM used for ADC5 Gen3 and each has eight
channels, which may be used for either immediate reads (same functionality
as previous PMIC5 and PMIC5 Gen2 ADC peripherals) or recurring measurements
(same as ADC_TM functionality).
By convention, we reserve the first channel of the first SDAM for all
immediate reads and use the remaining channels across all SDAMs for
ADC_TM monitoring functionality.
Add support for PMIC5 Gen3 ADC driver for immediate read functionality.
ADC_TM is implemented as an auxiliary thermal driver under this ADC
driver.
Signed-off-by: Jishnu Prakash <jishnu.prakash@oss.qualcomm.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Jishnu Prakash [Fri, 30 Jan 2026 11:54:19 +0000 (17:24 +0530)]
dt-bindings: iio: adc: Add support for QCOM PMIC5 Gen3 ADC
For the PMIC5-Gen3 type PMICs, ADC peripheral is present in HW for the
following PMICs: PMK8550, PM8550, PM8550B and PM8550VX PMICs.
It is similar to PMIC5-Gen2, with SW communication to ADCs on all PMICs
going through PBS(Programmable Boot Sequence) firmware through a single
register interface. This interface is implemented on SDAM (Shared
Direct Access Memory) peripherals on the master PMIC PMK8550 rather
than a dedicated ADC peripheral.
Add documentation for PMIC5 Gen3 ADC and update SPMI PMIC bindings to
allow ADC5 Gen3 as adc@ subnode.
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Signed-off-by: Jishnu Prakash <jishnu.prakash@oss.qualcomm.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Jishnu Prakash [Fri, 30 Jan 2026 11:54:18 +0000 (17:24 +0530)]
dt-bindings: iio: adc: Split out QCOM VADC channel properties
Split out the common channel properties for QCOM VADC devices into a
separate file so that it can be included as a reference for devices
using them. This will be needed for the upcoming ADC5 Gen3 binding
support patch, as ADC5 Gen3 also uses all of these common properties.
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Jishnu Prakash <jishnu.prakash@oss.qualcomm.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Antoniu Miclaus [Mon, 16 Feb 2026 15:11:11 +0000 (17:11 +0200)]
iio: adc: ad4080: add support for AD4082, AD4085 and AD4088
Add support for the AD4082, AD4085 and AD4088 SAR ADCs. These devices
share the same resolution as their base variants but differ in LVDS CNV
clock count maximum:
- AD4082 (20-bit, like AD4080): lvds_cnv_clk_cnt_max 8 vs 7
- AD4085 (16-bit, like AD4084): lvds_cnv_clk_cnt_max 8 vs 2
- AD4088 (14-bit, like AD4087): lvds_cnv_clk_cnt_max 8 vs 1
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Antoniu Miclaus [Mon, 16 Feb 2026 15:11:10 +0000 (17:11 +0200)]
dt-bindings: iio: adc: adi,ad4080: add support for AD4082, AD4085 and AD4088
Add device tree binding support for AD4082, AD4085 and AD4088 SAR ADCs.
Add adi,ad4082, adi,ad4085 and adi,ad4088 to the compatible enum.
A fallback compatible string is not appropriate for these devices as they
differ in LVDS CNV clock count maximum from their base variants:
- AD4082 (20-bit) vs AD4080: lvds_cnv_clk_cnt_max 8 vs 7
- AD4085 (16-bit) vs AD4084: lvds_cnv_clk_cnt_max 8 vs 2
- AD4088 (14-bit) vs AD4087: lvds_cnv_clk_cnt_max 8 vs 1
Marcelo Schmitt [Mon, 16 Feb 2026 15:00:22 +0000 (12:00 -0300)]
iio: adc: ad4030: Use BIT macro to improve code readability
Use BIT macro to make the list of average modes more readable.
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
AD4030 and similar devices all connect to the system as SPI peripherals.
Reference spi-peripheral-props so common SPI peripheral can be used from
ad4030 dt-binding.
Antoniu Miclaus [Mon, 16 Feb 2026 13:17:05 +0000 (15:17 +0200)]
iio: dac: max5522: simplify probe with devm_regulator_get_enable_read_voltage()
Simplify probe by using devm_regulator_get_enable_read_voltage() to
get, enable and read the regulator voltage in a single call, caching
the value at probe time.
The reference voltage for this DAC is a fixed hardware configuration
that is not expected to change at runtime, so reading it once during
probe and caching the millivolt value is sufficient.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Antoniu Miclaus [Mon, 16 Feb 2026 13:17:04 +0000 (15:17 +0200)]
iio: magnetometer: si7210: simplify probe with devm_regulator_get_enable_read_voltage()
Simplify probe by using devm_regulator_get_enable_read_voltage() to
get, enable and read the regulator voltage in a single call, caching
the value at probe time.
This is a functional change as VDD voltage is now read once at probe
rather than dynamically on each temperature measurement. However, in
real deployments it is very rare for VDD to change after initial probe.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
The added code is currently a dead code. Moreover, the driver is not
designed to have any defaults effectively making driver data a mandatory
information to work with. Taking all together, revert unneeded change.
Discussion at #1 concluded in agreeing a new policy on this for IIO.