summaryrefslogtreecommitdiff
path: root/drivers/iio/light
AgeCommit message (Collapse)Author
2025-04-07iio: hid-sensor-prox: Fix incorrect OFFSET calculationZhang Lixu
The OFFSET calculation in the prox_read_raw() was incorrectly using the unit exponent, which is intended for SCALE calculations. Remove the incorrect OFFSET calculation and set it to a fixed value of 0. Cc: stable@vger.kernel.org Fixes: 39a3a0138f61 ("iio: hid-sensors: Added Proximity Sensor Driver") Signed-off-by: Zhang Lixu <lixu.zhang@intel.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://patch.msgid.link/20250331055022.1149736-4-lixu.zhang@intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-04-07iio: hid-sensor-prox: support multi-channel SCALE calculationZhang Lixu
With the introduction of multi-channel support in commit 596ef5cf654b ("iio: hid-sensor-prox: Add support for more channels"), each channel requires an independent SCALE calculation, but the existing code only calculates SCALE for a single channel. Addresses the problem by modifying the driver to perform independent SCALE calculations for each channel. Cc: stable@vger.kernel.org Fixes: 596ef5cf654b ("iio: hid-sensor-prox: Add support for more channels") Signed-off-by: Zhang Lixu <lixu.zhang@intel.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://patch.msgid.link/20250331055022.1149736-3-lixu.zhang@intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-04-07iio: hid-sensor-prox: Restore lost scale assignmentsZhang Lixu
The variables `scale_pre_decml`, `scale_post_decml`, and `scale_precision` were assigned in commit d68c592e02f6 ("iio: hid-sensor-prox: Fix scale not correct issue"), but due to a merge conflict in commit 9c15db92a8e5 ("Merge tag 'iio-for-5.13a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next"), these assignments were lost. Add back lost assignments and replace `st->prox_attr` with `st->prox_attr[0]` because commit 596ef5cf654b ("iio: hid-sensor-prox: Add support for more channels") changed `prox_attr` to an array. Cc: stable@vger.kernel.org # 5.13+ Fixes: 9c15db92a8e5 ("Merge tag 'iio-for-5.13a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next") Signed-off-by: Zhang Lixu <lixu.zhang@intel.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://patch.msgid.link/20250331055022.1149736-2-lixu.zhang@intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-04-07iio: light: opt3001: fix deadlock due to concurrent flag accessLuca Ceresoli
The threaded IRQ function in this driver is reading the flag twice: once to lock a mutex and once to unlock it. Even though the code setting the flag is designed to prevent it, there are subtle cases where the flag could be true at the mutex_lock stage and false at the mutex_unlock stage. This results in the mutex not being unlocked, resulting in a deadlock. Fix it by making the opt3001_irq() code generally more robust, reading the flag into a variable and using the variable value at both stages. Fixes: 94a9b7b1809f ("iio: light: add support for TI's opt3001 light sensor") Cc: stable@vger.kernel.org Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Link: https://patch.msgid.link/20250321-opt3001-irq-fix-v1-1-6c520d851562@bootlin.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-03-14Merge tag 'iio-for-6.15a' 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.15 cycle. The usual mixture of new drivers, support in existing drivers for new devices, a range of features and general subsystem cleanup. Two merges of immutable branches in here: * SPI offload support. Culmination of a long effort to bring the ability to offload triggered sequences of SPI operations to specific hardware, allow high datarate acquisition over an SPI bus (if you have the right hardware / FPGA firmware) * GPIO set-array-helper - enables code simplification. New device support ================== adi,ad3552r-hs: - Add support for AD3541r and AD3542r via newly supported FPGA HDL. adi,ad4030 - New driver supporting the AD4030, AD4630 AD4630-16, AD4640-24, AD4632-16, AD4632-24 1 and 2 channel high precision SPI ADCs. adi,ad4851 - New driver and backend support for the AD4851, AD4852, AD4853, AD4854, AD4855, AD4846, AD4857, AD4858 and AD4858I high speed multichannel simultaneous sampling ADCs. adi,ad7191 - New driver for this 24-bit ADC for precision bridge applications, adi,ad7380 - Add support for the adaq4381-4 which is a 14-bit version of the already supported adaq4380-1 adi,adis16550 - New driver using the ADIS library (which needed extensions) for this IMU. brcm,apds9160 - New driver for this proximity and ambient light sensor. dynaimage,al3000a - New driver for this illuminance sensor. mcube,mc3230 - Add support for the mc3510c accelerometer with a different scale to existing supported parts (some rework preceded this) nxp,imx93 - Add compatibles for imx94 and imx95 which are fully compatible with imx93. rockchip,saradc - Add support for the RK3528 ADC - Add support for the RK3562 ADC silab,si7210 - New driver to support this I2C Hall effect magnetic position sensor. ti,ads7138 - New driver supporting the ADS7128 and AD7138 I2C ADCs. Staging driver drop =================== adi,adis16240 - Drop this impact sensor. Interesting part but complex hence never left staging due to ABI challenges. No longer readily available so drop driver. New features ============ Documentation - A really nice overview document introduce ADC terminology and how it maps to IIO. core - New description for FAULT events, used in the ad7173. - filter_type ABI used in ad4130. buffer-dmaengine - Split DMA channel request from buffer allocation (for SPI offload) - Add a new _with_handle setup variant. (for SPI offload) adi,adf4371 - Add control of reference clock type and support for frequency doubling where appropriate. adi,ad4695 - Support SPI offload. - Support oversampling control. adi,ad5791 - Support SPI offload. adi,ad7124 - Add channel calibration support. adi,ad7380: - Alert support (threshold interrupts) - SPI offload support. adi,ad7606 - Support writing registers when using backend enabling software control of modes. adi,ad7944 - Support SPI offload. adi,ad9832 - Use devm_regulator_get_enable() to simplify code. adi,ad9834 - Use devm_regulator_get_enable() to simplify code. adi,adxl345 - Improve IRQ handling code. - Add debug access to registers. bosch,bmi270 - Add temperature channel support. - Add data ready trigger. google,cross_ec - Add trace events. mcube,mc3230 - Add mount matrix support - Add an OF match table. Cleanup and minor bug fixes =========================== Tree wide: - Stop using iio_device_claim_direct_scoped() and introduce sparse friendly iio_device_claim/release_direct() The conditional scoped cleanup has proved hard to deal with, requiring workarounds for various compiler issues and in is rather non-intuitive so abandon that experiment. One of the attractions of that approach was that it made it much harder to have unbalanced claim/release bugs so instead introduce a conditional-lock style boolean returning new pair of functions. These are inline in the header and have __acquire and __release calls allowing sparse to detect lack of balance. There are occasional false positives but so far those have reflected complex code paths that benefited from cleanup anyway. The first set of driver conversions are in this pull request, more to follow next cycle. Various related cleanup in drivers. Removal of the _scoped code is completed and the definition removed. - Use of str_enable_disable() and similar helpers. - Don't set regmap cache to REGCACHE_NONE as that's the default anyway. - Change some caches from RBTREE to MAPLE reflecting best practice. - Use the new gpiod_multi_set_value_cansleep() - Make sure to grab direct mode for some calibrations paths. - Avoid using memcmp on structures when checking for matching channel configs. Instead just match field by field. dt-bindings: - Fix up indentation inconsistencies. gts-helper: - Simplify building of available scale table. adi,ad-sigma-delta - Make sure to disable channel after calibration done. - Add error handling in configuring channel during calibration. adi,ad2s1201 - use a bitmap_write() rather than directly accessing underlying storage. adi,ad3552r-hs - Fix a wrong error message. - Make sure to use instruction mode for configuration. adi,ad4695 - Add a conversion to ensure exit from conversion mode. - Use custom regmap to handle required sclk rate change. - Fix an out of bounds array access - Simplify oversampling ratio handling. adi,ad4851 - Fix a sign bug. adi,ad5791 - Fix wrong exported number of storage bits. adi,ad7124 - Disable all channels at probe to avoid strange initial configurations. adi,ad7173 - Rework to allow static const struct ad_sigma_delta without need to make a copy. adi,ad7623 - Drop a BSD license tag that the authors consider unnecessary. adi,ad7768-1 - Fix channels sign description exposed to user space. - Set MOSI idle state to avoid accidental device reset. - Avoid some overkill locking. adi,axi-dac - Check if device interface is busy when enabling data stream. - Add control of bus mode. bosch,bmi270 - Move a struct definition to a c file as only used there. vishay,veml6030 - Enable regmap cache to reduce bus traffic. - Fix ABI bug around scale reporting. vishay,vem6075 - Check array bounds to harden against broken hardware. Various other minor tweaks and fixes not called out. * * tag 'iio-for-6.15a' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (223 commits) doc: iio: ad7380: describe offload support iio: ad7380: add support for SPI offload iio: light: Add check for array bounds in veml6075_read_int_time_ms iio: adc: ti-ads7924 Drop unnecessary function parameters staging: iio: ad9834: Use devm_regulator_get_enable() staging: iio: ad9832: Use devm_regulator_get_enable() iio: gyro: bmg160_spi: add of_match_table dt-bindings: iio: adc: Add i.MX94 and i.MX95 support iio: adc: ad7768-1: remove unnecessary locking Documentation: ABI: add wideband filter type to sysfs-bus-iio iio: adc: ad7768-1: set MOSI idle state to prevent accidental reset iio: adc: ad7768-1: Fix conversion result sign iio: adc: ad7124: Benefit of dev = indio_dev->dev.parent in ad7124_parse_channel_config() iio: adc: ad7124: Implement system calibration iio: adc: ad7124: Implement internal calibration at probe time iio: adc: ad_sigma_delta: Add error checking for ad_sigma_delta_set_channel() iio: adc: ad4130: Adapt internal names to match official filter_type ABI iio: adc: ad7173: Fix comparison of channel configs iio: adc: ad7124: Fix comparison of channel configs iio: adc: ad4130: Fix comparison of channel setups ...
2025-03-11iio: light: Add check for array bounds in veml6075_read_int_time_msKaran Sanghavi
The array contains only 5 elements, but the index calculated by veml6075_read_int_time_index can range from 0 to 7, which could lead to out-of-bounds access. The check prevents this issue. Coverity Issue CID 1574309: (#1 of 1): Out-of-bounds read (OVERRUN) overrun-local: Overrunning array veml6075_it_ms of 5 4-byte elements at element index 7 (byte offset 31) using index int_index (which evaluates to 7) This is hardening against potentially broken hardware. Good to have but not necessary to backport. Fixes: 3b82f43238ae ("iio: light: add VEML6075 UVA and UVB light sensor driver") Signed-off-by: Karan Sanghavi <karansanghvi98@gmail.com> Reviewed-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://patch.msgid.link/Z7dnrEpKQdRZ2qFU@Emma Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-03-04iio: light: Fix spelling mistake "regist" -> "register"Colin Ian King
There are spelling mistakes in dev_err messages. Fix them. Signed-off-by: Colin Ian King <colin.i.king@gmail.com> Link: https://patch.msgid.link/20250228090228.679535-1-colin.i.king@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-03-04iio: light: Add support for AL3000a illuminance sensorSvyatoslav Ryhel
AL3000a is a simple I2C-based ambient light sensor, which is closely related to AL3010 and AL3320a, but has significantly different way of processing data generated by the sensor. Tested-by: Robert Eckelmann <longnoserob@gmail.com> Tested-by: Antoni Aloy Torrens <aaloytorrens@gmail.com> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com> Reviewed-by: David Heidelberg <david@ixit.cz> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20250217140336.107476-3-clamor95@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-02-17iio: light: bh1745: Stop using iio_device_claim_direct_scoped()Jonathan Cameron
This complex cleanup.h use case of conditional guards has proved to be more trouble that it is worth in terms of false positive compiler warnings and hard to read code. Move directly to the new claim/release_direct() that allow sparse to check for unbalanced context. Reviewed-by: Mudit Sharma <muditsharma.info@gmail.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Link: https://patch.msgid.link/20250209180624.701140-27-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-02-08iio: light: adux1020: Drop unneeded assignment for cache_typeAndy Shevchenko
REGCACHE_NONE is the default type of the cache when not provided. Drop unneeded explicit assignment to it. Note, it's defined to 0, and if ever be redefined, it will break literally a lot of the drivers, so it very unlikely to happen. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Link: https://patch.msgid.link/20250129152546.1798306-2-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-02-08iio: light: veml6030: fix scale to conform to ABIJavier Carrasco
The current scale is not ABI-compliant as it is just the sensor gain instead of the value that acts as a multiplier to be applied to the raw value (there is no offset). Use the iio-gts helpers to obtain the proper scale values according to the gain and integration time to match the resolution tables from the datasheet and drop dedicated variables to store the current values of the integration time, gain and resolution. When at it, use 'scale' instead of 'gain' consistently for the get/set functions to avoid misunderstandings. Fixes: 7b779f573c48 ("iio: light: add driver for veml6030 ambient light sensor") Acked-by: Matti Vaittinen <mazziesaccount@gmail.com> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://patch.msgid.link/20250127-veml6030-scale-v3-2-4f32ba03df94@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-02-08iio: light: Add APDS9160 ALS & Proximity sensor driverMikael Gonella-Bolduc
APDS9160 is a combination of ALS and proximity sensors. This patch add supports for: - Intensity clear data and illuminance data - Proximity data - Gain control, rate control - Event thresholds Signed-off-by: Mikael Gonella-Bolduc <mgonellabolduc@dimonoff.com> Link: https://patch.msgid.link/20250122-apds9160-driver-v5-2-5393be10279a@dimonoff.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-02-08iio: light: veml6030: extend regmap to support cachingJavier Carrasco
The configuration registers are not volatile and are not affected by read operations (i.e. not precious), making them suitable to be cached in order to reduce the number of accesses to the device. Add support for caching (RBTREE type). Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://patch.msgid.link/20250119-veml6030-scale-v2-2-6bfc4062a371@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-02-08iio: light: veml6030: extend regmap to support regfieldsJavier Carrasco
Add support for regfields as well to simplify register operations, taking into account the different fields for the veml6030/veml7700 and veml6035. Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://patch.msgid.link/20250119-veml6030-scale-v2-1-6bfc4062a371@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-02-03iio: hid-sensor-prox: Split difference from multiple channelsRicardo Ribalda
When the driver was originally created, it was decided that sampling_frequency and hysteresis would be shared_per_type instead of shared_by_all (even though it is internally shared by all). Eg: in_proximity_raw in_proximity_sampling_frequency When we introduced support for more channels, we continued with shared_by_type which. Eg: in_proximity0_raw in_proximity1_raw in_proximity_sampling_frequency in_attention_raw in_attention_sampling_frequency Ideally we should change to shared_by_all, but it is not an option, because the current naming has been a stablished ABI by now. Luckily we can use separate instead. That will be more consistent: in_proximity0_raw in_proximity0_sampling_frequency in_proximity1_raw in_proximity1_sampling_frequency in_attention_raw in_attention_sampling_frequency Fixes: 596ef5cf654b ("iio: hid-sensor-prox: Add support for more channels") Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Link: https://patch.msgid.link/20241216-fix-hid-sensor-v2-1-ff8c1959ec4a@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-02-03iio: light: apds9306: fix max_scale_nano valuesJavier Carrasco
The two provided max_scale_nano values must be multiplied by 100 and 10 respectively to achieve nano units. According to the comments: Max scale for apds0306 is 16.326432 → the fractional part is 0.326432, which is 326432000 in NANO. The current value is 3264320. Max scale for apds0306-065 is 14.09721 → the fractional part is 0.09712, which is 97120000 in NANO. The current value is 9712000. Update max_scale_nano initialization to use the right NANO fractional parts. Cc: stable@vger.kernel.org Fixes: 620d1e6c7a3f ("iio: light: Add support for APDS9306 Light Sensor") Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Tested-by: subhajit.ghosh@tweaklogic.com Link: https://patch.msgid.link/20250112-apds9306_nano_vals-v1-1-82fb145d0b16@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-01-16Merge tag 'iio-fixes-for-6.13b' of ↵Greg Kroah-Hartman
ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next Merge from Jonathan: IIO: 2nd set of fixes for the 6.13 cycle. Given timing so late in cycle and that they are all confined to specific drivers, it is fine for these to go upstream early in the 6.14 cycle. hid-sensors - Handle processed attention channel rather than just returning an error. adi,ad3552r - Fix output ranges for ad3541r and ad3542r. - Clear the reset status flag so that we can pick up any resets during operation. adi,ad5791 - Fix a misleading dt binding example where the sense of the interrupt was reversed. adi,ad7606 - Fix some hard coded offsets that should be taking the number of channels on a particular part into account. These were missed due to some racing changes. ams,as73211 - Fix an off by one in optimized path for just reading the colour channels. bosch,bme680 - Fix type of variable passed as pointer, ensuring it works on big endian systems and doesn't expose uninitialized data. * tag 'iio-fixes-for-6.13b' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: iio: dac: ad3552r-hs: clear reset status flag iio: dac: ad3552r-common: fix ad3541/2r ranges iio: chemical: bme680: Fix uninitialized variable in __bme680_read_raw() iio: light: as73211: fix channel handling in only-color triggered buffer dt-bindings: iio: dac: ad5791: ldac gpio is active low iio: hid-sensor-prox: Fix invalid read_raw for attention iio: adc: ad7606: Fix hardcoded offset in the ADC channels
2025-01-13Merge 6.13-rc4 into char-misc-nextGreg Kroah-Hartman
We need the IIO fixes in here as well, and it resolves a merge conflict in: drivers/iio/adc/ti-ads1119.c Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-01-04iio: light: veml3235: fix scale to conform to ABIJavier Carrasco
The current scale is not ABI-compliant as it is just the sensor gain instead of the value that acts as a multiplier to be applied to the raw value (there is no offset). Use the iio-gts helpers to obtain the proper scale values according to the gain and integration time to match the resolution tables from the datasheet. When at it, use 'scale' instead of 'gain' consistently for the get/set functions to avoid misunderstandings. Fixes: c5a23f80c164 ("iio: light: add support for veml3235") Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://patch.msgid.link/20241230-veml3235_scale-v3-2-48a5795e2f64@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-28iio: light: veml3235: extend regmap to add cacheJavier Carrasco
The configuration and ID registers are not volatile and are not affected by read operations (i.e. not precious), making them suitable to be cached in order to reduce the number of accesses to the device. Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://patch.msgid.link/20241224-veml3235_scale-v2-3-2e1286846c77@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-28iio: light: veml3235: fix code styleJavier Carrasco
Trivial fixes to drop double spacings. Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://patch.msgid.link/20241224-veml3235_scale-v2-2-2e1286846c77@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-28iio: light: Use aligned_s64 instead of open coding alignment.Jonathan Cameron
Use this new type to both slightly simplify the code and avoid confusing static analysis tools. Mostly this series is about consistency to avoid this code pattern getting copied into more drivers. Acked-By: Matti Vaittinen <mazziesaccount@gmail.com> #For bu27034, rpr0521 Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20241215182912.481706-9-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-28iio: light: Add support for TI OPT4060 color sensorPer-Daniel Olsson
Add support for Texas Instruments OPT4060 RGBW Color sensor. Signed-off-by: Per-Daniel Olsson <perdaniel.olsson@axis.com> Link: https://patch.msgid.link/20241218104836.2784523-3-perdaniel.olsson@axis.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-20iio: light: as73211: fix channel handling in only-color triggered bufferJavier Carrasco
The channel index is off by one unit if AS73211_SCAN_MASK_ALL is not set (optimized path for color channel readings), and it must be shifted instead of leaving an empty channel for the temperature when it is off. Once the channel index is fixed, the uninitialized channel must be set to zero to avoid pushing uninitialized data. Add available_scan_masks for all channels and only-color channels to let the IIO core demux and repack the enabled channels. Cc: stable@vger.kernel.org Fixes: 403e5586b52e ("iio: light: as73211: New driver") Tested-by: Christian Eggers <ceggers@arri.de> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://patch.msgid.link/20241214-iio_memset_scan_holes-v4-1-260b395b8ed5@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-20iio: hid-sensor-prox: Fix invalid read_raw for attentionRicardo Ribalda
The attention channel is a IIO_CHAN_INFO_PROCESSED, not a IIO_CHAN_INFO_RAW. Modify prox_read_raw() to support it. Fixes: 596ef5cf654b ("iio: hid-sensor-prox: Add support for more channels") Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://patch.msgid.link/20241122-fix-processed-v2-1-b9f606d3b519@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-07iio: light: veml6030: add support for triggered bufferJavier Carrasco
All devices supported by this driver (currently veml6030, veml6035 and veml7700) have two 16-bit channels, and can profit for the same configuration to support data access via triggered buffers. The measurements are stored in two 16-bit consecutive registers (addresses 0x04 and 0x05) as little endian, unsigned data. Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://patch.msgid.link/20241124-veml6030_triggered_buffer-v3-1-565bb6b4b5c8@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-07iio: light: Drop BU27008 and BU27010Matti Vaittinen
The ROHM BU27008 and BU27010 RGB sensors got cancelled. I was informed they never reached mass production stage. Keeping the drivers around is waste of maintenance resources. Drop the drivers. Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/f4d0aa31f29f160a06cba4856a034fa5636d3372.1732819203.git.mazziesaccount@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-07iio: light: cm3232: Reset before reading HW IDCibil Pankiras
According to the datasheet, the chip requires a reset before any data can be read. This commit moves the device identification logic to occur after the reset to ensure proper initialization. Cc: Kevin Tsai <ktsai@capellamicro.com> Signed-off-by: Cibil Pankiras <cibil.pankiras@aerq.com> Link: https://patch.msgid.link/20241114091323.7415-1-cibil.pankiras@aerq.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-07iio: bu27034: simplify using guard(mutex)Matti Vaittinen
The BU27034 uses mutex for protecting the gain / time / scale changes. The clean-up for a few of the functions can be slightly simplified by removing the goto-based error handling/unlocking and by utilizing the guard(mutex) scoped mutex handling instead. Simplify driver by using the scoped mutexes. Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Reviewed-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://patch.msgid.link/4e65a4725c211b166906f70fdb5ba90f2af0f570.1732193263.git.mazziesaccount@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-07iio: light: vcnl4035: fix information leak in triggered bufferJavier Carrasco
The 'buffer' local array is used to push data to userspace from a triggered buffer, but it does not set an initial value for the single data element, which is an u16 aligned to 8 bytes. That leaves at least 4 bytes uninitialized even after writing an integer value with regmap_read(). Initialize the array to zero before using it to avoid pushing uninitialized information to userspace. Cc: stable@vger.kernel.org Fixes: ec90b52c07c0 ("iio: light: vcnl4035: Fix buffer alignment in iio_push_to_buffers_with_timestamp()") Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://patch.msgid.link/20241125-iio_memset_scan_holes-v1-6-0cb6e98d895c@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-07iio: light: bh1745: fix information leak in triggered bufferJavier Carrasco
The 'scan' local struct is used to push data to user space from a triggered buffer, but it does not set values for inactive channels, as it only uses iio_for_each_active_channel() to assign new values. Initialize the struct to zero before using it to avoid pushing uninitialized information to userspace. Cc: stable@vger.kernel.org Fixes: eab35358aae7 ("iio: light: ROHM BH1745 colour sensor") Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://patch.msgid.link/20241125-iio_memset_scan_holes-v1-7-0cb6e98d895c@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-02module: Convert symbol namespace to string literalPeter Zijlstra
Clean up the existing export namespace code along the same lines of commit 33def8498fdd ("treewide: Convert macro and uses of __section(foo) to __section("foo")") and for the same reason, it is not desired for the namespace argument to be a macro expansion itself. Scripted using git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file; do awk -i inplace ' /^#define EXPORT_SYMBOL_NS/ { gsub(/__stringify\(ns\)/, "ns"); print; next; } /^#define MODULE_IMPORT_NS/ { gsub(/__stringify\(ns\)/, "ns"); print; next; } /MODULE_IMPORT_NS/ { $0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g"); } /EXPORT_SYMBOL_NS/ { if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) { if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ && $0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ && $0 !~ /^my/) { getline line; gsub(/[[:space:]]*\\$/, ""); gsub(/[[:space:]]/, "", line); $0 = $0 " " line; } $0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/, "\\1(\\2, \"\\3\")", "g"); } } { print }' $file; done Requested-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://mail.google.com/mail/u/2/#inbox/FMfcgzQXKWgMmjdFwwdsfgxzKpVHWPlc Acked-by: Greg KH <gregkh@linuxfoundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2024-11-09Merge commit '9365f0de4303f82ed4c2db1c39d3de824b249d80' into HEADJonathan Cameron
Merge v6.12-rc6 via char-misc-next to get some fixes needed for next few patches in IIO.
2024-11-05Merge 6.12-rc6 into char-misc-nextGreg Kroah-Hartman
We need the char/misc/iio fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-11-03iio: light: apds9960: remove useless returnJulien Stephan
return 0 statement at the end of apds9960_read_event_config is useless. Remove it. Signed-off-by: Julien Stephan <jstephan@baylibre.com> Link: https://patch.msgid.link/20241031-iio-fix-write-event-config-signature-v2-15-2bcacbb517a2@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-03iio: light: apds9960: convert als_int and pxs_int to boolJulien Stephan
Since the write_event_config callback now uses a bool for the state parameter, update type of als_int and pxs_int to bool. Signed-off-by: Julien Stephan <jstephan@baylibre.com> Link: https://patch.msgid.link/20241031-iio-fix-write-event-config-signature-v2-14-2bcacbb517a2@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-03iio: light: apds9306: simplifies if branch in apds9306_write_event_configJulien Stephan
Simplifies the regmap_wite if branch in apds9306_write_event_config. Signed-off-by: Julien Stephan <jstephan@baylibre.com> Link: https://patch.msgid.link/20241031-iio-fix-write-event-config-signature-v2-13-2bcacbb517a2@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-03iio: light: apds9300: use bool for event stateJulien Stephan
Since the write_event_config callback now uses a bool for the state parameter, update apds9300_set_intr_state accordingly and change intr_en to bool. Also update apds9300_set_power_state and power_state for consistency. Signed-off-by: Julien Stephan <jstephan@baylibre.com> Link: https://patch.msgid.link/20241031-iio-fix-write-event-config-signature-v2-12-2bcacbb517a2@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-03iio: fix write_event_config signatureJulien Stephan
write_event_config callback use an int for state, but it is actually a boolean. iio_ev_state_store is actually using kstrtobool to check user input, then gives the converted boolean value to write_event_config. Fix signature and update all iio drivers to use the new signature. This patch has been partially written using coccinelle with the following script: $ cat iio-bool.cocci // Options: --all-includes virtual patch @c1@ identifier iioinfo; identifier wecfunc; @@ static const struct iio_info iioinfo = { ..., .write_event_config = ( wecfunc | &wecfunc ), ..., }; @@ identifier c1.wecfunc; identifier indio_dev, chan, type, dir, state; @@ int wecfunc(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, -int +bool state) { ... } make coccicheck MODE=patch COCCI=iio-bool.cocci M=drivers/iio Unfortunately, this script didn't match all files: * all write_event_config callbacks using iio_device_claim_direct_scoped were not detected and not patched. * all files that do not assign and declare the write_event_config callback in the same file. iio.h was also manually updated. The patch was build tested using allmodconfig config. cc: Julia Lawall <julia.lawall@inria.fr> Signed-off-by: Julien Stephan <jstephan@baylibre.com> Link: https://patch.msgid.link/20241031-iio-fix-write-event-config-signature-v2-7-2bcacbb517a2@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-03iio: light: adux1020: write_event_config: use local variable for interrupt valueJulien Stephan
state parameter is currently an int, but it is actually a boolean. iio_ev_state_store is actually using kstrtobool to check user input, then gives the converted boolean value to write_event_config. The code in adux1020_write_event_config re-uses state parameter to store an integer value. To prepare for updating the write_event_config signature to use a boolean for state, introduce a new local int variable. Signed-off-by: Julien Stephan <jstephan@baylibre.com> Link: https://patch.msgid.link/20241031-iio-fix-write-event-config-signature-v2-6-2bcacbb517a2@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-03iio: light: tsl2772: simplify code in write_event_config callbackJulien Stephan
iio_ev_state_store is actually using kstrtobool to check user input, then gives the converted boolean value to the write_event_config callback. Remove useless code in write_event_config callback. Signed-off-by: Julien Stephan <jstephan@baylibre.com> Link: https://patch.msgid.link/20241031-iio-fix-write-event-config-signature-v2-3-2bcacbb517a2@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-03iio: light: ltr390: simplify code in write_event_config callbackJulien Stephan
iio_ev_state_store is actually using kstrtobool to check user input, then gives the converted boolean value to the write_event_config callback. Remove useless code in write_event_config callback. Signed-off-by: Julien Stephan <jstephan@baylibre.com> Link: https://patch.msgid.link/20241031-iio-fix-write-event-config-signature-v2-1-2bcacbb517a2@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-03iio: hid-sensor-prox: Add support for more channelsRicardo Ribalda
Egis620 supports 3 channels: presense, proximity and attention. Modify the driver so it can read those channels as well. Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Link: https://patch.msgid.link/20241101-hpd-v3-5-e9c80b7c7164@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-03iio: hid-sensors-prox: Make proximity channel indexedRicardo Ribalda
We are going to introduce more proximity channels. Make proximity a indexed channel now, in a simple patch, so the change can be easily bisected if there are any issues. Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Link: https://patch.msgid.link/20241101-hpd-v3-4-e9c80b7c7164@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-03iio: hid-sensors-prox: Factor-in hid_sensor_push_dataRicardo Ribalda
The function is only called from one place and it is a one-liner. Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Link: https://patch.msgid.link/20241101-hpd-v3-2-e9c80b7c7164@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-03iio: light: veml6070: add support for integration timeJavier Carrasco
The integration time of the veml6070 depends on an external resistor (called Rset in the datasheet) and the value configured in the IT field of the command register, whose supported values are 1/2x, 1x, 2x and 4x. Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://patch.msgid.link/20241031-veml6070-integration-time-v4-2-c66da6788256@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-01iio: light: add support for veml3235Javier Carrasco
The Vishay veml3235 is a low-power ambient light sensor with I2C interface. It provides a minimum detectable intensity of 0.0021 lx/cnt, configurable integration time and gain, and an additional white channel to distinguish between different light sources. Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://patch.msgid.link/20241023-veml3235-v3-2-8490f2622f9a@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-01iio: light: stk3310: simplify code in write_event_config callbackJulien Stephan
iio_ev_state_store is actually using kstrtobool to check user input, then gives the converted boolean value to the write_event_config callback. Remove useless code in write_event_config callback. Signed-off-by: Julien Stephan <jstephan@baylibre.com> Link: https://patch.msgid.link/20241024-iio-fix-write-event-config-signature-v1-6-7d29e5a31b00@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-01iio: imu: inv_mpu6050: simplify code in write_event_config callbackJulien Stephan
iio_ev_state_store is actually using kstrtobool to check user input, then gives the converted boolean value to the write_event_config callback. Remove useless code in write_event_config callback. Signed-off-by: Julien Stephan <jstephan@baylibre.com> Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com> Link: https://patch.msgid.link/20241024-iio-fix-write-event-config-signature-v1-5-7d29e5a31b00@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-01iio: light: veml6030: simplify code in write_event_config callbackJulien Stephan
iio_ev_state_store is actually using kstrtobool to check user input, then gives the converted boolean value to the write_event_config callback. Remove useless code in write_event_config callback. Signed-off-by: Julien Stephan <jstephan@baylibre.com> Link: https://patch.msgid.link/20241024-iio-fix-write-event-config-signature-v1-4-7d29e5a31b00@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>