summaryrefslogtreecommitdiff
path: root/drivers/iio/adc
AgeCommit message (Collapse)Author
2026-02-23iio: adc: ad7768-1: Fix ERR_PTR dereference in ad7768_fill_scale_tblEthan Tidmore
The function iio_get_current_scan_type() can return an error pointer, the return value scan_type is not checked for this and immediately dereferenced which can cause a kernel panic. Add check for IS_ERR() and propagate the error back. Fixes: ff085189cb17 ("iio: adc: ad7768-1: add support for ADAQ776x-1 ADC Family") Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <error27@gmail.com> Closes: https://lore.kernel.org/r/202602051234.5gArzLyZ-lkp@intel.com/ 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>
2026-02-22Convert remaining multi-line kmalloc_obj/flex GFP_KERNEL usesKees Cook
Conversion performed via this Coccinelle script: // SPDX-License-Identifier: GPL-2.0-only // Options: --include-headers-for-types --all-includes --include-headers --keep-comments virtual patch @gfp depends on patch && !(file in "tools") && !(file in "samples")@ identifier ALLOC = {kmalloc_obj,kmalloc_objs,kmalloc_flex, kzalloc_obj,kzalloc_objs,kzalloc_flex, kvmalloc_obj,kvmalloc_objs,kvmalloc_flex, kvzalloc_obj,kvzalloc_objs,kvzalloc_flex}; @@ ALLOC(... - , GFP_KERNEL ) $ make coccicheck MODE=patch COCCI=gfp.cocci Build and boot tested x86_64 with Fedora 42's GCC and Clang: Linux version 6.19.0+ (user@host) (gcc (GCC) 15.2.1 20260123 (Red Hat 15.2.1-7), GNU ld version 2.44-12.fc42) #1 SMP PREEMPT_DYNAMIC 1970-01-01 Linux version 6.19.0+ (user@host) (clang version 20.1.8 (Fedora 20.1.8-4.fc42), LLD 20.1.8) #1 SMP PREEMPT_DYNAMIC 1970-01-01 Signed-off-by: Kees Cook <kees@kernel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2026-02-21treewide: Replace kmalloc with kmalloc_obj for non-scalar typesKees Cook
This is the result of running the Coccinelle script from scripts/coccinelle/api/kmalloc_objs.cocci. The script is designed to avoid scalar types (which need careful case-by-case checking), and instead replace kmalloc-family calls that allocate struct or union object instances: Single allocations: kmalloc(sizeof(TYPE), ...) are replaced with: kmalloc_obj(TYPE, ...) Array allocations: kmalloc_array(COUNT, sizeof(TYPE), ...) are replaced with: kmalloc_objs(TYPE, COUNT, ...) Flex array allocations: kmalloc(struct_size(PTR, FAM, COUNT), ...) are replaced with: kmalloc_flex(*PTR, FAM, COUNT, ...) (where TYPE may also be *VAR) The resulting allocations no longer return "void *", instead returning "TYPE *". Signed-off-by: Kees Cook <kees@kernel.org>
2026-02-02Merge tag 'iio-for-7.0a' of ↵Greg Kroah-Hartman
ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next Jonathan writes: IIO: New device support, features and cleanup for the 6.20/7.0 cycle. Slightly messier than normal unfortunately due to some conflicts and build config bugs related to I3C drivers. One last minute Kconfig fix right at the top after a linux-next report. I've simplified the Kconfig and made it match other instances in the kernel so that should be safe enough despite short soak time in front of build bots. Merge of an immutable branch from I3C to get some stubs that were missing and caused build issues with dual I2C / I3C drivers. This also brought in a drop of some deprecated interfaces so there is also one patch to update a new driver to not use those. We are having another go at using cleanup.h magic with the IIO mode claim functions after backing out last try at this. This time we have wrappers around the new ACQUIRE() and ACQUIRE_ERR() macros. Having been burnt once, we will be taking it a bit more slowly this time wrt to wide adoption of these! Thanks in particular to Kurt for taking on this core IIO work. New Device Support ================== adi,ad18113 - New driver to support the AD18113 amplifier - an interesting device due to the external bypass paths where we need to describe what gain those paths have in DT. Longer term it will be interesting to see if this simplistic description is enough for real deployments. adi,ad4062 - New driver for the AD4060 and AD4052 SAR ADCs including trigger, event and GPIO controller support. Follow up patch replaced use of some deprecated I3C interfaces prior to the I3C immutable branch merge as that includes dropping them. adi,ad4134 - New driver for the AD4134 24bit 4 channel simultaneous sampling ADC. adi,ad7768-1, - Add support for the ADAQ767-1, ADAQ7768-1 and ADAQ7769-1 ADCs after some rework to enable the driver to support multiple device types. adi,ad9467 - Add support for the similar ad9211 ADC to this existing driver. - Make the selection of 2s comp mode explicit for normal operation and switch to offset binary when entering calibration mode. honeywell,abp2 - New driver to support this huge family (100+) of board mount pressure and temperature sensors. maxim,max22007 - New drier for this 4 channel DAC. memsic,mmc5633 - New driver for this I2C/I3C magnetometer. Follow on patches fixed up issues related to single driver supporting both bus types. microchip,mcp747feb02 - New driver for the Microchip MCP47F(E/V)B(0/1/2)1, MCP47F(E/V)B(0/1/2)2, MCP47F(E/V)B(0/1/2)4 and MCP47F(E/V)B(0/1/2)8 buffered voltage output DACs. nxp,sar-adc - New driver support ADCs found on s32g2 and s32g3 platforms. ti,ads1018 - New drier for the ADS1018 and ADS1118 SPI ADCs. ti,ads131m02 - New driver supporting ADS131M(02/03/04/06/08)24-bit simultaneous sampling ADCs. Features ======== iio-core - New IIO_DEV_ACQUIRE_DIRECT_MODE() / IIO_DEV_ACQUIRE_FAILED() + equivalents for the much rarer case where the mode needs pinning whether or not it is in direct mode. These use the ACQUIRE() / ACQUIRE_ERR() infrastructure underneath to provide both simple checks on whether we got the requested mode and to provide scope based release. Applied in a few initial drivers. adi,ad9467 - Support calibbias control adi,adf4377 - Add support to act as a clock provider. adi,adxl380 - Support low power 1KHz sampling frequency mode. Required rework of how events and filters were configured, plus applying of constraints when in this mode. rf-digital,rfd77402 - Add interrupt support as alternative to polling for completion. st,lsm6dsx - Tap event detection (after considerable driver rework) Cleanup and Minor Fixes ======================= More minor cleanup such as typos, white space etc not called out except where they were applied to a lot of drivers. Various drivers. - Use of dev_err_probe() to cleanup error handling. - Introduce local struct device and struct device_node variables to reduce duplication of getting them from containing structs. - Ensure uses of iio_trigger_generic_data_rdy_poll() set IRQF_NO_THREAD as that function calls non threaded child interrupt handlers. - Replace IRQF_ONESHOT in not thread interrupt handlers with IRQF_NO_THREAD to ensure they run as intended. Drop one unnecessary case. iio-sw-device/trigger. - Constify configs_group_operations structures. iio-buffer-dma / buffer-dma-engine - Use lockdep_assert_held() to replace WARN_ON() to check lock is correctly held. - Make use of cleanup.h magic to simplify various code paths. - Make iio_dma_buffer_init() return void rather than always success. adi,ad7766 - Replace custom interrupt handler with iio_trigger_generic_data_rdy_poll() adi,ad9832 - Drop legacy platform_data support. adi,ade9000 - Add a maintainer entry. adi,adt7316 - Move to EXPORT_GPL_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() so the compiler can cleanly drop unused pm structures and callbacks. adi,adxl345 - Relax build constraint vs the driver that is in input so both may be built as modules and selection made at runtime. adi,adxl380 - Make sure we don't read tail entries in the hardware fifo if a partial new scan has been written. - Move to a single larger regmap_noinc_read() to read the hardware fifo. aspeed,ast2600 - Add missing interrupts property to DT binding. bosch,bmi270_i2c - Add missing MODULE_DEVICE_TABLE() macros so auto probing of modules can work. bosch,smi330 - Drop duplicate assignment of IIO_TYPE in smi330_read_avail() - Use new common field_get() and field_prep() helpers to replace local version. honeywell,mprls0025pa Fixes delayed to merge window as late in cycle and we didn't want to delay the rest of the series. - Allow Kconfig selection of specific bus sub-drivers rather than tying that to the buses themselves being supported. - Zero spi_transfer structure to avoid chance of unintentionally set fields effecting transfer. - Fix a potential timing violation wrt to the chip select to first clock edge timing. - As recent driver, take risk inherent in dropping interrupt direction from driver as that should be set by firmware. - Fix wrong reported number of data bits for channel. - Fix a pressure channel calculation bug. - Rework to allow embedding the tx buffer in the iio_priv() structure rather than requiring separate allocation. - Move the buffer clearing to the shared core bringing it into affect for SPI as well as I2C. - Stricter checks for status byte. - Greatly simplify the measurement sequence. - Add a copyright entry to reflect Petre's continued work on this driver. intersil,isl29018 - Switch from spritnf to sysfs_emit_at() to make it clear overflow can't occur. invensense,icm42600 - Allow sysfs access to temperature when buffered capture in use as it does not impact other sensor data paths. invensense,itg3200 - Check unused return value in read_raw() callback. men,z188 - Drop now duplicated module alias. rf-digital,rfd77402 - Add DT binding doc and explicit of_device_id table. - Poll for timeout with times as on datasheet, then replace opencoded version with read_poll_timeout(). sensiron,scd4x - Add missing timestamp channel. The code to push it to the buffer was there but there was no way to turn it on. vti,sca3000 - Fix resource leak if iio_device_register() fails. * tag 'iio-for-7.0a' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (144 commits) iio: magn: mmc5633: Fix Kconfig for combination of I3C as module and driver builtin iio: sca3000: Fix a resource leak in sca3000_probe() iio: proximity: rfd77402: Add interrupt handling support iio: proximity: rfd77402: Document device private data structure iio: proximity: rfd77402: Use devm-managed mutex initialization iio: proximity: rfd77402: Use kernel helper for result polling iio: proximity: rfd77402: Align polling timeout with datasheet iio: cros_ec: Allow enabling/disabling calibration mode iio: frequency: ad9523: correct kernel-doc bad line warning iio: buffer: buffer_impl.h: fix kernel-doc warnings iio: gyro: itg3200: Fix unchecked return value in read_raw MAINTAINERS: add entry for ADE9000 driver iio: accel: sca3000: remove unused last_timestamp field iio: accel: adxl372: remove unused int2_bitmask field iio: adc: ad7766: Use iio_trigger_generic_data_rdy_poll() iio: magnetometer: Remove IRQF_ONESHOT iio: Replace IRQF_ONESHOT with IRQF_NO_THREAD iio: Use IRQF_NO_THREAD iio: dac: Add MAX22007 DAC driver support dt-bindings: iio: dac: Add max22007 ...
2026-01-29iio: adc: ad7766: Use iio_trigger_generic_data_rdy_poll()Sebastian Andrzej Siewior
ad7766_irq() is identical to iio_trigger_generic_data_rdy_poll(). Use iio_trigger_generic_data_rdy_poll() instead of ad7766_irq(). Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2026-01-29iio: Replace IRQF_ONESHOT with IRQF_NO_THREADSebastian Andrzej Siewior
Passing IRQF_ONESHOT ensures that the interrupt source is masked until the secondary (threaded) handler is done. If only a primary handler is used then the flag makes no sense because the interrupt can not fire (again) while its handler is running. The flag also disallows force-threading of the primary handler and the irq-core will warn about this. The intention here was probably not allowing forced-threading for handlers such as iio_trigger_generic_data_rdy_poll() will intends to invoke hard-interrupt handlers. Replace IRQF_ONESHOT with IRQF_NO_THREAD. Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Reviewed-by: Marcus Folkesson <marcus.folkesson@gmail.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2026-01-29iio: Use IRQF_NO_THREADSebastian Andrzej Siewior
The interrupt handler iio_trigger_generic_data_rdy_poll() will invoke other interrupt handler and this supposed to happen from within the hardirq. Use IRQF_NO_THREAD to forbid forced-threading. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2026-01-22iio: adc: ad7768-1: add support for ADAQ776x-1 ADC FamilyJonathan Santos
Add support for ADAQ7767/68/69-1 series, which includes PGIA and Anti-aliasing filter (AAF) gains. Unlike the AD7768-1, they do not provide a VCM regulator interface. The PGA gain is configured in run-time through the scale attribute, if supported by the device. PGA is controlled by GPIOs provided in the device tree. The AAF gain is defined by hardware connections and should be specified in the device tree. Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2026-01-22iio: adc: ad7768-1: refactor ad7768_write_raw()Jonathan Santos
Squash __ad7768_write_raw() back to ad7768_write_raw() to allow the addition of new attributes without requiring a direct mode claim. Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2026-01-22iio: adc: ad7768-1: introduce chip info for future multidevice supportJonathan Santos
Add Chip info struct in SPI device to store channel information for each supported part. Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2026-01-22iio: core: Match iio_device_claim_*() semantics and implementationKurt Borja
Implement iio_device_claim_buffer_mode() fully inline with the use of __iio_dev_mode_lock(), which takes care of sparse annotations. To completely match iio_device_claim_direct() semantics, we need to also change iio_device_claim_buffer_mode() return semantics to usual true/false conditional lock semantics. Additionally, to avoid silently breaking out-of-tree drivers, rename iio_device_claim_buffer_mode() to iio_device_claim_try_buffer_mode(). Reviewed-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Signed-off-by: Kurt Borja <kuurtb@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2026-01-22iio: adc: ad4062: Switch from struct i3c_priv_xfer to struct i3c_xferJonathan Cameron
Commit 9904232ae30bc ("i3c: drop i3c_priv_xfer and i3c_device_do_priv_xfers()") currently in the i3c/for-next tree removes the deprecated struct i3c_priv_xfer and i3c_device_do_priv_xfers(). Switch to struct i3c_xfer and i3c_device_do_xfers(..., I3C_SDR) now rather causing a build issue when both trees are merged. Suggested-by: Sasha Levin <sashal@kernel.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2026-01-16iio: adc: ad9467: include two's complement in default modeTomas Melin
All supported drivers currently implicitly use two's complement mode. Make this clear by declaring two's complement in the default output mode. Calibration mode uses offset binary, so change the output mode only when running the calibration or other test mode. Reviewed-by: Nuno Sá <nuno.sa@analog.com> Signed-off-by: Tomas Melin <tomas.melin@vaisala.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2026-01-11iio: adc: Initial support for AD4134Marcelo Schmitt
AD4134 is a 24-bit, 4-channel, simultaneous sampling, precision analog-to-digital converter (ADC). The device can be managed through SPI or direct control of pin logical levels (pin control mode). The AD4134 design also features a dedicated bus for ADC sample data output. Though, this initial driver for AD4134 only supports usual SPI connections. Add basic support for AD4134 that enables single-shot ADC sample read. Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2026-01-11iio: adc: ad7476: Remove duplicate includeChen Ni
Remove duplicate inclusion of linux/bitops.h. Signed-off-by: Chen Ni <nichen@iscas.ac.cn> Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2026-01-11iio: adc: ti-ads1018: Drop stale kernel-doc function contextKurt Borja
The driver no longer uses iio_device_claim_buffer_mode(). Drop it from ads1018_spi_read_exclusive() context remark. Signed-off-by: Kurt Borja <kuurtb@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2026-01-11iio: adc: men_z188_adc: drop unneeded MODULE_ALIASJose Javier Rodriguez Barbarin
Since commit 1f4ea4838b13 ("mcb: Add missing modpost build support") the MODULE_ALIAS() is redundant as the module alias is now automatically generated from the MODULE_DEVICE_TABLE(). Remove the explicit alias. No functional change intended. Reviewed-by: Jorge Sanjuan Garcia <dev-jorge.sanjuangarcia@duagon.com> Signed-off-by: Jose Javier Rodriguez Barbarin <dev-josejavier.rodriguez@duagon.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-31iio: adc: rockchip: Simplify probe() with local 'dev'Krzysztof Kozlowski
Simplify the probe function by using a local 'dev' variable instead of full pointer dereference. This makes several lines shorter, which allows to avoid wrapping making code more readable. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Reviewed-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-31iio: adc: exynos: Simplify probe() with local 'dev' and 'np'Krzysztof Kozlowski
Simplify the probe function by using local 'dev' and 'np' variables instead of full pointer dereferences. This makes several lines shorter, which allows to avoid wrapping making code more readable. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-31iio: adc: aspeed: Simplify probe() with local 'dev' and 'np'Krzysztof Kozlowski
Simplify the probe function by using local 'dev' and 'np' variables instead of full pointer dereferences. This makes several lines shorter, which allows to avoid wrapping making code more readable. While touching the return line, simplify by avoiding unnecessary 'ret' assignment. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-31iio: adc: ad4062: Add GPIO Controller supportJorge Marques
When gp0 or gp1 is not taken as an interrupt, expose them as GPO if gpio-contoller is set in the devicetree. gpio-regmap is not used because the GPO static low is 'b101 and static high is 0b110; low state requires setting bit 0, not fitting the abstraction of low=0 and high=mask. Signed-off-by: Jorge Marques <jorge.marques@analog.com> Reviewed-by: Linus Walleij <linusw@kernel.org> Acked-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-31iio: adc: ad4062: Add IIO Events supportJorge Marques
Adds support for IIO Events. Optionally, gp0 is assigned as Threshold Either signal, if not present, fallback to an I3C IBI with the same role. Signed-off-by: Jorge Marques <jorge.marques@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-31iio: adc: ad4062: Add IIO Trigger supportJorge Marques
Adds support for IIO Trigger. Optionally, gp1 is assigned as Data Ready signal, if not present, fallback to an I3C IBI with the same role. The software trigger is allocated by the device, but must be attached by the user before enabling the buffer. The purpose is to not impede removing the driver due to the increased reference count when iio_trigger_set_immutable() or iio_trigger_get() is used. Signed-off-by: Jorge Marques <jorge.marques@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-31iio: adc: Add support for ad4062Jorge Marques
The AD4060/AD4062 are versatile, 16-bit/12-bit, successive approximation register (SAR) analog-to-digital converter (ADC) with low-power and threshold monitoring modes. Signed-off-by: Jorge Marques <jorge.marques@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-21iio: adc: ad7606_spi: use bitmap_full() in ad7606_spi_update_scan_mode()Yury Norov (NVIDIA)
bitmap_full() is less verbose and more efficient, as it stops traversing scan_mask as soon as the 1st unset bit found. Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-21iio: adc: Add ti-ads1018 driverKurt Borja
Add ti-ads1018 driver for Texas Instruments ADS1018 and ADS1118 SPI analog-to-digital converters. This chips' MOSI pin is shared with a data-ready interrupt. Defining this interrupt in devicetree is optional, therefore we only create an IIO trigger if one is found. Handling this interrupt requires some considerations. When enabling the trigger the CS line is tied low (active), thus we need to hold spi_bus_lock() too, to avoid state corruption. This is done inside the set_trigger_state() callback, to let users use other triggers without wasting a bus lock. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Kurt Borja <kuurtb@gmail.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-21iio: adc: exynos_adc: fix OF populate on driver rebindJohan Hovold
Since commit c6e126de43e7 ("of: Keep track of populated platform devices") child devices will not be created by of_platform_populate() if the devices had previously been deregistered individually so that the OF_POPULATED flag is still set in the corresponding OF nodes. Switch to using of_platform_depopulate() instead of open coding so that the child devices are created if the driver is rebound. Fixes: c6e126de43e7 ("of: Keep track of populated platform devices") Cc: stable@vger.kernel.org # 3.16 Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-21iio: adc: sc27xx: Simplify with dev_err_probeKrzysztof Kozlowski
Use dev_err_probe() to make error code handling simpler and handle deferred probe nicely (avoid spamming logs). Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-21iio: adc: rockchip: Simplify with dev_err_probeKrzysztof Kozlowski
Use dev_err_probe() to make error code handling simpler and handle deferred probe nicely (avoid spamming logs). Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-21iio: adc: qcom-spmi-rradc: Simplify with dev_err_probeKrzysztof Kozlowski
Use dev_err_probe() to make error code handling simpler. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-21iio: adc: exynos: Simplify with dev_err_probeKrzysztof Kozlowski
Use dev_err_probe() to make error code handling simpler and handle deferred probe nicely (avoid spamming logs). Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-21iio: adc: aspeed: Simplify with dev_err_probeKrzysztof Kozlowski
Use dev_err_probe() to make error code handling simpler and handle deferred probe nicely (avoid spamming logs). Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-21iio: adc: adi-axi-adc: Slightly simplify axi_adc_create_platform_device()Nuno Sá
There's no point in having a ret variable and checking for errors (as we do nothing with it). Instead, save some lines of code and directly return the devm_add_action_or_reset() call. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Nuno Sá <nuno.sa@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-21iio: adc: adi-axi-adc: Make use of dev_err_probe()Nuno Sá
Be consistent and use dev_err_probe() as in all other places in the .probe() path. While at it, remove the line break in the version condition. Yes, it goes over the 80 column limit but I do think the line break hurts readability in this case. And use a struct device *dev helper for neater code. Signed-off-by: Nuno Sá <nuno.sa@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-21iio: adc: ad9467: add support for ad9211Tomas Melin
The AD9211 is a 10-bit monolithic sampling analog-to-digital converter optimized for high performance, low power, and ease of use. The product operates at up to a 300 MSPS conversion rate and is optimized for outstanding dynamic performance in wideband carrier and broadband systems. The scale table implemented here is not an exact match with the datasheet as the table presented there is missing some information. The reference presents these values as being linear, but that does not add up. There is information missing in the table. Implemented scale table matches values at the middle and at the ends, smoothing the curve towards middle and end. Impact on end result from deviation in scale factor affects only software using it for scaling. All the possible hw-settings are also available with this implementation. Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/AD9211.pdf Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Tomas Melin <tomas.melin@vaisala.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-21iio: adc: ad9467: sort header includesTomas Melin
Include headers in ascending order. Signed-off-by: Tomas Melin <tomas.melin@vaisala.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-21iio: adc: Add the NXP SAR ADC support for the s32g2/3 platformsDaniel Lezcano
The NXP S32G2 and S32G3 platforms integrate a successive approximation register (SAR) ADC. Two instances are available, each providing 8 multiplexed input channels with 12-bit resolution. The conversion rate is up to 1 Msps depending on the configuration and sampling window. The SAR ADC supports raw, buffer, and trigger modes. It can operate in both single-shot and continuous conversion modes, with optional hardware triggering through the cross-trigger unit (CTU) or external events. An internal prescaler allows adjusting the sampling clock, while per-channel programmable sampling times provide fine-grained trade-offs between accuracy and latency. Automatic calibration is performed at probe time to minimize offset and gain errors. All modes have been validated on the S32G274-RDB2 platform using an externally generated square wave captured by the ADC. Tests covered buffered streaming via IIO, trigger synchronization, and accuracy verification against a precision laboratory signal source. One potential scenario, not detected during testing, is that in some corner cases the DMA may already have been armed for the next transfer, which can lead dmaengine_tx_status() to return an incorrect residue. The callback_result() operation—intended to supply the residue directly and eliminate the need to call dmaengine_tx_status()—also does not work. Attempting to use dmaengine_pause() and dmaengine_resume() to prevent the residue from being updated does not work either. This potential scenario should apply to any driver using cyclic DMA. However, no current driver actually handles this case, and they all rely on the same acquisition routine (e.g., the STM32 implementation). The NXP SAR acquisition routine has been used in production for several years, which is a good indication of its robustness. As the IIO is implementing the cyclic DMA support API, it is not worth to do more spins to the current routine as it will go away when the new API will be available. The driver is derived from the BSP implementation and has been partly rewritten to comply with upstream requirements. For this reason, all contributors to the original code are listed as co-developers. Originally-by: Stefan-Gabriel Mirea <stefan-gabriel.mirea@nxp.com> Co-developed-by: Alexandru-Catalin Ionita <alexandru-catalin.ionita@nxp.com> Signed-off-by: Alexandru-Catalin Ionita <alexandru-catalin.ionita@nxp.com> Co-developed-by: Ciprian Costea <ciprianmarian.costea@nxp.com> Signed-off-by: Ciprian Costea <ciprianmarian.costea@nxp.com> Co-developed-by: Radu Pirea (NXP OSS) <radu-nicolae.pirea@oss.nxp.com> Signed-off-by: Radu Pirea (NXP OSS) <radu-nicolae.pirea@oss.nxp.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-21iio: adc: Add TI ADS131M0x ADC driverDavid Jander
Add a new IIO ADC driver for Texas Instruments ADS131M0x devices (ADS131M02/03/04/06/08). These are 24-bit, up to 64 kSPS, simultaneous- sampling delta-sigma ADCs accessed via SPI. Highlights: - Supports 2/3/4/6/8-channel variants with per-channel RAW and SCALE. - Implements device-required full-duplex fixed-frame transfers. - Handles both input and output CRC Note: Despite the almost identical name, this hardware is not compatible with the ADS131E0x series handled by drivers/iio/adc/ti-ads131e08.c. Signed-off-by: David Jander <david@protonic.nl> Co-developed-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Reviewed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-21iio: adc: pac1934: Fix clamped value in pac1934_reg_snapshotThorsten Blum
The local variable 'curr_energy' was never clamped to PAC_193X_MIN_POWER_ACC or PAC_193X_MAX_POWER_ACC because the return value of clamp() was not used. Fix this by assigning the clamped value back to 'curr_energy'. Cc: stable@vger.kernel.org Fixes: 0fb528c8255b ("iio: adc: adding support for PAC193x") Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-21iio: adc: ad9467: fix ad9434 vref maskTomas Melin
The mask setting is 5 bits wide for the ad9434 (ref. data sheet register 0x18 FLEX_VREF). Apparently the settings from ad9265 were copied by mistake when support for the device was added to the driver. Fixes: 4606d0f4b05f ("iio: adc: ad9467: add support for AD9434 high-speed ADC") Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Tomas Melin <tomas.melin@vaisala.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-21iio: adc: ad7606: Fix incorrect type for error return variableHaotian Zhang
The variable ret is declared as unsigned int but is used to store return values from functions returning int, which may be negative error codes. Change ret from unsigned int to int. Fixes: 849cebf8dc67 ("iio: adc: ad7606: Add iio-backend support") Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn> Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-21iio: adc: ad7280a: handle spi_setup() errors in probe()Pavel Zhigulin
The probe() function ignored the return value of spi_setup(), leaving SPI configuration failures undetected. If spi_setup() fails, the driver should stop initialization and propagate the error to the caller. Add proper error handling: check the return value of spi_setup() and return it on failure. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 2051f25d2a26 ("iio: adc: New driver for AD7280A Lithium Ion Battery Monitoring System") Signed-off-by: Pavel Zhigulin <Pavel.Zhigulin@kaspersky.com> Reviewed-by: Marcelo Schmitt <marcelo.schmitt@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-21iio: adc: at91-sama5d2_adc: Fix potential use-after-free in sama5d2_adc driverPei Xiao
at91_adc_interrupt can call at91_adc_touch_data_handler function to start the work by schedule_work(&st->touch_st.workq). If we remove the module which will call at91_adc_remove to make cleanup, it will free indio_dev through iio_device_unregister but quite a bit later. While the work mentioned above will be used. The sequence of operations that may lead to a UAF bug is as follows: CPU0 CPU1 | at91_adc_workq_handler at91_adc_remove | iio_device_unregister(indio_dev) | //free indio_dev a bit later | | iio_push_to_buffers(indio_dev) | //use indio_dev Fix it by ensuring that the work is canceled before proceeding with the cleanup in at91_adc_remove. Fixes: 23ec2774f1cc ("iio: adc: at91-sama5d2_adc: add support for position and pressure channels") Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-21iio: adc: ad9467: support write/read offset via _calibbiasTomas Melin
Support configuring output calibration value. Among the devices currently supported by this driver, this setting is specific to ad9434. The offset can be used to calibrate the output against a known input. The register is called offset, but the procedure is best mapped internally with calibbias operation. Reviewed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Tomas Melin <tomas.melin@vaisala.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-12-06Merge tag 'char-misc-6.19-rc1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc Pull char/misc/IIO driver updates from Greg KH: "Here is the big set of char/misc/iio driver updates for 6.19-rc1. Lots of stuff in here including: - lots of IIO driver updates, cleanups, and additions - large interconnect driver changes as they get converted over to a dynamic system of ids - coresight driver updates - mwave driver updates - binder driver updates and changes - comedi driver fixes now that the fuzzers are being set loose on them - nvmem driver updates - new uio driver addition - lots of other small char/misc driver updates, full details in the shortlog All of these have been in linux-next for a while now" * tag 'char-misc-6.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (304 commits) char: applicom: fix NULL pointer dereference in ac_ioctl hangcheck-timer: fix coding style spacing hangcheck-timer: Replace %Ld with %lld hangcheck-timer: replace printk(KERN_CRIT) with pr_crit uio: Add SVA support for PCI devices via uio_pci_generic_sva.c dt-bindings: slimbus: fix warning from example intel_th: Fix error handling in intel_th_output_open misc: rp1: Fix an error handling path in rp1_probe() char: xillybus: add WQ_UNBOUND to alloc_workqueue users misc: bh1770glc: use pm_runtime_resume_and_get() in power_state_store misc: cb710: Fix a NULL vs IS_ERR() check in probe() mux: mmio: Add suspend and resume support virt: acrn: split acrn_mmio_dev_res out of acrn_mmiodev greybus: gb-beagleplay: Fix timeout handling in bootloader functions greybus: add WQ_PERCPU to alloc_workqueue users char/mwave: drop typedefs char/mwave: drop printk wrapper char/mwave: remove printk tracing char/mwave: remove unneeded fops char/mwave: remove MWAVE_FUTZ_WITH_OTHER_DEVICES ifdeffery ...
2025-11-09iio: adc: pac1934: replace use of system_wq with system_percpu_wqMarco Crivellari
Currently if a user enqueues a work item using schedule_delayed_work() the used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to schedule_work() that is using system_wq and queue_work(), that makes use again of WORK_CPU_UNBOUND. This lack of consistency cannot be addressed without refactoring the API. This patch continues the effort to refactor worqueue APIs, which has begun with the change introducing new workqueues and a new alloc_workqueue flag: commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq") commit 930c2ea566af ("workqueue: Add new WQ_PERCPU flag") system_percpu_wq replaced system_wq, so change the wq in iio/adc/pac1934. The old wq (system_wq) will be kept for a few release cycles. Suggested-by: Tejun Heo <tj@kernel.org> Signed-off-by: Marco Crivellari <marco.crivellari@suse.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-11-09iio: adc: Add support for the Renesas RZ/N1 ADCHerve Codina (Schneider Electric)
The Renesas RZ/N1 ADC controller is the ADC controller available in the Renesas RZ/N1 SoCs family. It can use up to two internal ADC cores (ADC1 and ADC2) those internal cores are not directly accessed but are handled through ADC controller virtual channels. Signed-off-by: Herve Codina (Schneider Electric) <herve.codina@bootlin.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-11-09iio: adc: aspeed: Add AST2700 ADC supportBilly Tsai
This patch adds support for the ADCs found on the Aspeed AST2700 SoC, which includes two instances: "ast2700-adc0" and "ast2700-adc1". While they are functionally similar to those on AST2600, the OTP trimming data is located at the same offset (0x820), but uses different bitfields. Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-11-09iio: adc: ade9000: convert to use maple tree register cacheChu Guangqing
The maple tree register cache is based on a much more modern data structure than the rbtree cache and makes optimisation choices which are probably more appropriate for modern systems than those made by the rbtree cache. Signed-off-by: Chu Guangqing <chuguangqing@inspur.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-11-09iio: adc: rohm-bd79124: Use regmap_reg_range()Matti Vaittinen
Initializing the regmap_ranges using direct assignment to the range_min and range_max members is slightly verbose. We can make it a tad cleaner when using the regmap_reg_range() macro. Clean up the code using regmap_reg_range() when initializing the regmap_range structure. Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>