summaryrefslogtreecommitdiff
path: root/drivers/iio/common
AgeCommit message (Collapse)Author
2025-06-08treewide, timers: Rename from_timer() to timer_container_of()Ingo Molnar
Move this API to the canonical timer_*() namespace. [ tglx: Redone against pre rc1 ] Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/all/aB2X0jCKQO56WdMt@gmail.com
2025-05-22Merge tag 'iio-for-6.16a-take2' 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 6.16 - take 2 Note - last minute rebase was to drop a typo patch that I'd accidentally picked up (in the microblaze arch Kconfig) Take 2 is due to that rebase messing up some fixes tags that were referring to patches after that point. There is a known merge conflict due to changes in neighbouring lines. Stephen's resolution in linux-next is: https://lore.kernel.org/linux-next/20250506155728.65605bae@canb.auug.org.au/ Added 3 named IIO reviewers to MAINTAINERS. This is a reflection of those who have been doing much of this work for some time. Lars-Peter is removed from the entry having moved on to other topics. Thanks Nuno, David and Andy for stepping up and Lars-Peter for all your hard work in the past! Includes the usual mix of new device support, features and general cleanup. This time we also have some tree wide changes. - Rip out the iio_device_claim_direct_scoped() as it proved hard to work with. This series includes quite a few related cleanups such as use of guard or factoring code out to allow direct returns. - Switch from iio_device_claim/release_direct_mode() to new iio_device_claim/release_direct() which is structured so that sparse can warn on failed releases. There were a few false positives but those were mostly in code that benefited from being cleaned up as part of this process. - Introduce iio_push_to_buffers_with_ts() to replace the _timestamp() version over time. This version takes the size of the supplied buffer which the core checks is at least as big as expected by calculation from channel descriptions of those channels enabled. Use this in an initial set of drivers. - Add macros for IIO_DECLARE_BUFFER_WITH_TS() and IIO_DECLARE_DMA_BUFFER_WITH_TS() to avoid lots of fiddly code to ensure correctly aligned buffers for timestamps being added onto the end of channel data. New device support ------------------ adi,ad3530r - New driver for AD3530, AD3530R, AD3531 and AD3531R DACs with programmable gain controls. R variants have internal references. adi,ad7476 - Add support (dt compatible only) for the Rohm BU79100G ADC which is fully compatible with the ti,ads7866. adi,ad7606 - Support ad7606c-16 and ad7606c-18 devices. Includes switch to dynamic channel information allocation. adi,ad7380 - Add support for the AD7389-4 dfrobot,sen0322 - New driver for this oxygen sensor. mediatek,mt2701-auxadc - Add binding for MT6893 which is fully compatible with already supported MT8173. meson-saradc - Support the GXLX SoCs. Mostly this is a workaround for some unrelated clock control bits found in the ADC register map. nuvoton,nct7201 - New driver for NCT7201 and NCT7202 I2C ADCs. rohm,bd79124 - New driver for this 12-bit, 8-channel SAR ADC. - Switch to new set_rv etc gpio callbacks that were added in 6.15. rohm,bd79703 - Add support for BD79700, BD79701 and BD79702 DACs that have subsets of functionality of the already supported bd79703. Included making this driver suitable for support device variants. st,stm32-lptimer - Add support for stm32pm25 to this trigger. Features -------- Beyond IIO - Property iterator for named children. core - Enable writes for 64 bit integers used for standard IIO ABI elements. Previously these could be read only. - Helper library that should avoid code duplication for simpler ADC bindings that have a child node per channel. - Enforce that IIO_DMA_MINALIGN is always at least 8 (almost always true and simplifies code on all significant architectures) core/backend - Add support to control source of data - useful when the HDL includes things like generated ramps for testing purposes. Enable this for adi-axi-dac adi,ad3552-hs - Add debugfs related callbacks to allow debug access to register contents. adi,ad4000 - Support SPI offload with appropriate FPGA firmware along with improving documentation. adi,ad7293 - Add support for external reference voltage. adi,ad7606 - Support SPI offload. adi,ad7768-1 - Support reset GPIO. adi,admv8818 - Support filter frequencies beyond 2^32. adi,adxl345 - Add single and double tap events. hid-sensor-prox - Support 16-bit report sizes as seen on some Intel platforms. invensense,icm42600 - Enable use of named interrupts to avoid problems with some wiring choices. Get the interrupt by name, but fallback to previous assumption on the first being INT1 if no names are supplied. microchip,mcp3911 - Add reset gpio support. rohm,bh7150 - Add reset gpio support. st,stm32 - Add support to control oversampling. ti,adc128s052 - Add support for ROHM BD79104 which is early compatible with the TI parts already supported by this driver. Includes some general driver cleanup and a separate dt binding. - Simplify reference voltage handling by assuming it is fixed after enabling the supply. winsen,mhz19b - New driver for this C02 sensor. Cleanup and minor fixes ----------------------- dt-bindings - Correct indentation and style for DTS examples. - Use unevalutateProperties for SPI devices instead of additionalProperties to allow generic SPI properties from spi-peripheral-props.yaml ABI Docs - Add missing docs for sampling_frequency when it applies only to events. Treewide - Various minor tweaks, comment fixes and similar. - Sort TI ADCs in Kconfig that had gotten out of order. - Switch various drives that provide GPIO chip functionality to the new callbacks with return values. - Standardize on { } formatting for all array sentinels. - Make use of aligned_s64 in a few places to replace either wrong types or manually defined equivalents. - Drop places where spi bits_per_word is set to 8 because that is the default anyway. adi,ad_sigma_delta library - Avoid a potential use of uninitialized data if reg_size has a value that is not supported (no drivers hit this but it is reasonable hardening) adi,ad4030 - Add error checking for scan types and no longer store it in state. - Rework code to reduce duplication. - Move setting the mode from buffer preenable() to update_scan_mode(), better matching expected semantics of the two different callbacks. - Improve data marshalling comments. adi,ad4695 - Use u16 for buffer elements as oversampling is not yet supported except with SPI offload (which doesn't use this path). adi,ad5592r - Clean up destruction of mutexes. - Use lock guards to simplify code (later patch fixes a missed unlock) adi,ad5933 - Correct some incorrect settling times. adi,ad7091 - Deduplicate handling of writable vs volatile registers as they are the inverse of each other for this device. adi,ad7124 - Fix 3db Filter frequency. - Remove ability to directly write the filter frequency (which was broken) - Register naming improvements. adi,ad7606 - Add a missing return value check. - Fill in max sampling rates for all chips. - Use devm_mutex_init() - Fix up some kernel-doc formatting issues. - Remove some camel case that snuck in. - Drop setting address field in channels as easily established from other fields. - Drop unnecessary parameter to ad76060_scale_setup_cb_t. adi,ad7768-1 - Convert to regmap. - Factor out buffer allocation. - Tidy up headers. adi,ad7944 - Stop setting bits_per_word in SPI xfers with no data. adi,ad9832 - Add of_device_id table rather than just relying on fallbacks. - Use FIELD_PREP() to set values of fields. adi,admv1013 - Cleanup a pointless ternary. adi,admv8818 - Fix up LPF Band 5 frequency which was slightly wrong. - Fix an integer overflow. - Fix range calculation adi,adt7316 - Replace irqd_get_trigger_type(irq_get_irq_data()) with simpler irq_get_trigger_type() adi,adxl345 - Use regmap cache instead of various state variables that were there to reduce bus accesses. - Make regmap return value checking consistent across all call sites. adi,axi-dac - Add a check on number of channels (0 to 15 valid) allwinner,sun20i - Use new adc-helpers to replace local parsing code for channel nodes. bosch,bmp290 - Move to local variables for sensor data marshalling removing the need for a messy definition that has to work for all supported parts. Follow up fix adds a missing initialization. dynaimage,al3010 and dynaimage,al3320a - Various minor cleanup to bring these drivers inline with reviewed feedback given on a new driver. - Fix an error path in which power down is not called when it should be. - Switch to regmap. google,cros_ec - Fix up a flexible array in middle of structure warning. - Flush fifo when changing the timeout to avoid potential long wait for samples. hid-sensor-rotation - Remove an __aligned(16) marking that doesn't seem to be justified. kionix,kxcjk-1013 - Deduplicate code for setting up interrupts. microchip,mcp3911 - Fix handling of conversion results register which differs across supported devices. idt,zopt2201 - Avoid duplicating register lists as all volatile registers are the inverse of writeable registers on this device. renesas,rzg2l - Use new adc-helpers to replace local parsing code for channel nodes. ti,ads1298 - Fix a missing Kconfig dependency. * tag 'iio-for-6.16a-take2' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (260 commits) dt-bindings: iio: adc: Add ROHM BD79100G iio: adc: add support for Nuvoton NCT7201 dt-bindings: iio: adc: add NCT7201 ADCs iio: chemical: Add driver for SEN0322 dt-bindings: trivial-devices: Document SEN0322 iio: adc: ad7768-1: reorganize driver headers iio: bmp280: zero-init buffer iio: ssp_sensors: optimalize -> optimize HID: sensor-hub: Fix typo and improve documentation iio: admv1013: replace redundant ternary operator with just len iio: chemical: mhz19b: Fix error code in probe() iio: adc: at91-sama5d2: use IIO_DECLARE_BUFFER_WITH_TS iio: accel: sca3300: use IIO_DECLARE_BUFFER_WITH_TS iio: adc: ad7380: use IIO_DECLARE_DMA_BUFFER_WITH_TS iio: adc: ad4695: rename AD4695_MAX_VIN_CHANNELS iio: adc: ad4695: use IIO_DECLARE_DMA_BUFFER_WITH_TS iio: introduce IIO_DECLARE_BUFFER_WITH_TS macros iio: make IIO_DMA_MINALIGN minimum of 8 bytes iio: pressure: zpa2326_spi: remove bits_per_word = 8 iio: pressure: ms5611_spi: remove bits_per_word = 8 ...
2025-05-21iio: ssp_sensors: optimalize -> optimizeAhelenia Ziemiańska
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Link: https://patch.msgid.link/5a64aa3034c6127d7587de9b7045a12892c01ee5.1746558529.git.nabijaczleweli@nabijaczleweli.xyz Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-05-21iio: cros_ec_sensors: Flush when changing the FIFO timeoutGwendal Grignou
|hwfifo_timeout| is used by the EC firmware only when new samples are available. When the timeout changes, espcially when the new timeout is shorter than the current one, send the samples waiting in the FIFO to the host. Inline the call to transmit |hwfifo_timeout| value to the firmware. Now flush when a sensor is suspended (ODR set to 0) as well. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Link: https://patch.msgid.link/20250423220506.2061021-1-gwendal@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-04-22iio: normalize array sentinel styleDavid Lechner
Use `\t(\{ ?\},|\{\}|\{\s*/\*.*\*/\s*\},?)$` regex to find and replace the array sentinel in all IIO drivers to the same style. For some time, we've been trying to consistently use `{ }` (no trailing comma, no comment, one space between braces) for array sentinels in the IIO subsystem. Still nearly 50% of existing code uses a different style. To save reviewers from having to request this trivial change as frequently, let's normalize the style in all existing IIO drivers. At least when code is copy/pasted to new drivers, the style will be consistent. Signed-off-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://patch.msgid.link/20250411-iio-sentinel-normalization-v1-1-d293de3e3d93@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-04-22iio: common: st_sensors: Switch to sparse friendly ↵Jonathan Cameron
iio_device_claim/release_direct() These new functions allow sparse to find failures to release direct mode reducing chances of bugs over the claim_direct_mode() functions that are deprecated. Reviewed-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com> Link: https://patch.msgid.link/20250331121317.1694135-8-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-04-22iio: common: scmi: Switch to sparse friendly iio_device_claim/release_direct()Jonathan Cameron
These new functions allow sparse to find failures to release direct mode reducing chances of bugs over the claim_direct_mode() functions that are deprecated. Cc: Jyoti Bhayana <jbhayana@google.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com> Link: https://patch.msgid.link/20250331121317.1694135-7-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-04-22iio: cros_ec: Avoid -Wflex-array-member-not-at-end warningGustavo A. R. Silva
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are getting ready to enable it, globally. Use the `DEFINE_RAW_FLEX()` helper for an on-stack definition of a flexible structure where the size of the flexible-array member is known at compile-time, and refactor the rest of the code, accordingly. So, with these changes, fix the following warning: drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c:39:40: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://patch.msgid.link/Z9lE6IVDeC5lnChN@kspp 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-05treewide: Switch/rename to timer_delete[_sync]()Thomas Gleixner
timer_delete[_sync]() replaces del_timer[_sync](). Convert the whole tree over and remove the historical wrapper inlines. Conversion was done with coccinelle plus manual fixups where necessary. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@kernel.org>
2025-02-08iio: cros_ec: Trace EC sensors commandGwendal Grignou
For debugging, add tracing for EC_CMD_MOTION_SENSE_CMD command: - decode the name of the subcommand - provide internal information for the most common sub-commands: setting range, frequency, EC probing frequency, ... - display return status. When enabled, the tracing output is similar to: /sys/kernel/debug/tracing # echo 1 > events/cros_ec/enable ; echo 1 > tracing_on ; cat trace_pipe | grep MOTIONSENSE_CMD_SENSOR_ODR SensorDeviceImp-814 [003] ..... 686.176782: cros_ec_motion_host_cmd: MOTIONSENSE_CMD_SENSOR_ODR, id: 1, data: 200000, result: 4, return: 12500 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://patch.msgid.link/20250121232007.1020666-1-gwendal@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-28iio: common: ssp_sensors: drop conditional optimization for simplicityVasileios Amoiridis
Drop conditional in favor of always calculating the timestamp value. This simplifies the code and allows to drop usage of internal private variable "scan_timestamp" of the struct iio_dev. Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com> Link: https://patch.msgid.link/20241214191421.94172-4-vassilisamir@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-07iio: invensense: Prevent possible integer overflow while multiplicationKaran Sanghavi
Typecast a variable to int64_t for 64-bit arithmetic multiplication. Signed-off-by: Karan Sanghavi <karansanghvi98@gmail.com> Link: https://scan7.scan.coverity.com/#/project-view/51946/11354?selectedIssue=1586045 Link: https://patch.msgid.link/20241103-coverity1586045integeroverflow-v1-1-43ea37a3f3cd@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-08Merge tag 'iio-fixes-for-6.12c' of ↵Greg Kroah-Hartman
ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next Jonathan writes: IIO: 3rd set of fixes for the 6.12 cycle Usual mixed bag of new issues from this cycle and ancient bugs recently noticed. core - Fix wrong fwnode handle if __fwnode_iio_channel_get_by_name() looks at parents of the provider node. core,backend - Fix a wrong pointer error check. gts library - Fix plausible corner case where the value returned was not set. - Avoid near infinite loop if the size of the table is 0. (neither are an issue for current drivers). adi,ad4000 - Fix reading of unsigned channels that were returning garbage. adi,ad7780 - Prevent a division by zero. adi,ad7923 - Fix buffer overflows in arrays that were not resized when devices with more channels were added to the driver. adi,adxl380 - Check only for negative error codes rather than including the positive channel read values in an error check. invense,common - Fix an issue where changing the sampling rate to another value and back again whilst the FIFO was off would not update things correctly. kionix,kx022a - Fix failure to sign extend value read from device. * tag 'iio-fixes-for-6.12c' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: iio: Fix fwnode_handle in __fwnode_iio_channel_get_by_name() iio: accel: adxl380: fix raw sample read iio: accel: kx022a: Fix raw read format iio: gts: fix infinite loop for gain_to_scaletables() iio: gts: Fix uninitialized symbol 'ret' iio: adc: ad4000: fix reading unsigned data ad7780: fix division by zero in ad7780_write_raw() iio: adc: ad7923: Fix buffer overflow for tx_buf and ring_xfer iio: backend: fix wrong pointer passed to IS_ERR() iio: invensense: fix multiple odr switch when FIFO is off
2024-10-29iio: invensense: fix multiple odr switch when FIFO is offJean-Baptiste Maneyrol
When multiple ODR switch happens during FIFO off, the change could not be taken into account if you get back to previous FIFO on value. For example, if you run sensor buffer at 50Hz, stop, change to 200Hz, then back to 50Hz and restart buffer, data will be timestamped at 200Hz. This due to testing against mult and not new_mult. To prevent this, let's just run apply_odr automatically when FIFO is off. It will also simplify driver code. Update inv_mpu6050 and inv_icm42600 to delete now useless apply_odr. Fixes: 95444b9eeb8c ("iio: invensense: fix odr switching to same value") Cc: stable@vger.kernel.org Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com> Link: https://patch.msgid.link/20241021-invn-inv-sensors-timestamp-fix-switch-fifo-off-v2-1-39ffd43edcc4@tdk.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-10-21Merge 6.12-rc4 into char-misc-nextGreg Kroah-Hartman
We need the iio fixes from 6.12-rc4 in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-10-13Merge tag 'iio-fixes-for-6.12a' of ↵Greg Kroah-Hartman
ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-linus Jonathan writes: IIO: 1st set of fixes for the 6.12 cycle. Most of this pull request is the result of Javier Carrasco doing a careful audit for missing Kconfig dependencies that luck has meant the random builds have never hit. The rest is the usual mix of old bugs that have surfaced and some fallout from the recent merge window. adi,ad5686 - Fix binding duplication of compatible strings. bosch,bma400 - Fix an uninitialized variable in the event tap handling. bosch,bmi323 - Fix several issues in the register saving and restore on suspend/resume sensiron,spd500 - Fix missing CRC8 dependency ti,op3001 - Fix a missing full-scale range value (values above this point were all reported wrongly) vishay,veml6030 - Fix a segmentation fault due to some type confusion. - Fix wrong ambient light sensor resolution. * tag 'iio-fixes-for-6.12a' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (34 commits) iio: frequency: admv4420: fix missing select REMAP_SPI in Kconfig iio: frequency: {admv4420,adrf6780}: format Kconfig entries iio: adc: ad4695: Add missing Kconfig select iio: adc: ti-ads8688: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: hid-sensors: Fix an error handling path in _hid_sensor_set_report_latency() iioc: dac: ltc2664: Fix span variable usage in ltc2664_channel_config() iio: dac: stm32-dac-core: add missing select REGMAP_MMIO in Kconfig iio: dac: ltc1660: add missing select REGMAP_SPI in Kconfig iio: dac: ad5770r: add missing select REGMAP_SPI in Kconfig iio: amplifiers: ada4250: add missing select REGMAP_SPI in Kconfig iio: frequency: adf4377: add missing select REMAP_SPI in Kconfig iio: resolver: ad2s1210: add missing select (TRIGGERED_)BUFFER in Kconfig iio: resolver: ad2s1210 add missing select REGMAP in Kconfig iio: proximity: mb1232: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: pressure: bm1390: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: magnetometer: af8133j: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: light: bu27008: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: chemical: ens160: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: dac: ad5766: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: dac: ad3552r: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig ...
2024-10-12Merge tag 'v6.12-rc2' into test2Jonathan Cameron
Linux 6.12-rc2 Resolved movement of asm/unaligned.h to linux/unaligned.h
2024-10-10iio: hid-sensors: Fix an error handling path in _hid_sensor_set_report_latency()Christophe JAILLET
If hid_sensor_set_report_latency() fails, the error code should be returned instead of a value likely to be interpreted as 'success'. Fixes: 138bc7969c24 ("iio: hid-sensor-hub: Implement batch mode") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://patch.msgid.link/c50640665f091a04086e5092cf50f73f2055107a.1727980825.git.christophe.jaillet@wanadoo.fr Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-10-02move asm/unaligned.h to linux/unaligned.hAl Viro
asm/unaligned.h is always an include of asm-generic/unaligned.h; might as well move that thing to linux/unaligned.h and include that - there's nothing arch-specific in that header. auto-generated by the following: for i in `git grep -l -w asm/unaligned.h`; do sed -i -e "s/asm\/unaligned.h/linux\/unaligned.h/" $i done for i in `git grep -l -w asm-generic/unaligned.h`; do sed -i -e "s/asm-generic\/unaligned.h/linux\/unaligned.h/" $i done git mv include/asm-generic/unaligned.h include/linux/unaligned.h git mv tools/include/asm-generic/unaligned.h tools/include/linux/unaligned.h sed -i -e "/unaligned.h/d" include/asm-generic/Kbuild sed -i -e "s/__ASM_GENERIC/__LINUX/" include/linux/unaligned.h tools/include/linux/unaligned.h
2024-09-30iio: common: st: use irq_get_trigger_type()Jonathan Cameron
Use irq_get_trigger_type() to replace getting the irq data then the type in two steps. Tweak ordering to put the comment before we get the trigger type. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20240901135950.797396-5-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-08-03iio: common: cros_ec_sensors_core: use new '.masklength' accessorsNuno Sa
Make use of iio_get_masklength) and iio_for_each_active_channel() to access '.masklength' so it can be annotated as __private when there are no more direct users of it. Signed-off-by: Nuno Sa <nuno.sa@analog.com> Link: https://patch.msgid.link/20240726-dev-iio-masklength-private3-v1-21-82913fc0fb87@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-08-03iio: common: scmi_iio: Remove unnecessary u64 type castThorsten Blum
The variable uHz already has the type u64 and casting it to u64 is unnecessary. Remove the redundant type cast. Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com> Link: https://patch.msgid.link/20240711134502.168484-1-thorsten.blum@toblux.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-06-30iio: common: scmi_iio: convert to dev_err_probe()Nuno Sa
Make use of dev_err_probe() and dev_err_ptr_probe() to simplify error paths during probe. Signed-off-by: Nuno Sa <nuno.sa@analog.com> Link: https://patch.msgid.link/20240606-dev-add_dev_errp_probe-v3-4-51bb229edd79@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-06-29iio: st_sensors: relax WhoAmI check in st_sensors_verify_id()Kaustabh Chakraborty
Hard matching against the WhoAmI values isn't ideal for using devices which are compatible with existing ones. Instead of raising an error, issue a warning instead, thus allowing the driver to continue probing. Suggested-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org> Link: https://patch.msgid.link/20240625082800.62305-1-kauschluss@disroot.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-05-27iio: invensense: fix odr switching to same valueJean-Baptiste Maneyrol
ODR switching happens in 2 steps, update to store the new value and then apply when the ODR change flag is received in the data. When switching to the same ODR value, the ODR change flag is never happening, and frequency switching is blocked waiting for the never coming apply. Fix the issue by preventing update to happen when switching to same ODR value. Fixes: 0ecc363ccea7 ("iio: make invensense timestamp module generic") Cc: stable@vger.kernel.org Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com> Link: https://lore.kernel.org/r/20240524124851.567485-1-inv.git-commit@tdk.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-05-03iio: invensense: fix timestamp glitches when switching frequencyJean-Baptiste Maneyrol
When a sensor is running and there is a FIFO frequency change due to another sensor turned on/off, there are glitches on timestamp. Fix that by using only interrupt timestamp when there is the corresponding sensor data in the FIFO. Delete FIFO period handling and simplify internal functions. Update integration inside inv_mpu6050 and inv_icm42600 drivers. Fixes: 0ecc363ccea7 ("iio: make invensense timestamp module generic") Cc: Stable@vger.kernel.org Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com> Link: https://lore.kernel.org/r/20240426094835.138389-1-inv.git-commit@tdk.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-05-01iio: invensense: fix interrupt timestamp alignmentJean-Baptiste Maneyrol
Restrict interrupt timestamp alignment for not overflowing max/min period thresholds. Fixes: 0ecc363ccea7 ("iio: make invensense timestamp module generic") Cc: stable@vger.kernel.org Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com> Link: https://lore.kernel.org/r/20240426135814.141837-1-inv.git-commit@tdk.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-01-23iio: invensense: remove redundant initialization of variable periodColin Ian King
The variable period is being initialized with a value that is never read, it is being re-assigned a new value later on before it is read. The initialization is redundant and can be removed. Cleans up clang scan build warning: Value stored to 'period' during its initialization is never read [deadcode.DeadStores] Signed-off-by: Colin Ian King <colin.i.king@gmail.com> Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com> Link: https://lore.kernel.org/r/20240106153202.54861-1-colin.i.king@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-11-16iio: common: ms_sensors: ms_sensors_i2c: fix humidity conversion time tableJavier Carrasco
The HTU21 offers 4 sampling frequencies: 20, 40, 70 and 120, which are associated to an index that is used to select the right measurement resolution and its corresponding measurement time. The current implementation selects the measurement resolution and the temperature measurement time properly, but it does not select the right humidity measurement time in all cases. In summary, the 40 and 70 humidity measurement times are swapped. The reason for that is probably the unusual coding for the measurement resolution. According to the datasheet, the bits [7,0] of the "user register" are used as follows to select the bit resolution: -------------------------------------------------- | Bit 7 | Bit 0 | RH | Temp | Trh (us) | Tt (us) | -------------------------------------------------- | 0 | 0 | 12 | 14 | 16000 | 50000 | -------------------------------------------------- | 0 | 1 | 8 | 12 | 3000 | 13000 | -------------------------------------------------- | 1 | 0 | 10 | 13 | 5000 | 25000 | -------------------------------------------------- | 1 | 1 | 11 | 11 | 8000 | 7000 | -------------------------------------------------- *This table is available in the official datasheet, page 13/21. I have just appended the times provided in the humidity/temperature tables, pages 3/21, 5/21. Note that always a pair of resolutions is selected. The sampling frequencies [20, 40, 70, 120] are assigned to a linear index [0..3] which is then coded as follows [1]: Index [7,0] -------------- idx 0 0,0 idx 1 1,0 idx 2 0,1 idx 3 1,1 That is done that way because the temperature measurements are being used as the reference for the sampling frequency (the frequencies and the temperature measurement times are correlated), so increasing the index always reduces the temperature measurement time and its resolution. Therefore, the temperature measurement time array is as simple as [50000, 25000, 13000, 7000] On the other hand, the humidity resolution cannot follow the same pattern because of the way it is coded in the "user register", where both resolutions are selected at the same time. The humidity measurement time array is the following: [16000, 3000, 5000, 8000], which defines the following assignments: Index [7,0] Trh ----------------------- idx 0 0,0 16000 -> right, [0,0] selects 12 bits (Trh = 16000) idx 1 1,0 3000 -> wrong! [1,0] selects 10 bits (Trh = 5000) idx 2 0,1 5000 -> wrong! [0,1] selects 8 bits (Trh = 3000) idx 3 1,1 8000 -> right, [1,1] selects 11 bits (Trh = 8000) The times have been ordered as if idx = 1 -> [0,1] and idx = 2 -> [1,0], which is not the case for the reason explained above. So a simple modification is required to obtain the right humidity measurement time array, swapping the values in the positions 1 and 2. The right table should be the following: [16000, 5000, 3000, 8000] Fix the humidity measurement time array with the right idex/value coding. [1] The actual code that makes this coding and assigns it to the current value of the "user register" is the following: config_reg &= 0x7E; config_reg |= ((i & 1) << 7) + ((i & 2) >> 1); Fixes: d574a87cc311 ("Add meas-spec sensors common part") Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://lore.kernel.org/r/20231026-topic-htu21_conversion_time-v1-1-bd257dc44209@gmail.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-10-05iio: cros_ec: fix an use-after-free in cros_ec_sensors_push_data()Tzung-Bi Shih
cros_ec_sensors_push_data() reads `indio_dev->active_scan_mask` and calls iio_push_to_buffers_with_timestamp() without making sure the `indio_dev` stays in buffer mode. There is a race if `indio_dev` exits buffer mode right before cros_ec_sensors_push_data() accesses them. An use-after-free on `indio_dev->active_scan_mask` was observed. The call trace: [...] _find_next_bit cros_ec_sensors_push_data cros_ec_sensorhub_event blocking_notifier_call_chain cros_ec_irq_thread It was caused by a race condition: one thread just freed `active_scan_mask` at [1]; while another thread tried to access the memory at [2]. Fix it by calling iio_device_claim_buffer_mode() to ensure the `indio_dev` can't exit buffer mode during cros_ec_sensors_push_data(). [1]: https://elixir.bootlin.com/linux/v6.5/source/drivers/iio/industrialio-buffer.c#L1189 [2]: https://elixir.bootlin.com/linux/v6.5/source/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c#L198 Cc: stable@vger.kernel.org Fixes: aa984f1ba4a4 ("iio: cros_ec: Register to cros_ec_sensorhub when EC supports FIFO") Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Link: https://lore.kernel.org/r/20230829030622.1571852-1-tzungbi@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-08-13Merge 6.5-rc6 into char-misc-nextGreg Kroah-Hartman
We need the char/misc fixes in here as well to build on top of. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-07-29iio: cros_ec: Fix the allocation size for cros_ec_commandYiyuan Guo
The struct cros_ec_command contains several integer fields and a trailing array. An allocation size neglecting the integer fields can lead to buffer overrun. Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org> Signed-off-by: Yiyuan Guo <yguoaz@gmail.com> Fixes: 974e6f02e27e ("iio: cros_ec_sensors_core: Add common functions for the ChromeOS EC Sensor Hub.") Link: https://lore.kernel.org/r/20230630143719.1513906-1-yguoaz@gmail.com Cc: <Stable@vger.kerenl.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20iio: make invensense timestamp module genericJean-Baptiste Maneyrol
Rename common module to inv_sensors_timestamp, add configuration at init (chip internal clock, acceptable jitter, ...) and update inv_icm42600 driver integration. Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20230606162147.79667-4-inv.git-commit@tdk.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20iio: move inv_icm42600 timestamp module in commonJean-Baptiste Maneyrol
Create new inv_sensors common modules and move inv_icm42600 timestamp module inside. This module will be used by IMUs and also in the future by other chips. Modify inv_icm42600 driver to use timestamp module and do some headers cleanup. Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20230606162147.79667-3-inv.git-commit@tdk.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-03-11iio: Rename iio_trigger_poll_chained and add kernel-docMehdi Djait
Rename the function to iio_trigger_poll_nested. Add kernel-doc with a note on the context where the function is expected to be called. Signed-off-by: Mehdi Djait <mehdi.djait.k@gmail.com> Link: https://lore.kernel.org/r/841b533cba28ca25a8e87280c44e45979166e8e2.1677761379.git.mehdi.djait.k@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-12-28iio: common: scmi_iio: use sysfs_emit() to instead of scnprintf()ye xingchen
Replace the open-code with sysfs_emit() to simplify the code. Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn> Link: https://lore.kernel.org/r/202212011156314630626@zte.com.cn Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-11-23iio: Don't silently expect attribute typesMatti Vaittinen
The iio_triggered_buffer_setup_ext() and the devm_iio_kfifo_buffer_setup_ext() were changed by commit 15097c7a1adc ("iio: buffer: wrap all buffer attributes into iio_dev_attr") to silently expect that all attributes given in buffer_attrs array are device-attributes. This expectation was not forced by the API - and some drivers did register attributes created by IIO_CONST_ATTR(). When using IIO_CONST_ATTRs the added attribute "wrapping" does not copy the pointer to stored string constant and when the sysfs file is read the kernel will access to invalid location. Change the function signatures to expect an array of iio_dev_attrs to avoid similar errors in the future. Merge conflict resolved whilst applying due to patch crossing with two new drivers (kx022a accelerometer and ad4130 ADC). Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Tested-by: Claudiu Beznea <claudiu.beznea@microchip.com> Link: https://lore.kernel.org/r/63f54787a684eb1232f1c5d275a09c786987fe4a.1664782676.git.mazziesaccount@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-11-23iio: st_sensors: core and lsm9ds0 switch to devm_regulator_bulk_get_enable()Jonathan Cameron
These drivers only turns the power on at probe and off via a custom devm_add_action_or_reset() callback. The two regulators were handled separately so also switch to bulk registration. The new devm_regulator_bulk_get_enable() replaces all this boilerplate code. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Linus Walleij <linus.walleij@linaro.org> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20221016163409.320197-8-jic23@kernel.org
2022-11-23iio: common: scmi_iio: do not use internal iio_dev lockNuno Sá
The iio_device lock is only meant for internal use. Hence define a device local lock to protect against concurrent accesses. While at it, properly include "mutex.h" for mutex related APIs. Signed-off-by: Nuno Sá <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20221004134909.1692021-12-nuno.sa@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-08-28iio: common: scmi_sensors: use HZ macro from units.hDmitry Rokosov
Remove duplicated definition of UHZ_PER_HZ, because it's available in the units.h as MICROHZ_PER_HZ. Signed-off-by: Dmitry Rokosov <ddrokosov@sberdevices.ru> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20220812165243.22177-5-ddrokosov@sberdevices.ru Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-08-19iio: st_sensors: move from strlcpy with unused retval to strscpyWolfram Sang
Follow the advice of the below link and prefer 'strscpy' in this subsystem. Conversion is 1:1 because the return value is not used. Generated by a coccinelle script. Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/ Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://lore.kernel.org/r/20220818210017.6817-1-wsa+renesas@sang-engineering.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-07-18iio: cros: Register FIFO callback after sensor is registeredGwendal Grignou
Instead of registering callback to process sensor events right at initialization time, wait for the sensor to be register in the iio subsystem. Events can come at probe time (in case the kernel rebooted abruptly without switching the sensor off for instance), and be sent to IIO core before the sensor is fully registered. Fixes: aa984f1ba4a4 ("iio: cros_ec: Register to cros_ec_sensorhub when EC supports FIFO") Reported-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Douglas Anderson <dianders@chromium.org> Link: https://lore.kernel.org/r/20220711144716.642617-1-gwendal@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-14iio: common: cros_ec_sensors: explicitly add proper header filesNuno Sá
Do not trust the fact that iio.h includes of.h which in turn includes all the headers we are relying on. The ultimate goal is to actually drop of.h from iio.h. Signed-off-by: Nuno Sá <nuno.sa@analog.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20220610084545.547700-13-nuno.sa@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-14iio: common: cros_ec_lid_angle: explicitly add proper header filesNuno Sá
Do not trust the fact that iio.h includes of.h which in turn includes all the headers we are relying on. The ultimate goal is to actually drop of.h from iio.h. Signed-off-by: Nuno Sá <nuno.sa@analog.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20220610084545.547700-12-nuno.sa@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-14iio: common: ssp: Fix alignment for DMA safetyJonathan Cameron
____cacheline_aligned is an insufficient guarantee for non-coherent DMA on platforms with 128 byte cachelines above L1. Switch to the updated IIO_DMA_MINALIGN definition. Fixes: 50dd64d57eee ("iio: common: ssp_sensors: Add sensorhub driver") Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Acked-by: Nuno Sá <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20220508175712.647246-43-jic23@kernel.org
2022-06-11iio: common: cros_ec_sensors: Add label attributeGwendal Grignou
When sensor location is known, populate iio sysfs "label" attribute: * "accel-base" : the sensor is in the base of the convertible (2-1) device. * "accel-display" : the sensor is in the lid/display plane of the device. * "accel-camera" : the sensor is in the swivel camera subassembly. The non-standard |location| attribute is removed, the field |loc| in cros_ec_sensors_core_state is removed. It apply to standalone accelerometer as well as IMU (accelerometer + gyroscope) and sensors where the location is known (light). Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Link: https://lore.kernel.org/r/20220427190804.961697-3-gwendal@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-04-28iio: Replace strtobool() with kstrtobool()Lars-Peter Clausen
strtobool() is deprecated and just a wrapper around kstrtobool().Replace it with kstrtobool() so the deprecated function can be removed eventually. Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20220409105812.2113895-1-lars@metafoo.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-04-10iio: core: Simplify the registration of kfifo buffersMiquel Raynal
Among all the users of the kfifo buffers, no one uses the INDIO_BUFFER_HARDWARE mode. So let's take this as a general rule and simplify a little bit the internals - overall the documentation - by eliminating unused specific cases. Use the INDIO_BUFFER_SOFTWARE mode by default with kfifo buffers, which will basically mimic what all the "non direct" modes do. Cc: Benson Leung <bleung@chromium.org> Cc: Guenter Roeck <groeck@chromium.org> Cc: Jyoti Bhayana <jbhayana@google.com> Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> Cc: Michael Hennerich <Michael.Hennerich@analog.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/r/20220207143840.707510-13-miquel.raynal@bootlin.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>