summaryrefslogtreecommitdiff
path: root/drivers/iio
AgeCommit message (Collapse)Author
6 daysReplace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c ↵Uwe Kleine-König (The Capable Hub)
files) Replace the #include of <linux/mod_devicetable.h> by the more specific <linux/device-id/*.h> where applicable. For most cases the include can be dropped completely, only a few drivers need one or two headers added. Acked-by: Danilo Krummrich <dakr@kernel.org> Acked-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://patch.msgid.link/1a3f2007c5c5dcf555c09a4035ce3ae8ef1b6c49.1782808461.git.u.kleine-koenig@baylibre.com Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
2026-06-22Merge tag 'char-misc-7.2-rc1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc Pull misc driver updates from Greg KH: "Here is the big set of char, misc, iio, fpga, and other small driver subsystems changes for 7.2-rc1. Lots of little stuff in here, the majority being of course the IIO driver updates, as a list they are: - IIO driver updates and additions - GPIB driver bugfixes and cleanups - Android binder driver updates (rust and C version) - counter driver updates - MHI driver updates - mei driver updates - w1 driver updates - interconnect driver updates - Comedi driver fixes and updates - some obsolete char drivers removed (applicom and dtlk) - hwtracing driver updates - other tiny driver updates All of these have been in linux-next for a while with no reported issues" * tag 'char-misc-7.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (406 commits) w1: ds2482: Use named initializers for arrays of i2c_device_data firmware: stratix10-svc: Add support to query Arm Trusted Firmware (ATF) version firmware: stratix10-rsu: avoid blocking reboot_image sysfs when busy coresight: ultrasoc-smb: Fix OOB write in smb_sync_perf_buffer() iio: adc: nxp-sar-adc: harden buffer ISR against per-channel read failure iio: chemical: scd30: Replace manual locking with RAII locking iio: light: tsl2591: remove unneeded tsl2591_compatible_als_persist_cycle() iio: dac: ad5686: create bus ops struct iio: dac: ad5686: cleanup doc header of local structs iio: dac: ad5686: add control_sync() for single-channel devices iio: dac: ad5686: add helpers to handle powerdown masks iio: dac: ad5686: add of_match table to the spi driver iio: dac: ad5686: drop enum id iio: dac: ad5686: remove redundant register definition iio: dac: ad5686: refactor include headers iio: adc: ad4080: fix AD4880 chip ID iio: light: veml3328: add support for new device dt-bindings: iio: light: veml6030: add veml3328 fpga: microchip-spi: fix zero header_size OOB read in mpf_ops_parse_header() fpga: dfl-afu: validate DMA mapping length in afu_dma_map_region() ...
2026-06-17Merge tag 'bitmap-for-7.2' of https://github.com/norov/linuxLinus Torvalds
Pull bitmap updates from Yury Norov: "This includes the new FIELD_GET_SIGNED() helper, bitmap_print_to_pagebuf() removal, RISCV/bitrev support, and a couple cleanups. - new handy helper FIELD_GET_SIGNED() (Yury) - arch test_and_set_bit_lock() and clear_bit_unlock() cleanup (Randy) - __bf_shf() simplification (Yury) - bitmap_print_to_pagebuf() removal (Yury) - RISCV/bitrev conditional support (Jindie, Yury)" * tag 'bitmap-for-7.2' of https://github.com/norov/linux: MAINTAINERS: BITOPS: include bitrev.[ch] arch/riscv: Add bitrev.h file to support rev8 and brev8 bitops: Define generic___bitrev8/16/32 for reuse lib/bitrev: Introduce GENERIC_BITREVERSE arch: select HAVE_ARCH_BITREVERSE conditionally on BITREVERSE bitmap: fix find helper documentation bitmap: drop bitmap_print_to_pagebuf() cpumask: switch cpumap_print_to_pagebuf() to using scnprintf() bitfield: wire __bf_shf to __builtin_ctzll bitops: use common function parameter names ptp: switch to using FIELD_GET_SIGNED() rtc: rv3032: switch to using FIELD_GET_SIGNED() wifi: rtw89: switch to using FIELD_GET_SIGNED() iio: mcp9600: switch to using FIELD_GET_SIGNED() iio: pressure: bmp280: switch to using FIELD_GET_SIGNED() iio: magnetometer: yas530: switch to using FIELD_GET_SIGNED() iio: intel_dc_ti_adc: switch to using FIELD_GET_SIGNED() x86/extable: switch to using FIELD_GET_SIGNED() bitfield: add FIELD_GET_SIGNED()
2026-06-14Merge tag 'iio-fixes-for-7.1b' of ↵Greg Kroah-Hartman
ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next IIO: 2nd set of fixes for the 7.1 cycle. Usual mixed bag of ancient issues and the recently introduced. Various drivers - Ensure use of simple_write_to_buffer() in debugfs callbacks doesn't result in reading off the end of intended data by checking the position is always 0. buffer/hw-consumer - Ensure scan_mask is freed on buffer release. acpi-als - Check ACPI_COMPANION() against NULL to close corner case where a driver is overridden. adi,ad4062 - Add GPIOLIB dependency to avoid undefined ref to gpiochip_get_data() adi.ad7768-1 - Add GPIOLIB dependency to avoid several undefined functions. adi,ad2s1210 - Ensure possible recovery path if a read fails in the interrupt handler. bosch,bmg160 - Increase sleep on startup to ensure device is ready. bosch,bmp280 - Ensure buffer pushed to kfifo is zeroed to avoid leaking uninitialized stack data to userspace. dyna-image,al3010 - Fix refactor that stopped reading one of the two measurement registers. dyna-image,al3320a - Fix refactor that stopped reading one of the two measurement registers. qcom,spmi-iadc - Ensure disable_irq_wake() is called on remove path. sensiron,scd30 - Fix a sign extension bug. st,vl5310x - Ensure possible recovery path if a read fails in the interrupt handler. ti,adc1298 - Bounds check for pga_settings index. Hardening against device returning unexpected values. ti,tmp006 - Ensure trigger correctly released on remove path. vishay,veml6030 - Fix incorrect channel type in events. vishay,veml6074 - Bounds check for veml6075_it_ms. Hardening against device returning unexpected values. * tag 'iio-fixes-for-7.1b' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (23 commits) iio: adc: ad_sigma_delta: fix clear_pending_event for registerless devices iio: adc: ad_sigma_delta: fix CS held asserted and state leaks iio: light: opt3001: fix missing state reset on timeout iio: chemical: scd30: Cleanup initializations and fix sign-extension bug iio: core: fix uninitialized data in debugfs iio: backend: fix uninitialized data in debugfs iio: dac: ad3552r-hs: fix uninitialized data ni ad3552r_hs_write_data_source() iio: adc: qcom-spmi-iadc: balance enable_irq_wake() on driver unbind iio: light: al3320a: read both ALS ADC registers again iio: light: al3010: read both ALS ADC registers again iio: temperature: tmp006: use devm_iio_trigger_register iio: buffer: hw-consumer: free scan_mask on buffer release iio: adc: ad7768-1: Select GPIOLIB iio: light: veml6030: fix channel type when pushing events iio: light: acpi-als: Check ACPI_COMPANION() against NULL iio: resolver: ad2s1210: notify trigger and clear state on fault read error iio: proximity: vl53l0x: notify trigger and clear IRQ on error paths iio: gyro: bmg160: wait full startup time after mode change at probe iio: gyro: bmg160: bail out when bandwidth/filter is not in table iio: pressure: bmp280: zero-init bmp580 trigger handler buffer ...
2026-06-03iio: adc: nxp-sar-adc: harden buffer ISR against per-channel read failureStepan Ionichev
nxp_sar_adc_isr_buffer() bails on the first channel-read failure without calling iio_trigger_notify_done(), so the trigger use_count is left incremented and iio_trigger_poll_chained() drops subsequent dispatches until the device is rebound. Reaching this path means a state machine has gone wrong (driver bug or the SAR ADC in an unexpected state) rather than a transient bus issue, so this is hardening rather than a bug fix. If the underlying condition persists the device is wedged and needs an unbind anyway. Call iio_trigger_notify_done() on the error exit too, matching the success path. The nxp_sar_adc_read_notify() duplication is intentional and avoids a goto label for a two-line bail-out, as suggested by David. Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-06-03iio: chemical: scd30: Replace manual locking with RAII lockingMaxwell Doose
scd30_core.c currently uses manual mutex_lock() and mutex_unlock() calls. Replace them with the newer guard(mutex)() for cleaner RAII patterns and to improve maintainability. Add new helper function scd30_trigger_handler_helper() containing the critical section for scd30_trigger_handler(). In addition, small refactor to replace "?:" operator with regular if/else returns. Signed-off-by: Maxwell Doose <m32285159@gmail.com> Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-06-03iio: light: tsl2591: remove unneeded tsl2591_compatible_als_persist_cycle()Lucas Rabaquim
The function was only used to verify if als_persist is a TSL2591_PRST_ALS_INT_CYCLE_* value. However, before its call in tsl2591_write_event_value(), the line als_persist = tsl2591_persist_lit_to_cycle(period) is executed, meaning that by the time tsl2591_compatible_als_persist_cycle() is reached, als_persist is a TSL2591_PRST_ALS_INT_CYCLE_* value, making the verification pointless. Suggested-by: Sashiko <sashiko-bot@kernel.org> Link: https://sashiko.dev/#/patchset/20260528185912.24774-1-matheus.feitosa%40usp.br Signed-off-by: Lucas Rabaquim <lucas.rabaquim@usp.br> Co-developed-by: Matheus Silveira <matheus.feitosa@usp.br> Signed-off-by: Matheus Silveira <matheus.feitosa@usp.br> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-06-02iio: dac: ad5686: create bus ops structRodrigo Alencar
Create struct with bus operations, which will be used to extend bus implementation features. Auxiliary functions ad5686_write() and ad5686_read() are created and ad5686_probe() now receives an ops struct pointer rather than individual read and write functions. Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-06-02iio: dac: ad5686: cleanup doc header of local structsRodrigo Alencar
Review documentation comment header for ad5686_chip_info and ad5686_state. Update variable names and description and remove unnecessary blank line between comment and struct declaration. Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-06-02iio: dac: ad5686: add control_sync() for single-channel devicesRodrigo Alencar
Create ad5310_control_sync() and ad5683_control_sync() functions that properly consume the mask definitions with FIELD_PREP(). This allows to reuse a function that updates the control register with cached values, without relying on confusing logic that depends on st->use_internal_vref, which is initialized earlier in ad5686_probe() because it is also applicable to the AD5686_REGMAP case, removing the need for the has_external_vref. Powerdown masks initialization is simplified as *_control_sync() masks outs any unused bits for the single-channel case. The change cleans up ad5686_write_dac_powerdown() and ad5686_probe(), organizing the code for feature extension, e.g. gain control support for single-channel devices. Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-06-02iio: dac: ad5686: add helpers to handle powerdown masksRodrigo Alencar
Add ad5686_pd_field_set() and ad5686_pd_field_get() helpers to cleanup powerdown mask control. Define AD5686_PD_* constants, e.g. AD5686_PD_MSK to hold powerdown mask value for a single channel. AD5686_LDAC_PWRDN_* macros are replaced by AD5686_PD_MODE_*, because they are unused and the LDAC feature for async load of DAC channel values is not related to power down control. Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-06-02iio: dac: ad5686: add of_match table to the spi driverRodrigo Alencar
Add of_match table for the SPI device variants to be consistent with the AD5696 I2C driver. Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-06-02iio: dac: ad5686: drop enum idRodrigo Alencar
Split chip info table into separate structs and expose them to the spi i2c drivers. That is the preferrable approach and allows for the drivers to have knowledge of the device info before the common probe function gets called. Those chip info structs may be shared by SPI and I2C driver variants. Channel declaration definitions are grouped according to channel count and DECLARE_AD5693_CHANNELS() macro is renamed to DECLARE_AD5683_CHANNELS() to match the regmap_type enum. Use spi_get_device_match_data() and i2c_get_match_data() to get chip info struct reference, passing it as parameter to the core probe function. Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-06-02iio: dac: ad5686: remove redundant register definitionRodrigo Alencar
AD5683_REGMAP and AD5693_REGMAP behave the same way in the common code, and that is because they target single channel devices from the same sub-family. There is no reason to separate them and it will make things simpler when refactoring the chip info table. Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-06-02iio: dac: ad5686: refactor include headersRodrigo Alencar
Apply IWYU principle, replacing unused/generic headers for specific/missing headers. The resulting include directive lists are sorted accordingly. Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-06-02Merge tag 'v7.1-rc6' into workJonathan Cameron
Linux 7.1-rc6
2026-06-02iio: adc: ad4080: fix AD4880 chip IDAntoniu Miclaus
The AD4880 chip ID was incorrectly set to 0x0750. According to the datasheet, the product ID registers read 0x00 (PRODUCT_ID_H) and 0x59 (PRODUCT_ID_L), giving a combined chip ID of 0x0059. Fix the value to match the actual hardware. Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-06-02iio: light: veml3328: add support for new deviceJoshua Crofts
Add support for the Vishay VEML3328 RGB/IR light sensor communicating via I2C (SMBus compatible). Also add a new entry for said driver into Kconfig and Makefile. Assisted-by: Gemini:3.1-Pro Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: adc: ad4691: add oversampling supportRadu Sabau
Add oversampling ratio (OSR) support for CNV burst mode. The accumulator depth register (ACC_DEPTH_IN(0)) is programmed with the selected OSR at buffer enable time and before each single-shot read. Supported OSR values: 1, 2, 4, 8, 16, 32. Introduce AD4691_MANUAL_CHANNEL() for manual mode channels, which do not expose the oversampling_ratio attribute since OSR is not applicable in that mode. A separate manual_channels array is added to struct ad4691_channel_info and selected at probe time. The OSR is shared across all channels (in_voltage_sampling_frequency and in_voltage_oversampling_ratio are info_mask_shared_by_all) because the chip has one internal oscillator and a single accumulator depth register (ACC_DEPTH_IN(0)) for all channels. in_voltage_sampling_frequency represents the effective output rate, defined as osc_freq / osr. Writing it computes needed_osc = freq * osr and snaps down to the largest oscillator table entry that satisfies both osc <= needed_osc and osc % osr == 0, guaranteeing an exact integer read-back. The result is stored in target_osc_freq_Hz and written to OSC_FREQ_REG at buffer enable and single-shot time, so sampling_frequency and oversampling_ratio can be set in any order. in_voltage_sampling_frequency_available is precomputed at probe for each OSR value, listing only oscillator table entries that divide evenly by that OSR, expressed as effective rates (osc_freq / osr). The list becomes sparser as OSR increases, capping at max_rate / osr. read_avail picks the precomputed list for the current OSR, making the returned pointer stable and race-free. Writing oversampling_ratio stores the new shared OSR and snaps target_osc_freq_Hz to the largest oscillator table entry that is both <= old_effective_rate * new_osr and evenly divisible by new_osr. This preserves an integer read-back of in_voltage_sampling_frequency after the OSR change while keeping the oscillator as close as possible to the previous effective rate. OSR defaults to 1 (no accumulation). Signed-off-by: Radu Sabau <radu.sabau@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: adc: ad4691: add SPI offload supportRadu Sabau
Add SPI offload support to enable DMA-based, CPU-independent data acquisition using the SPI Engine offload framework. When an SPI offload is available (devm_spi_offload_get() succeeds), the driver registers a DMA engine IIO buffer and uses dedicated buffer setup operations. If no offload is available the existing software triggered buffer path is used unchanged. Both CNV Burst Mode and Manual Mode support offload, but use different trigger mechanisms: CNV Burst Mode: the SPI Engine is triggered by the ADC's DATA_READY signal on the GP pin specified by the trigger-source consumer reference in the device tree (one cell = GP pin number 0-3). For this mode the driver acts as both an SPI offload consumer (DMA RX stream, message optimization) and a trigger source provider: it registers the GP/DATA_READY output via devm_spi_offload_trigger_register() so the offload framework can match the '#trigger-source-cells' phandle and automatically fire the SPI Engine DMA transfer at end-of-conversion. Manual Mode: the SPI Engine is triggered by a periodic trigger at the configured sampling frequency. The pre-built SPI message uses the pipelined CNV-on-CS protocol: N+1 16-bit transfers are issued for N active channels (the first result is discarded as garbage from the pipeline flush) and the remaining N results are captured by DMA. All offload transfers use 16-bit frames (bits_per_word=16, len=2). The SPI Engine assembles received bits into native 16-bit words before DMA, so offload samples land in CPU-native byte order (IIO_CPU). Dedicated channel arrays (AD4691_OFFLOAD_CHANNEL) reflect this: they omit IIO_BE and carry no soft timestamp (DMA delivers data directly to userspace). The software triggered-buffer path retains its IIO_BE channels because bits_per_word=8 causes SPI to deliver bytes MSB-first into memory, making the on-disk layout big-endian. Both paths use storagebits=16 as transfers are 16 bits wide in both cases. IIO_BUFFER_DMAENGINE is selected because the offload path uses devm_iio_dmaengine_buffer_setup_with_handle() to allocate and attach the DMA RX buffer to the IIO device. Signed-off-by: Radu Sabau <radu.sabau@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: adc: ad4691: add triggered buffer supportRadu Sabau
Add buffered capture support using the IIO triggered buffer framework. CNV Burst Mode: the GP pin identified by interrupt-names in the device tree is configured as DATA_READY output. The IRQ handler stops conversions and fires the IIO trigger; the trigger handler executes a pre-built SPI message that reads all active channels from the AVG_IN accumulator registers and then resets accumulator state and restarts conversions for the next cycle. Manual Mode: CNV is tied to SPI CS so each transfer simultaneously reads the previous result and starts the next conversion (pipelined N+1 scheme). At preenable time a pre-built, optimised SPI message of N+1 transfers is constructed (N channel reads plus one NOOP to drain the pipeline). The trigger handler executes the message in a single spi_sync() call and collects the results. An external trigger (e.g. iio-trig-hrtimer) is required to drive the trigger at the desired sample rate. Both modes share the same trigger handler and push a complete scan — one big-endian 16-bit (__be16) slot per active channel, densely packed in scan_index order, followed by a timestamp. The CNV Burst Mode sampling frequency (PWM period) is exposed as a buffer-level attribute via IIO_DEVICE_ATTR. Signed-off-by: Radu Sabau <radu.sabau@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: adc: ad4691: add initial driver for AD4691 familyRadu Sabau
Add support for the Analog Devices AD4691 family of high-speed, low-power multichannel SAR ADCs: AD4691 (16-ch, 500 kSPS), AD4692 (16-ch, 1 MSPS), AD4693 (8-ch, 500 kSPS) and AD4694 (8-ch, 1 MSPS). The driver implements a custom regmap layer over raw SPI to handle the device's mixed 1/2/3/4-byte register widths and uses the standard IIO read_raw/write_raw interface for single-channel reads. The chip idles in Autonomous Mode so that single-shot read_raw can use the internal oscillator without disturbing the hardware configuration. Three voltage supply domains are managed: avdd (required), vio, and a reference supply on either the REF pin (ref-supply, external buffer) or the REFIN pin (refin-supply, uses the on-chip reference buffer; REFBUF_EN is set accordingly). Hardware reset is performed by asserting then deasserting the reset-gpios GPIO line (tRESETL minimum pulse width is 10 ns, satisfied by function-call overhead); the driver then waits 300 µs for the chip to complete its internal reset sequence. A software reset via SPI_CONFIG_A is used as fallback when no reset GPIO is provided. Accumulator channel masking for single-shot reads uses ACC_MASK_REG via an ADDR_DESCENDING SPI write, which covers both mask bytes in a single 16-bit transfer. Reviewed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Radu Sabau <radu.sabau@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: adc: ad4080: add support for AD4884Antoniu Miclaus
Add support for the AD4884, a dual-channel, 16-bit, 40 MSPS SAR ADC. The AD4884 is the dual-channel variant of the AD4084, sharing the same register map and SPI interface as the rest of the AD4080 family. Like the AD4880, it uses two independent ADC channels, each with its own SPI configuration interface. Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31light: tsl2591: simplify tsl2591_persist functions via lookup tableMatheus Silveira
Replace switch statements with an indexed lookup table for persist cycle conversions. Both functions contain redundant switch statements. This reduces code duplication and makes future updates to TSL2591_PRST_ALS_INT_CYCLE_* definitions easier to maintain by keeping the mapping in a single place. Signed-off-by: Matheus Silveira <matheus.feitosa@usp.br> Co-developed-by: Lucas Rabaquim <lucas.rabaquim@usp.br> Signed-off-by: Lucas Rabaquim <lucas.rabaquim@usp.br> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: Use named initializers for platform_device_id arraysUwe Kleine-König (The Capable Hub)
Named initializers are better readable and more robust to changes of the struct definition. This robustness is relevant for a planned change to struct platform_device_id replacing .driver_data by an anonymous union. Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: temperature: ltc2983: Add support for ADT7604Liviu Stan
The ADT7604 shares the same die as the LTC2984. It repurposes the custom RTD sensor type (18) as a copper trace resistance sensor and the custom thermistor type (27) as a leak detector, and removes thermocouple, diode and direct ADC sensor types. Two new software sensor type values are introduced (LTC2983_SENSOR_COPPER_TRACE = 32, LTC2983_SENSOR_LEAK_DETECTOR = 33) that map to the hardware register values 18 and 27 respectively. Dedicated structs (ltc2983_copper_trace, ltc2983_leak_detector) and parser functions are added rather than extending the existing RTD and thermistor paths, as the hardware configuration bits are fully hardcoded and several RTD/thermistor properties would need to be explicitly forbidden or ignored. Custom RTD (type 18) becomes the copper trace sensor. Sensor configuration bits are hardcoded to 0b1001 per the datasheet. Two variants are supported via the adi,copper-trace-sub-ohm DT property: sub-ohm traces (< 1 ohm) have bits 17:0 cleared with no excitation current or custom table; standard traces (> 1 ohm) have a required resistance-to-temperature table. Custom thermistor (type 27) becomes the leak detector. Sensor configuration bits are hardcoded to 0b001. The custom table uses a resolution of 16 instead of 64, and is specified via the required adi,custom-leak-detector DT property. Both sensor types expose an IIO_RESISTANCE channel reading from the resistance result register bank (0x0060-0x00AF). Added a "base" parameter to the LTC2983_RESULT_ADDR macro and a "base_reg" parameter to the ltc2983_chan_read function so we can read from both result register banks. The resistance register encodes the measured resistance with 10 fractional bits, so dividing by 1024 gives ohms. Since the sense resistor is specified in ohms, the output is in ohms for both sensor types and a single 1/1024 scale applies to both. For > 1 ohm copper traces and for leak detectors, a secondary channel also appears: IIO_TEMP (millidegrees Celsius) for copper trace and IIO_COVERAGE (percent) for leak detector. The ltc2983_chip_info struct is extended with a u64 supported_sensors bitmask using BIT_ULL() to safely represent the new sensor type bits 32 and 33 on 32-bit builds. A LTC2983_SENSOR_NUM sentinel is added to the enum so that the bounds check uses >= LTC2983_SENSOR_NUM rather than hardcoding the last sensor type. Tested on EVAL-ADT7604-AZ connected to Raspberry Pi 5 via SPI. Signed-off-by: Liviu Stan <liviu.stan@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: core: Add IIO_COVERAGE channel typeLiviu Stan
Add a new channel type for sensors that report fractional coverage as a percentage. The sysfs attribute is in_coverageY_raw; after applying in_coverageY_scale the value is in percent. The first user is the ADT7604 leak detector, where the value represents the portion of the sensing element that is wetted. Signed-off-by: Liviu Stan <liviu.stan@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: temperature: ltc2983: Use fwnode_property_present() for optional propertiesLiviu Stan
Checking fwnode_property_read_u32() return value with if (!ret) silently swallows meaningful error codes when a property is present but malformed. Use fwnode_property_present() first so that absence uses the default while a present but unreadable property returns a proper error. Signed-off-by: Liviu Stan <liviu.stan@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: temperature: ltc2983: Fix inconsistent channel wording in messagesLiviu Stan
Replace occurrences of the abbreviated 'chann' and 'chan' with 'channel' in error and debug messages throughout the driver. Also changed the diode invalid channel error message from "thermistor" to "diode". Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com> Signed-off-by: Liviu Stan <liviu.stan@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: temperature: ltc2983: Use local device pointer consistentlyLiviu Stan
Some functions define a local 'dev' pointer but still use bare '&st->spi->dev' in some code paths, and some don't have it at all. Replace bare references with the local pointer for consistency and collapse some wrapped lines that now fit within 80 characters. Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com> Signed-off-by: Liviu Stan <liviu.stan@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: temperature: ltc2983: Fix macro parenthesization and renameLiviu Stan
Wrap the 'chan' parameter in LTC2983_CHAN_START_ADDR() and LTC2983_CHAN_RES_ADDR() with parentheses to prevent potential macro argument expansion issues. Also rename LTC2983_CHAN_START_ADDR to LTC2983_CHAN_ASSIGN_ADDR and LTC2983_CHAN_RES_ADDR to LTC2983_RESULT_ADDR, to better reflect the datasheet names and avoid them being confused as related. Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com> Signed-off-by: Liviu Stan <liviu.stan@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: temperature: ltc2983: Fix reinit_completion() called after conversion startLiviu Stan
reinit_completion() was called after regmap_write() initiated the hardware conversion, creating a race window where the interrupt could fire and call complete() before reinit_completion() reset the completion. Move reinit_completion() before the regmap_write() to close the race. ltc2983_eeprom_cmd() already does it in the correct order. Fixes: f110f3188e56 ("iio: temperature: Add support for LTC2983") Signed-off-by: Liviu Stan <liviu.stan@analog.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: temperature: ltc2983: Fix n_wires default bypassing rotation checkLiviu Stan
When adi,number-of-wires is absent, n_wires is left at 0. The binding documents a default of 2 wires, matching the hardware default. However the current-rotate validation checks n_wires == 2 || n_wires == 3, so with n_wires = 0 the guard is bypassed and adi,current-rotate is accepted for a 2-wire RTD. Initialize n_wires = 2 to match the binding default and ensure the rotation check fires correctly when the property is absent. Fixes: f110f3188e56 ("iio: temperature: Add support for LTC2983") Signed-off-by: Liviu Stan <liviu.stan@analog.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: light: add support for APDS9999 sensorJose A. Perez de Azpillaga
Add IIO driver for Broadcom APDS9999 ambient light sensor. The APDS9999 is a digital proximity and RGB sensor with ALS capability. The driver implements the ALS/Lux functionality using the green channel, which uses optical coating technology to approximate the human eye spectral response. Raw IIO_INTENSITY channels are exposed for red, green, blue, and IR so userspace can compute its own weighted lux. Proximity (PS) support is not yet implemented. Signed-off-by: Jose A. Perez de Azpillaga <azpijr@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: adc: spear_adc: align headers with IWYU principleRodrigo Gobbi
Remove unused includes and add what is being used: #include <linux/array_size.h> // for ARRAY_SIZE #include <linux/bits.h> // for GENMASKxx #include <linux/dev_printk.h> // for dev_err_probe, dev_info #include <linux/math.h> // for DIV_ROUND_UP #include <linux/mutex.h> // for struct mutex #include <linux/types.h> // for uXX definitions #include <linux/iio/types.h> // for IIO_CHAN_INFO_* Signed-off-by: Rodrigo Gobbi <rodrigo.gobbi.7@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: adc: spear_adc: sort includes alphabeticallyRodrigo Gobbi
Sort includes alphabetically, no functional change Signed-off-by: Rodrigo Gobbi <rodrigo.gobbi.7@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: pressure: cros_ec_baro: simplify timestamp channel definitionDavid Lechner
Use IIO_CHAN_SOFT_TIMESTAMP() to define the timestamp channel instead of manually filling in the struct iio_chan_spec fields. This makes the code less verbose and mistake-prone. Also drop obvious comment while we're at it. Signed-off-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: light: cros_ec_light_prox: simplify timestamp channel definitionDavid Lechner
Use IIO_CHAN_SOFT_TIMESTAMP() to define the timestamp channel instead of manually filling in the struct iio_chan_spec fields. This makes the code less verbose and mistake-prone. Also drop obvious comment while we're at it. Signed-off-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: common: cros_ec_sensors: simplify timestamp channel definitionDavid Lechner
Use IIO_CHAN_SOFT_TIMESTAMP() to define the timestamp channel instead of manually filling in the struct iio_chan_spec fields. This makes the code less verbose and mistake-prone. Also drop obvious comment while we're at it. Signed-off-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: adc: stm32-adc: simplify timestamp channel definitionDavid Lechner
Use IIO_CHAN_SOFT_TIMESTAMP() to define the timestamp channel instead of manually filling in the struct iio_chan_spec fields. This makes the code less verbose and mistake-prone. Signed-off-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: adc: cc10001_adc: simplify timestamp channel definitionDavid Lechner
Use IIO_CHAN_SOFT_TIMESTAMP() to define the timestamp channel instead of manually filling in the struct iio_chan_spec fields. This makes the code less verbose and mistake-prone. Signed-off-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: adc: at91_adc: simplify timestamp channel definitionDavid Lechner
Use IIO_CHAN_SOFT_TIMESTAMP() to define the timestamp channel instead of manually filling in the struct iio_chan_spec fields. This makes the code less verbose and mistake-prone. Signed-off-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: adc: dln2-adc: simplify timestamp channel definitionDavid Lechner
Use IIO_CHAN_SOFT_TIMESTAMP() to define the timestamp channel instead of manually filling in the struct iio_chan_spec fields. This makes the code less verbose and mistake-prone. Signed-off-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: common: scmi_sensors: simplify timestamp channel definitionDavid Lechner
Use IIO_CHAN_SOFT_TIMESTAMP() to define the timestamp channel instead of manually filling in the struct iio_chan_spec fields. This makes the code less verbose and mistake-prone. In fact, there was an error here as the sign should be 's' instead of 'u' which is now changed to 's' by using IIO_CHAN_SOFT_TIMESTAMP(). If we find that this breaks userspace, we will have to revert this change, but seems unlikely since the timestamp channel is well-known to be a signed 64-bit integer globally. Signed-off-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: Convert IIO_CHAN_SOFT_TIMESTAMP() to be compound literalAndy Shevchenko
Currently IIO_CHAN_SOFT_TIMESTAMP() can only be used to fill the static data. In some cases it would be convenient to use it as right value in the assignment operation. But it can't be done as is, because compiler has no clue about the data layout. Converting it to be a compound literal allows the above mentioned usage. While at it, tidy up the indentation. We also have to change existing uses of compound literal at the same time to avoid compiler errors. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: chemical: sps30: Replace manual locking with RAII lockingMaxwell Doose
Replace manual mutex_lock() and mutex_unlock() calls with the much newer guard(mutex)() macro to enable RAII patterns, modernize the driver, and to increase readability. Move mutex locking into sps30_do_meas() and tune it up to use guard()(), as every caller takes the lock anyways. Signed-off-by: Maxwell Doose <m32285159@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: tcs3472: move standalone return to default caseAldo Conte
Move the trailing 'return -EINVAL' statements at the end of tcs3472_read_raw() and tcs3472_write_raw() into explicit default: cases inside the respective switch statements. This removes the need for a separate return statement after the switch. No functional change. Suggested-by: Andy Shevchenko <andy@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com> Signed-off-by: Aldo Conte <aldocontelk@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: tcs3472: use local struct device * for remaining casesAldo Conte
Use the local 'struct device *dev' variable introduced for the devm calls also for the dev_info() calls in tcs3472_probe(), to keep the probe function consistent. No functional change. Signed-off-by: Aldo Conte <aldocontelk@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: tcs3472: use devm for resource managementAldo Conte
Convert the driver to use device-managed resource allocation: - Add tcs3472_powerdown_action() and register it with devm_add_action_or_reset() to ensure the device is powered down on cleanup. - Replace iio_triggered_buffer_setup() with devm_iio_triggered_buffer_setup(). - Replace request_threaded_irq() with devm_request_threaded_irq(). - Replace iio_device_register() with devm_iio_device_register(). - Replace mutex_init() with devm_mutex_init(). - Remove tcs3472_remove() as all cleanup is now handled by devm. Use a local 'dev = &client->dev' in tcs3472_probe() to keep the devm calls compact. Signed-off-by: Aldo Conte <aldocontelk@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31iio: tcs3472: use ! instead of explicit NULL checkAldo Conte
Replace 'if (indio_dev == NULL)' with 'if (!indio_dev)' in tcs3472_probe() to follow the preferred kernel style. No functional change. Suggested-by: Joshua Crofts <joshua.crofts1@gmail.com> Signed-off-by: Aldo Conte <aldocontelk@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>