linux-block.git
3 weeks agobinder: fix yet another UAF in binder_devices
Carlos Llamas [Sat, 24 May 2025 22:07:58 +0000 (22:07 +0000)]
binder: fix yet another UAF in binder_devices

Commit e77aff5528a18 ("binderfs: fix use-after-free in binder_devices")
addressed a use-after-free where devices could be released without first
being removed from the binder_devices list. However, there is a similar
path in binder_free_proc() that was missed:

  ==================================================================
  BUG: KASAN: slab-use-after-free in binder_remove_device+0xd4/0x100
  Write of size 8 at addr ffff0000c773b900 by task umount/467
  CPU: 12 UID: 0 PID: 467 Comm: umount Not tainted 6.15.0-rc7-00138-g57483a362741 #9 PREEMPT
  Hardware name: linux,dummy-virt (DT)
  Call trace:
   binder_remove_device+0xd4/0x100
   binderfs_evict_inode+0x230/0x2f0
   evict+0x25c/0x5dc
   iput+0x304/0x480
   dentry_unlink_inode+0x208/0x46c
   __dentry_kill+0x154/0x530
   [...]

  Allocated by task 463:
   __kmalloc_cache_noprof+0x13c/0x324
   binderfs_binder_device_create.isra.0+0x138/0xa60
   binder_ctl_ioctl+0x1ac/0x230
  [...]

  Freed by task 215:
   kfree+0x184/0x31c
   binder_proc_dec_tmpref+0x33c/0x4ac
   binder_deferred_func+0xc10/0x1108
   process_one_work+0x520/0xba4
  [...]
  ==================================================================

Call binder_remove_device() within binder_free_proc() to ensure the
device is removed from the binder_devices list before being kfreed.

Cc: stable@vger.kernel.org
Fixes: 12d909cac1e1 ("binderfs: add new binder devices to binder_devices")
Reported-by: syzbot+4af454407ec393de51d6@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=4af454407ec393de51d6
Tested-by: syzbot+4af454407ec393de51d6@syzkaller.appspotmail.com
Signed-off-by: Carlos Llamas <cmllamas@google.com>
Link: https://lore.kernel.org/r/20250524220758.915028-1-cmllamas@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 weeks agoMerge tag 'counter-updates-for-6.16b' of ssh://gitolite.kernel.org/pub/scm/linux...
Greg Kroah-Hartman [Sat, 24 May 2025 06:29:32 +0000 (08:29 +0200)]
Merge tag 'counter-updates-for-6.16b' of ssh://gitolite./linux/kernel/git/wbg/counter into char-misc-next

William writes:

Second set of Counter updates for 6.16

Adds compatible for STM32MP25 SoC and enables respective encoder
capability for stm32-timer-cnt. Implements watch_validate callback for
microchip-tcb-capture.

* tag 'counter-updates-for-6.16b' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/wbg/counter:
  counter: microchip-tcb-capture: Add watch validation support
  counter: stm32-timer-cnt: add support for stm32mp25

3 weeks agoMerge tag 'icc-6.16-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/djakov...
Greg Kroah-Hartman [Thu, 22 May 2025 16:25:27 +0000 (18:25 +0200)]
Merge tag 'icc-6.16-rc1' of ssh://gitolite./linux/kernel/git/djakov/icc into char-misc-next

Georgi writes:

interconnect changes for 6.16

This pull request contains the interconnect changes for the 6.16-rc1
merge window. The core and driver changes are listed below.

Core changes:
- Add support for dynamic id allocation, that allows creating
  multiple instances of the same provider

Driver changes:
- Add driver for the EPSS L3 instances on SA8775P SoC
- Add QoS support for SM8650 SoC
- Add some missing nodes for SM8650
- Misc dt-binding style and indentation fixes

Signed-off-by: Georgi Djakov <djakov@kernel.org>
* tag 'icc-6.16-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/djakov/icc:
  interconnect: qcom: sm8650: remove regmap config for mc_virt & clk_virt
  interconnect: qcom: sm8650: add the MASTER_APSS_NOC
  dt-bindings: interconnect: sm8650: document the MASTER_APSS_NOC
  interconnect: qcom: sm8650: enable QoS configuration
  dt-bindings: interconnect: Correct indentation and style in DTS example
  interconnect: qcom: sa8775p: Add dynamic icc node id support
  interconnect: qcom: icc-rpmh: Add dynamic icc node id support
  interconnect: qcom: Add multidev EPSS L3 support
  interconnect: core: Add dynamic id allocation support
  dt-bindings: interconnect: Add EPSS L3 compatible for SA8775P

3 weeks agoMerge tag 'coresight-next-v6.16' of ssh://gitolite.kernel.org/pub/scm/linux/kernel...
Greg Kroah-Hartman [Thu, 22 May 2025 16:04:43 +0000 (18:04 +0200)]
Merge tag 'coresight-next-v6.16' of ssh://gitolite./linux/kernel/git/coresight/linux into char-misc-next

Suzuki writes:

coresight: updates for Linux v6.16

CoreSight self-hosted trace driver subsystem updates for Linux v6.16 includes:
 - Clear CLAIM tags on device probe if self-hosted tags are set.
 - Support for perf AUX pause/resume for CoreSight ETM PMU driver, with trace
   collection at pause.
 - Miscellaneous fixes for the subsystem

Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
* tag 'coresight-next-v6.16' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/coresight/linux: (27 commits)
  coresight: prevent deactivate active config while enabling the config
  coresight: holding cscfg_csdev_lock while removing cscfg from csdev
  coresight/etm4: fix missing disable active config
  coresight: etm4x: Fix timestamp bit field handling
  coresight: tmc: fix failure to disable/enable ETF after reading
  Documentation: coresight: Document AUX pause and resume
  coresight: perf: Update buffer on AUX pause
  coresight: tmc: Re-enable sink after buffer update
  coresight: perf: Support AUX trace pause and resume
  coresight: etm4x: Hook pause and resume callbacks
  coresight: Introduce pause and resume APIs for source
  coresight: etm4x: Extract the trace unit controlling
  coresight: cti: Replace inclusion by struct fwnode_handle forward declaration
  coresight: Disable MMIO logging for coresight stm driver
  coresight: replicator: Fix panic for clearing claim tag
  coresight: Add a KUnit test for coresight_find_default_sink()
  coresight: Remove extern from function declarations
  coresight: Remove inlines from static function definitions
  coresight: Clear self hosted claim tag on probe
  coresight: etm3x: Convert raw base pointer to struct coresight access
  ...

3 weeks agoMerge tag 'iio-for-6.16a-take2' of ssh://gitolite.kernel.org/pub/scm/linux/kernel...
Greg Kroah-Hartman [Thu, 22 May 2025 13:54:52 +0000 (15:54 +0200)]
Merge tag 'iio-for-6.16a-take2' of ssh://gitolite./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 BD79700BD79701 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
  ...

3 weeks agocounter: microchip-tcb-capture: Add watch validation support
Dharma Balasubiramani [Tue, 20 May 2025 15:21:46 +0000 (20:51 +0530)]
counter: microchip-tcb-capture: Add watch validation support

The Timer Counter Block (TCB) exposes several kinds of events to the
Counter framework, but not every event is meaningful on every hardware
channel. Add a `watch_validate()` callback so userspace may register only
the combinations actually supported:

* Channel 0 (COUNTER_MCHP_EVCHN_CV, COUNTER_MCHP_EVCHN_RA)
   - COUNTER_EVENT_CAPTURE
   - COUNTER_EVENT_CHANGE_OF_STATE
   - COUNTER_EVENT_OVERFLOW

* Channel 1 (COUNTER_MCHP_EVCHN_RB)
   - COUNTER_EVENT_CAPTURE

* Channel 2 (COUNTER_MCHP_EVCHN_RC)
   - COUNTER_EVENT_THRESHOLD

Any other request is rejected with `-EINVAL`.

Signed-off-by: Dharma Balasubiramani <dharma.b@microchip.com>
Link: https://lore.kernel.org/r/20250520-counter-tcb-v3-1-4631e2aff7ed@microchip.com
Signed-off-by: William Breathitt Gray <wbg@kernel.org>
3 weeks agodt-bindings: iio: adc: Add ROHM BD79100G
Matti Vaittinen [Wed, 14 May 2025 06:25:13 +0000 (09:25 +0300)]
dt-bindings: iio: adc: Add ROHM BD79100G

The ROHM BD79100G is a 12-bit ADC which can be read over SPI. Device has
no MOSI pin. ADC results can be read from MISO by clocking in 16 bits.
The 4 leading bits will be zero, last 12 containig the data.

Device has only VCC supply pin, which acts also as a VFS, determining the
voltage for full 12-bits. Specifying it is mandatory.

This seems identical to the ti,ads7866.

Support ROHM BU79100G using ti,ads7866 as a fallback.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://patch.msgid.link/4907a096eee1f54afae834213cf721b551382d4e.1747203712.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: add support for Nuvoton NCT7201
Eason Yang [Mon, 12 May 2025 08:31:56 +0000 (16:31 +0800)]
iio: adc: add support for Nuvoton NCT7201

Add Nuvoton NCT7201/NCT7202 system voltage monitor 12-bit ADC driver

NCT7201/NCT7202 supports up to 12 analog voltage monitor inputs and up
to 4 SMBus addresses by ADDR pin. Meanwhile, ALERT# hardware event pins
for independent alarm signals, and all the threshold values could be set
for system protection without any timing delay. It also supports reset
input RSTIN# to recover system from a fault condition.

Currently, only single-edge mode conversion and threshold events are
supported.

Signed-off-by: Eason Yang <j2anfernee@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20250512083156.3300006-3-j2anfernee@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agodt-bindings: iio: adc: add NCT7201 ADCs
Eason Yang [Mon, 12 May 2025 08:31:55 +0000 (16:31 +0800)]
dt-bindings: iio: adc: add NCT7201 ADCs

Add a binding specification for the Nuvoton NCT7201/NCT7202 up to 12-bit
ADCs with I2C interface.

Signed-off-by: Eason Yang <j2anfernee@gmail.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20250512083156.3300006-2-j2anfernee@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: chemical: Add driver for SEN0322
Tóth János [Tue, 6 May 2025 09:01:16 +0000 (11:01 +0200)]
iio: chemical: Add driver for SEN0322

Add support for the DFRobot SEN0322 oxygen sensor.

To instantiate (assuming device is connected to I2C-2):
echo 'sen0322 0x73' > /sys/class/i2c-dev/i2c-2/device/new_device

To get the oxygen concentration (assuming device is iio:device0) multiply
the values read from:
/sys/bus/iio/devices/iio:device0/in_concentration_raw
/sys/bus/iio/devices/iio:device0/in_concentration_scale

Datasheet: https://wiki.dfrobot.com/Gravity_I2C_Oxygen_Sensor_SKU_SEN0322
Signed-off-by: Tóth János <gomba007@gmail.com>
Link: https://patch.msgid.link/20250506-iio-chemical-sen0322-v4-2-1465ac8dc190@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agodt-bindings: trivial-devices: Document SEN0322
Tóth János [Tue, 6 May 2025 09:01:15 +0000 (11:01 +0200)]
dt-bindings: trivial-devices: Document SEN0322

Add documentation for the DFRobot SEN0322 oxygen sensor.

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Tóth János <gomba007@gmail.com>
Link: https://patch.msgid.link/20250506-iio-chemical-sen0322-v4-1-1465ac8dc190@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: ad7768-1: reorganize driver headers
Jonathan Santos [Thu, 8 May 2025 17:03:04 +0000 (14:03 -0300)]
iio: adc: ad7768-1: reorganize driver headers

Remove kernel.h since it adds a lot of unnecessary dependencies.
Add specific headers to ensure all functions and macros used in the driver
are directly declared.

Suggested-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://patch.msgid.link/1f7677d31a0165cb30d7eb3b4d613e1337937f9a.1746662899.git.Jonathan.Santos@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: bmp280: zero-init buffer
David Lechner [Tue, 6 May 2025 18:49:57 +0000 (13:49 -0500)]
iio: bmp280: zero-init buffer

Zero-initialize the buffer used with iio_push_to_buffers_with_ts(). The
struct used for the buffer has holes in it, so we need to make sure that
the holes are zeroed out rather than containing uninitialized data from
the stack.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-iio/aBoBR5D1UMjsSUfZ@stanley.mountain/
Fixes: 872c8014e05e ("iio: pressure: bmp280: drop sensor_data array")
Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250506-iio-pressure-bmp280-zero-init-buffer-v1-1-0935c31558ac@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: ssp_sensors: optimalize -> optimize
Ahelenia Ziemiańska [Tue, 6 May 2025 19:10:02 +0000 (21:10 +0200)]
iio: ssp_sensors: optimalize -> optimize

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>
3 weeks agoHID: sensor-hub: Fix typo and improve documentation
Chelsy Ratnawat [Wed, 7 May 2025 05:57:45 +0000 (22:57 -0700)]
HID: sensor-hub: Fix typo and improve documentation

Includes the following corrections -
 - Changed Measurment -> Measurement
 - Changed clode -> close
 - Gyro -> gyro

Signed-off-by: Chelsy Ratnawat <chelsyratnawat2001@gmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250507055745.4069933-1-chelsyratnawat2001@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: admv1013: replace redundant ternary operator with just len
Colin Ian King [Wed, 7 May 2025 13:45:02 +0000 (14:45 +0100)]
iio: admv1013: replace redundant ternary operator with just len

The variable ret is being assigned a return value and non-zero error
return paths are taken at all stages. At the end of the function ret
is always zero, so the ternary operator checking for zero ret is
redundant and can be replaced with just len instead.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250507134502.254736-1-colin.i.king@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: chemical: mhz19b: Fix error code in probe()
Dan Carpenter [Wed, 7 May 2025 12:59:00 +0000 (15:59 +0300)]
iio: chemical: mhz19b: Fix error code in probe()

Return -ENOMEM if devm_iio_device_alloc() fails.  Don't return success.

Fixes: 4572a70b3681 ("iio: chemical: Add support for Winsen MHZ19B CO2 sensor")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Acked-by: Gyeyoung Baek <gye976@gmail.com>
Link: https://patch.msgid.link/aBtZFLFlr0slcYSi@stanley.mountain
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: at91-sama5d2: use IIO_DECLARE_BUFFER_WITH_TS
David Lechner [Wed, 7 May 2025 20:42:46 +0000 (15:42 -0500)]
iio: adc: at91-sama5d2: use IIO_DECLARE_BUFFER_WITH_TS

Use IIO_DECLARE_BUFFER_WITH_TS() to declare the buffer that gets used
with iio_push_to_buffers_with_ts(). This makes the code a bit easier to
read and understand.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250507-iio-introduce-iio_declare_buffer_with_ts-v6-7-4aee1b9f1b89@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: accel: sca3300: use IIO_DECLARE_BUFFER_WITH_TS
David Lechner [Wed, 7 May 2025 20:42:45 +0000 (15:42 -0500)]
iio: accel: sca3300: use IIO_DECLARE_BUFFER_WITH_TS

Use IIO_DECLARE_BUFFER_WITH_TS() to declare the buffer that gets used
with iio_push_to_buffers_with_ts(). This makes the code a bit easier to
read and understand.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250507-iio-introduce-iio_declare_buffer_with_ts-v6-6-4aee1b9f1b89@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: ad7380: use IIO_DECLARE_DMA_BUFFER_WITH_TS
David Lechner [Wed, 7 May 2025 20:42:44 +0000 (15:42 -0500)]
iio: adc: ad7380: use IIO_DECLARE_DMA_BUFFER_WITH_TS

Use IIO_DECLARE_DMA_BUFFER_WITH_TS() to declare the buffer that gets
used with iio_push_to_buffers_with_ts(). This makes the code a bit
easier to read and understand.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250507-iio-introduce-iio_declare_buffer_with_ts-v6-5-4aee1b9f1b89@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: ad4695: rename AD4695_MAX_VIN_CHANNELS
David Lechner [Wed, 7 May 2025 20:42:43 +0000 (15:42 -0500)]
iio: adc: ad4695: rename AD4695_MAX_VIN_CHANNELS

Rename AD4695_MAX_CHANNELS to AD4695_MAX_VIN_CHANNELS. It has been a
point of confusion that this macro is only the voltage input channels
and not all channels.

Reviewed-by: Trevor Gamblin <tgamblin@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250507-iio-introduce-iio_declare_buffer_with_ts-v6-4-4aee1b9f1b89@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: ad4695: use IIO_DECLARE_DMA_BUFFER_WITH_TS
David Lechner [Wed, 7 May 2025 20:42:42 +0000 (15:42 -0500)]
iio: adc: ad4695: use IIO_DECLARE_DMA_BUFFER_WITH_TS

Use IIO_DECLARE_DMA_BUFFER_WITH_TS() to declare the buffer that gets
used with iio_push_to_buffers_with_ts(). This makes the code a bit
easier to read and understand.

Reviewed-by: Trevor Gamblin <tgamblin@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250507-iio-introduce-iio_declare_buffer_with_ts-v6-3-4aee1b9f1b89@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: introduce IIO_DECLARE_BUFFER_WITH_TS macros
David Lechner [Wed, 7 May 2025 20:42:41 +0000 (15:42 -0500)]
iio: introduce IIO_DECLARE_BUFFER_WITH_TS macros

Add new macros to help with the common case of declaring a buffer that
is safe to use with iio_push_to_buffers_with_ts(). This is not trivial
to do correctly because of the alignment requirements of the timestamp.
This will make it easier for both authors and reviewers.

To avoid double __align() attributes in cases where we also need DMA
alignment, add a 2nd variant IIO_DECLARE_DMA_BUFFER_WITH_TS().

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250507-iio-introduce-iio_declare_buffer_with_ts-v6-2-4aee1b9f1b89@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: make IIO_DMA_MINALIGN minimum of 8 bytes
David Lechner [Wed, 7 May 2025 20:42:40 +0000 (15:42 -0500)]
iio: make IIO_DMA_MINALIGN minimum of 8 bytes

Add a condition to ensure that IIO_DMA_MINALIGN is at least 8 bytes.
On some 32-bit architectures, IIO_DMA_MINALIGN is 4. In many cases,
drivers are using this alignment for buffers that include a 64-bit
timestamp that is used with iio_push_to_buffers_with_ts(), which expects
the timestamp to be aligned to 8 bytes. To handle this, we can just make
IIO_DMA_MINALIGN at least 8 bytes.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250507-iio-introduce-iio_declare_buffer_with_ts-v6-1-4aee1b9f1b89@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: pressure: zpa2326_spi: remove bits_per_word = 8
David Lechner [Mon, 5 May 2025 19:20:41 +0000 (14:20 -0500)]
iio: pressure: zpa2326_spi: remove bits_per_word = 8

Remove setting bits_per_word = 8 from the zpa2326 driver. This is the
default value for SPI transfers, so it is not necessary to explicitly
set it.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250505-iio-remove-bits_per_word-8-v1-14-341f85fcfe11@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: pressure: ms5611_spi: remove bits_per_word = 8
David Lechner [Mon, 5 May 2025 19:20:40 +0000 (14:20 -0500)]
iio: pressure: ms5611_spi: remove bits_per_word = 8

Remove setting bits_per_word = 8 from the ms5611 driver. This is the
default value for SPI transfers, so it is not necessary to explicitly
set it.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250505-iio-remove-bits_per_word-8-v1-13-341f85fcfe11@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: pressure: bmp280-spi: remove bits_per_word = 8
David Lechner [Mon, 5 May 2025 19:20:39 +0000 (14:20 -0500)]
iio: pressure: bmp280-spi: remove bits_per_word = 8

Remove setting bits_per_word = 8 from the bmp280 driver. This is the
default value for SPI transfers, so it is not necessary to explicitly
set it.

Since no other SPI settings are changed, we can also remove the call to
spi_setup().

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250505-iio-remove-bits_per_word-8-v1-12-341f85fcfe11@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: magnetometer: rm3100-spi: remove bits_per_word = 8
David Lechner [Mon, 5 May 2025 19:20:38 +0000 (14:20 -0500)]
iio: magnetometer: rm3100-spi: remove bits_per_word = 8

Remove setting bits_per_word = 8 from the rm3100 driver. This is the
default value for SPI transfers, so it is not necessary to explicitly
set it.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250505-iio-remove-bits_per_word-8-v1-11-341f85fcfe11@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: magnetometer: hmc5843_spi: remove bits_per_word = 8
David Lechner [Mon, 5 May 2025 19:20:37 +0000 (14:20 -0500)]
iio: magnetometer: hmc5843_spi: remove bits_per_word = 8

Remove setting bits_per_word = 8 from the hmc5843 driver. This is the
default value for SPI transfers, so it is not necessary to explicitly
set it.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250505-iio-remove-bits_per_word-8-v1-10-341f85fcfe11@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: imu: adis: remove bits_per_word = 8
David Lechner [Mon, 5 May 2025 19:20:36 +0000 (14:20 -0500)]
iio: imu: adis: remove bits_per_word = 8

Remove setting bits_per_word = 8 from the adis driver. This is the
default value for SPI transfers, so it is not necessary to explicitly
set it.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250505-iio-remove-bits_per_word-8-v1-9-341f85fcfe11@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: gyro: adxrs450: remove bits_per_word = 8
David Lechner [Mon, 5 May 2025 19:20:35 +0000 (14:20 -0500)]
iio: gyro: adxrs450: remove bits_per_word = 8

Remove setting bits_per_word = 8 from the adxrs450 driver. This is the
default value for SPI transfers, so it is not necessary to explicitly
set it.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250505-iio-remove-bits_per_word-8-v1-8-341f85fcfe11@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: dac: ltc2688: remove bits_per_word = 8
David Lechner [Mon, 5 May 2025 19:20:34 +0000 (14:20 -0500)]
iio: dac: ltc2688: remove bits_per_word = 8

Remove setting bits_per_word = 8 from the ltc2688 driver. This is the
default value for SPI transfers, so it is not necessary to explicitly
set it.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250505-iio-remove-bits_per_word-8-v1-7-341f85fcfe11@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: dac: ad5791: remove bits_per_word = 8
David Lechner [Mon, 5 May 2025 19:20:33 +0000 (14:20 -0500)]
iio: dac: ad5791: remove bits_per_word = 8

Remove setting bits_per_word = 8 from the ad5791 driver. This is the
default value for SPI transfers, so it is not necessary to explicitly
set it.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250505-iio-remove-bits_per_word-8-v1-6-341f85fcfe11@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: dac: ad5766: remove bits_per_word = 8
David Lechner [Mon, 5 May 2025 19:20:32 +0000 (14:20 -0500)]
iio: dac: ad5766: remove bits_per_word = 8

Remove setting bits_per_word = 8 from the ad5766 driver. This is the
default value for SPI transfers, so it is not necessary to explicitly
set it.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250505-iio-remove-bits_per_word-8-v1-5-341f85fcfe11@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: dac: ad5761: remove bits_per_word = 8
David Lechner [Mon, 5 May 2025 19:20:31 +0000 (14:20 -0500)]
iio: dac: ad5761: remove bits_per_word = 8

Remove setting bits_per_word = 8 from the ad5761 driver. This is the
default value for SPI transfers, so it is not necessary to explicitly
set it.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250505-iio-remove-bits_per_word-8-v1-4-341f85fcfe11@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: chemical: bme680_spi: remove bits_per_word = 8
David Lechner [Mon, 5 May 2025 19:20:30 +0000 (14:20 -0500)]
iio: chemical: bme680_spi: remove bits_per_word = 8

Remove setting bits_per_word = 8 from the bme680 driver. This is the
default value for SPI transfers, so it is not necessary to explicitly
set it.

Since no other SPI settings are changed, we can also remove the call to
spi_setup().

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250505-iio-remove-bits_per_word-8-v1-3-341f85fcfe11@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: ti-tsc2046: remove bits_per_word = 8
David Lechner [Mon, 5 May 2025 19:20:29 +0000 (14:20 -0500)]
iio: adc: ti-tsc2046: remove bits_per_word = 8

Remove setting bits_per_word = 8 from the ti-tsc2046 driver. This is the
default value for SPI transfers, so it is not necessary to explicitly
set it.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250505-iio-remove-bits_per_word-8-v1-2-341f85fcfe11@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: ad4030: remove bits_per_word = 8
David Lechner [Mon, 5 May 2025 19:20:28 +0000 (14:20 -0500)]
iio: adc: ad4030: remove bits_per_word = 8

Remove setting bits_per_word = 8 from the ad4030 driver. This is the
default value for SPI transfers, so it is not necessary to explicitly
set it.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250505-iio-remove-bits_per_word-8-v1-1-341f85fcfe11@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: ti-ads1298: Kconfig: add kfifo dependency to fix module build
Arthur-Prince [Wed, 30 Apr 2025 19:07:37 +0000 (16:07 -0300)]
iio: adc: ti-ads1298: Kconfig: add kfifo dependency to fix module build

Add dependency to Kconfig’s ti-ads1298 because compiling it as a module
failed with an undefined kfifo symbol.

Fixes: 00ef7708fa60 ("iio: adc: ti-ads1298: Add driver")
Signed-off-by: Arthur-Prince <r2.arthur.prince@gmail.com>
Co-developed-by: Mariana Valério <mariana.valerio2@hotmail.com>
Signed-off-by: Mariana Valério <mariana.valerio2@hotmail.com>
Link: https://patch.msgid.link/20250430191131.120831-1-r2.arthur.prince@gmail.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: ti-adc128s052: Drop variable vref
Matti Vaittinen [Mon, 28 Apr 2025 07:02:17 +0000 (10:02 +0300)]
iio: ti-adc128s052: Drop variable vref

According to Jonathan, variable reference voltages are very rare. It is
unlikely it is needed, and supporting it makes the code a bit more
complex.

Simplify the driver and drop the variable vref support.

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/59106e24332743a7f9eb0b13ad6a2f5595ab485a.1745823530.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: ad4000: Avoid potential double data word read
Marcelo Schmitt [Tue, 15 Apr 2025 12:21:10 +0000 (09:21 -0300)]
iio: adc: ad4000: Avoid potential double data word read

Currently, SPI-Engine offload module always sends 32-bit data elements to
DMA engine. Appropriately, when set for SPI offloading, the IIO driver uses
32 storagebits for IIO ADC channel buffer elements. However, setting SPI
transfer length according to storagebits (32-bits in case of offload) can
lead to unnecessarily long transfers for ADCs that are 16-bit or less
precision. Adjust AD4000 single-shot read to run transfers of 2 bytes when
that is enough to get all ADC data bits.

Fixes: 59b51edf717b ("iio: adc: ad4000: Add support for SPI offload")
Suggested-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/8f765cfd6e93fad4e755dd95d709b7bea2a388e2.1744718916.git.marcelo.schmitt@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: mcp3911: add reset management
Marcus Folkesson [Mon, 28 Apr 2025 06:54:13 +0000 (08:54 +0200)]
iio: adc: mcp3911: add reset management

Add support for optional HW reset.
If specified, a reset will be asserted during driver probe.

Co-developed-by: Lukas Rauber <lukas.rauber@janitza.de>
Signed-off-by: Lukas Rauber <lukas.rauber@janitza.de>
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20250428-mcp3911-fixes-v2-3-406e39330c3d@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agodt-bindings: iio: adc: mcp3911: add reset-gpios
Marcus Folkesson [Mon, 28 Apr 2025 06:54:12 +0000 (08:54 +0200)]
dt-bindings: iio: adc: mcp3911: add reset-gpios

The MCP391X family provides an active low reset signal that is still not
described in the bindings.

Add reset-gpios to the bindings and the example.

Co-developed-by: Lukas Rauber <lukas.rauber@janitza.de>
Signed-off-by: Lukas Rauber <lukas.rauber@janitza.de>
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20250428-mcp3911-fixes-v2-2-406e39330c3d@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: mcp3911: fix device dependent mappings for conversion result registers
Marcus Folkesson [Mon, 28 Apr 2025 06:54:11 +0000 (08:54 +0200)]
iio: adc: mcp3911: fix device dependent mappings for conversion result registers

The conversion result registers differs between devices. Make sure the
mapping is correct by using a device dependent .get_raw() callback function.

Fixes: 732ad34260d3 ("iio: adc: mcp3911: add support for the whole MCP39xx family")
Co-developed-by: Lukas Rauber <lukas.rauber@janitza.de>
Signed-off-by: Lukas Rauber <lukas.rauber@janitza.de>
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20250428-mcp3911-fixes-v2-1-406e39330c3d@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: ad4695: use u16 for buffer elements
David Lechner [Mon, 28 Apr 2025 20:23:04 +0000 (15:23 -0500)]
iio: adc: ad4695: use u16 for buffer elements

Change the type of the buffer elements to u16 since we currently only
support 16-bit word size. The code was originally written to also allow
for 32-bit word size when oversampling is enabled, but so far,
oversampling is only implemented when using SPI offload and therefore
doesn't use this buffer.

AD4695_MAX_CHANNEL_SIZE macro is dropped since it no longer adds any
value.

AD4695_MAX_CHANNELS + 2 is changed to AD4695_MAX_CHANNELS + 1 because
previously we were overallocating. AD4695_MAX_CHANNELS is the number of
of voltage channels and + 1 is for the temperature channel.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Trevor Gamblin <tgamblin@baylibre.com>
Link: https://patch.msgid.link/20250428-iio-introduce-iio_declare_buffer_with_ts-v4-2-6f7f6126f1cb@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: dac: ad3530r: Add driver for AD3530R and AD3531R
Kim Seer Paller [Tue, 29 Apr 2025 02:19:18 +0000 (10:19 +0800)]
iio: dac: ad3530r: Add driver for AD3530R and AD3531R

The AD3530/AD3530R (8-channel) and AD3531/AD3531R (4-channel) are
low-power, 16-bit, buffered voltage output DACs with software-
programmable gain controls, providing full-scale output spans of 2.5V or
5V for reference voltages of 2.5V. These devices operate from a single
2.7V to 5.5V supply and are guaranteed monotonic by design. The "R"
variants include a 2.5V, 5ppm/°C internal reference, which is disabled
by default.

Support for monitoring internal die temperature, output voltages, and
current of a selected channel via the MUXOUT pin using an external ADC
is currently not implemented.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Kim Seer Paller <kimseer.paller@analog.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://patch.msgid.link/20250429-togreg-v7-3-0af9c543b545@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agodt-bindings: iio: dac: Add adi,ad3530r.yaml
Kim Seer Paller [Tue, 29 Apr 2025 02:19:17 +0000 (10:19 +0800)]
dt-bindings: iio: dac: Add adi,ad3530r.yaml

Document the AD3530/AD3530R (8-channel) and AD3531/AD3531R (4-channel)
low-power, 16-bit, buffered voltage output DACs with software-
programmable gain controls. They provide full-scale output spans of 2.5V
or 5V for reference voltages of 2.5V. These devices operate on a single
2.7V to 5.5V supply and are guaranteed to be monotonic by design.
The "R" variants include a 2.5V, 5ppm/°C internal reference, which is
disabled by default.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Kim Seer Paller <kimseer.paller@analog.com>
Link: https://patch.msgid.link/20250429-togreg-v7-2-0af9c543b545@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: ABI: add new DAC powerdown mode
Kim Seer Paller [Tue, 29 Apr 2025 02:19:16 +0000 (10:19 +0800)]
iio: ABI: add new DAC powerdown mode

Add a new powerdown mode for DACs with 7.7kohm and 32kohm resistor
to GND.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Kim Seer Paller <kimseer.paller@analog.com>
Link: https://patch.msgid.link/20250429-togreg-v7-1-0af9c543b545@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoHID: sensor-hub: Fix typo and improve documentation for sensor_hub_remove_callback()
Chelsy Ratnawat [Fri, 2 May 2025 00:36:55 +0000 (17:36 -0700)]
HID: sensor-hub: Fix typo and improve documentation for sensor_hub_remove_callback()

Fixed a typo in "registered" and improved grammar for better readability
and consistency with kernel-doc standards. No functional changes.

Signed-off-by: Chelsy Ratnawat <chelsyratnawat2001@gmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250502003655.1943000-1-chelsyratnawat2001@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: ad7606: explicit timestamp alignment
David Lechner [Tue, 29 Apr 2025 02:17:14 +0000 (21:17 -0500)]
iio: adc: ad7606: explicit timestamp alignment

Use struct with aligned_s64 timestamp to make timestamp alignment
explicit. Technically, what we have works because for all known
architectures, IIO_DMA_MINALIGN is a multiple of __alignof__(s64).
But this way, we don't have to make people read the comments to know
why there are extra elements in each buffer.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250428-iio-adc-ad7606-fix-buffer-alignment-v1-1-88dfc57e5df0@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoMAINTAINERS: add maintainers for ad4851 driver
Antoniu Miclaus [Fri, 2 May 2025 10:00:16 +0000 (13:00 +0300)]
MAINTAINERS: add maintainers for ad4851 driver

Add the ad4851 entry in the MAINTAINERS file.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250502100016.26279-1-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: ad7606_spi: add offload scan mask check
David Lechner [Fri, 2 May 2025 15:42:16 +0000 (10:42 -0500)]
iio: adc: ad7606_spi: add offload scan mask check

Validate the scan mask when SPI offloading is being used.

Since this family of ADCs is simultaneous sampling, there isn't a way
to selectively disable channels when reading sample data. (Technically,
AD7616 has a sequencer so the driver could have some control, but that
is for another day).

For "regular" IIO triggered buffer reads, this isn't a problem and the
IIO core will demux the data and ignore data from disabled channels.
However, since SPI offloading is done completely in hardware, we don't
have a way to do the same. So before this patch, if less than all
channels were enabled, the data would be misplaced in the buffer.

By adding a check in update_scan_mode, we can fail to enable the buffer
instead of having bad data returned to userspace.

Fixes: e96d35faf357 ("iio: adc: ad7606: add SPI offload support")
Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250502-iio-adc-ad7606_spi-fix-offload-scan-mask-check-v2-1-e70c6d71baa3@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agodt-bindings: iio: adc: Add compatible for Dimensity 1200 MT6893
AngeloGioacchino Del Regno [Wed, 16 Apr 2025 12:02:35 +0000 (14:02 +0200)]
dt-bindings: iio: adc: Add compatible for Dimensity 1200 MT6893

Add a compatible for the Dimensity 1200 (MT6893) SoC; The AUXADC
IP in this chip is fully compatible with the one found in MT8173.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://patch.msgid.link/20250416120235.147889-1-angelogioacchino.delregno@collabora.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: dac: ad7293: add adc reference configuration
Antoniu Miclaus [Tue, 22 Apr 2025 08:55:29 +0000 (11:55 +0300)]
iio: dac: ad7293: add adc reference configuration

Add support for configurating the ADC reference (internal/external).

According to the datasheet, the external reference is enabled by
default.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250422085529.4407-2-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agodt-bindings: iio: dac: ad7293: add vrefin support
Antoniu Miclaus [Tue, 22 Apr 2025 08:55:28 +0000 (11:55 +0300)]
dt-bindings: iio: dac: ad7293: add vrefin support

Add support for vrefin supply responsible for providing external
reference to the SAR ADC within the part.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://patch.msgid.link/20250422085529.4407-1-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: ad7091r-base: Remove duplicate code on volatile reg check
Arthur Pilone [Mon, 21 Apr 2025 14:55:34 +0000 (11:55 -0300)]
iio: adc: ad7091r-base: Remove duplicate code on volatile reg check

Both ad7091r_writeable_reg() and ad7091r_volatile_reg() perform the
same test, checking whether a given 'reg' code is
AD7091R_REG_RESULT or AD7091R_REG_ALERT. As the volatile ad7091r
registers happen to be the only read-only ones, the volatile_reg()
function now returns the negated output of writeable_reg().

Co-developed-by: Bruno Stephan <bruno.stephan@usp.br>
Signed-off-by: Bruno Stephan <bruno.stephan@usp.br>
Co-developed-by: Andre de Lima <aschwarz@usp.br>
Signed-off-by: Andre de Lima <aschwarz@usp.br>
Signed-off-by: Arthur Pilone <art.pilone@gmail.com>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Link: https://patch.msgid.link/20250421145534.91146-1-arthurpilone@usp.br
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: pressure: bmp280: drop sensor_data array
David Lechner [Tue, 22 Apr 2025 19:28:36 +0000 (14:28 -0500)]
iio: pressure: bmp280: drop sensor_data array

Drop the sensor_data array from struct bmp280_data and replace it using
local structs in each interrupt handler.

The sensor_data array in struct bmp280_data is not used to share data
between functions and isn't used for DMA, so there isn't really a need
to have it in the struct. Instead, we can use the struct pattern for
scan data in each interrupt handler. This has the advantage of allowing
us to see the actual layout of each scan buffer for each different type
of supported sensor. It also avoid juggling values between local
variables and the array which makes the code a bit simpler by avoiding
some extra assignments.

We can also drop the BME280_NUM_MAX_CHANNELS macro as it is no longer
used.

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Link: https://lore.kernel.org/linux-iio/20250421135540.1a667221@jic23-huawei/
Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://patch.msgid.link/20250422-iio-pressure-bmp280-rework-push-to-buffers-v1-1-ee722f29aeca@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoMAINTAINERS: Add WINSEN MHZ19B
Gyeyoung Baek [Wed, 23 Apr 2025 19:41:00 +0000 (04:41 +0900)]
MAINTAINERS: Add WINSEN MHZ19B

Add undersigned as a maintainer for the WINSEN MHZ19B.

Signed-off-by: Gyeyoung Baek <gye976@gmail.com>
Link: https://patch.msgid.link/20250423194100.53934-5-gye976@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: chemical: Add support for Winsen MHZ19B CO2 sensor
Gyeyoung Baek [Wed, 23 Apr 2025 19:40:59 +0000 (04:40 +0900)]
iio: chemical: Add support for Winsen MHZ19B CO2 sensor

Add support for Winsen MHZ19B CO2 sensor.

Datasheet: https://www.winsen-sensor.com/d/files/infrared-gas-sensor/mh-z19b-co2-ver1_0.pdf
Signed-off-by: Gyeyoung Baek <gye976@gmail.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://patch.msgid.link/20250423194100.53934-4-gye976@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agodt-bindings: Add device tree support for Winsen MHZ19B CO2 sensor
Gyeyoung Baek [Wed, 23 Apr 2025 19:40:58 +0000 (04:40 +0900)]
dt-bindings: Add device tree support for Winsen MHZ19B CO2 sensor

Add device tree support for Winsen MHZ19B sensor.

Signed-off-by: Gyeyoung Baek <gye976@gmail.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20250423194100.53934-3-gye976@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agodt-bindings: Add Winsen to the vendor prefixes
Gyeyoung Baek [Wed, 23 Apr 2025 19:40:57 +0000 (04:40 +0900)]
dt-bindings: Add Winsen to the vendor prefixes

Add Winsen to the vendor prefixes.

Signed-off-by: Gyeyoung Baek <gye976@gmail.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20250423194100.53934-2-gye976@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: accel: kxcjk-1013: Deduplicate setup interrupt functions
Gustavo Vaz [Wed, 23 Apr 2025 20:46:31 +0000 (17:46 -0300)]
iio: accel: kxcjk-1013: Deduplicate setup interrupt functions

The contents of kxcjk1013_setup_any_motion_interrupt and
kxcj1013_setup_new_data_interrupt are very similar. Deduplicate these
functions by introducing a generic function named
kxcjk1013_setup_interrupt that has an additional flag indicating if
it's a new data interrupt.

Signed-off-by: Gustavo Vaz <gustavo.vaz@usp.br>
Co-developed-by: Francisco Henriques <franciscolealhenriques@usp.br>
Signed-off-by: Francisco Henriques <franciscolealhenriques@usp.br>
Link: https://patch.msgid.link/20250423204631.16460-1-gustavo.vaz@usp.br
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: cros_ec_sensors: Flush when changing the FIFO timeout
Gwendal Grignou [Wed, 23 Apr 2025 22:05:06 +0000 (15:05 -0700)]
iio: cros_ec_sensors: Flush when changing the FIFO timeout

|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>
3 weeks agoiio: light: zopt2201: Remove code duplication in scale write functions
Beatriz Viana Costa [Thu, 24 Apr 2025 00:21:44 +0000 (21:21 -0300)]
iio: light: zopt2201: Remove code duplication in scale write functions

Consolidate duplicated logic from zopt2201_write_scale_als_by_idx() and
zopt2201_write_scale_uvb_by_idx() into a new generic helper function
zopt2201_write_scale_by_idx(). This function takes an additional
parameter: a pointer to a zopt2201_scale array.

To support this, the previously anonymous and duplicated struct used in
the scale arrays was promoted to a named struct: zopt2201_scale.

This change also corrects an incorrect array access that existed in
zopt2201_write_scale_uvb_by_idx().

Signed-off-by: Beatriz Viana Costa <beatrizvianacosta16@gmail.com>
Co-developed-by: Gabriela Victor <gabevictor333@gmail.com>
Signed-off-by: Gabriela Victor <gabevictor333@gmail.com>
Link: https://patch.msgid.link/20250424002144.23260-1-beatrizvianacosta16@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: PAC1934: fix typo in documentation link
Marius Cristea [Thu, 24 Apr 2025 08:06:33 +0000 (11:06 +0300)]
iio: adc: PAC1934: fix typo in documentation link

Fix a typo,(PAC1934 -> PAC193X), into the link from an application note
related to the ACPI device definition.

Fixes: 0fb528c8255b ("iio: adc: adding support for PAC193x")
Reported-by: Matteo Martelli <matteomartelli3@gmail.com>
Closes: https://patch.msgid.link/172794015844.2520.11909797050797595912@njaxe.localdomain
Signed-off-by: Marius Cristea <marius.cristea@microchip.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250424-pac1934-doc_link-v1-1-9832445cb270@microchip.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: stm32: add oversampling support
Olivier Moysan [Thu, 24 Apr 2025 15:16:03 +0000 (17:16 +0200)]
iio: adc: stm32: add oversampling support

Add oversampling support for STM32H7, STM32MP15 & STM32MP13.
STM32F4 ADC has no oversampling feature.

The current support of the oversampling feature aims at increasing the
data SNR, without changing the data resolution.
As the oversampling by itself increases data resolution, a right shift
is applied to keep the initial resolution.
Only the oversampling ratio corresponding to a power of two are
supported here, to get a direct link between right shift and
oversampling ratio. (2^n ratio <=> n right shift)

The oversampling ratio is shared by all channels, whatever channel type.
(e.g. single ended or differential).

Oversampling can be configured using IIO ABI:
- oversampling_ratio_available
- oversampling_ratio

Co-developed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://patch.msgid.link/20250424151604.626758-1-olivier.moysan@foss.st.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agostaging: iio: ad5933: Correct settling cycles encoding per datasheet
Gabriel Shahrouzi [Sun, 20 Apr 2025 01:30:09 +0000 (21:30 -0400)]
staging: iio: ad5933: Correct settling cycles encoding per datasheet

The AD5933 datasheet (Table 13) lists the maximum cycles to be 0x7FC
(2044).

Clamp the user input to the maximum effective value of 0x7FC cycles.

Fixes: f94aa354d676 ("iio: impedance-analyzer: New driver for AD5933/4 Impedance Converter, Network Analyzer")
Cc: stable@vger.kernel.org
Signed-off-by: Gabriel Shahrouzi <gshahrouzi@gmail.com>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Link: https://patch.msgid.link/20250420013009.847851-1-gshahrouzi@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: orientation: hid-sensor-rotation: remove unnecessary alignment
David Lechner [Fri, 18 Apr 2025 20:08:53 +0000 (15:08 -0500)]
iio: orientation: hid-sensor-rotation: remove unnecessary alignment

Remove __aligned(16) in the scan data struct in the hid-sensor-rotation
driver. There is nothing in the code that requires this alignment.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://patch.msgid.link/20250418-iio-orientation-hid-sensor-rotation-remove-alignment-v1-1-6da68eae7ecf@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: hx711: use struct with aligned_s64 timestamp
David Lechner [Fri, 18 Apr 2025 19:58:22 +0000 (14:58 -0500)]
iio: adc: hx711: use struct with aligned_s64 timestamp

Use a struct with aligned s64_timestamp instead of a padded array for
the buffer used for iio_push_to_buffers_with_ts(). This makes it easier
to see the correctness of the size and alignment of the buffer.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250418-iio-prefer-aligned_s64-timestamp-v1-3-4c6080710516@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: accel: adxl345: set the tap suppress bit permanently
Lothar Rubusch [Mon, 14 Apr 2025 18:42:38 +0000 (18:42 +0000)]
iio: accel: adxl345: set the tap suppress bit permanently

Set the suppress bit feature to the double tap detection, whenever
double tap is enabled. This impedes the suppress bit dangling in any
state, and thus varying in sensitivity for double tap detection.

Any tap event is defined by a rising signal edge above threshold, i.e.
duration time starts counting; and the falling edge under threshold
within duration time, i.e. then the tap event is issued. This means
duration is used individually for each tap event.

For double tap detection after a single tap, a latency time needs to be
specified. Usually tap events, i.e. spikes above and returning below
threshold will be ignored within latency. After latency, the window
time starts counting for a second tap detection which has to happen
within a duration time.

If the suppress bit is not set, spikes within latency time are ignored.
Setting the suppress bit will invalidate the double tap function. The
sensor will thus be able to save the window time for double tap
detection, and follow a more strict definition of what signal qualifies
for a double tap.

In a summary having the suppress bit set, fewer signal spikes will be
considered as double taps. This is an optional add on to double tap,
thus a separate patch.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20250414184245.100280-5-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: accel: adxl345: add double tap feature
Lothar Rubusch [Mon, 14 Apr 2025 18:42:37 +0000 (18:42 +0000)]
iio: accel: adxl345: add double tap feature

Add the double tap feature of the sensor. The interrupt handler needs
to catch and forward the event to the IIO channel. The single tap
implementation now is extended to deal with double tap as well.

Doubletap introduces window and latency times, both in us. Since both
times are scaled, the 8-bit register value is stored in hardware,
where the scaled value in [us] is stored as member variable.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20250414184245.100280-4-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: accel: adxl345: add single tap feature
Lothar Rubusch [Mon, 14 Apr 2025 18:42:36 +0000 (18:42 +0000)]
iio: accel: adxl345: add single tap feature

Add the single tap feature with a threshold in 62.5mg/LSB points and a
scaled duration in us. Keep singletap threshold in regmap cache but
the scaled value of duration in us as member variable.

Both use IIO channels for individual enable of the x/y/z axis. Initializes
threshold and duration with reasonable content. When an interrupt is
caught it will be pushed to the according IIO channel.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20250414184245.100280-3-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: accel: adxl345: introduce adxl345_push_event function
Lothar Rubusch [Mon, 14 Apr 2025 18:42:35 +0000 (18:42 +0000)]
iio: accel: adxl345: introduce adxl345_push_event function

Move the fifo handling into a separate function. This is a preparation
for a generic handling of the interrupt status register results. The
function is supposed to handle particular sensor events, and later to
forward them to the iio channel. This is needed to read out the interrupt
status register.

The function shall return occurring errors, if any, or 0 in case of
handled events or read fifo content. Thus migrate fifo read-out and push
fifo content to iio channels into this function to be built up with
additional event handling.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20250414184245.100280-2-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: dac: ad5592r: Delete stray unlock in ad5592r_write_raw()
Dan Carpenter [Wed, 16 Apr 2025 11:09:33 +0000 (14:09 +0300)]
iio: dac: ad5592r: Delete stray unlock in ad5592r_write_raw()

This code was converted to use guard locks but one of the unlocks was
accidentally overlooked.  Delete it.

Fixes: 135e101f4dd6 ("iio: dac: ad5592r: use lock guards")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Link: https://patch.msgid.link/Z_-P7bsD3KL5K25R@stanley.mountain
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: frequency: ad9832: Remove unused parameter from data documentation
Gabriel Shahrouzi [Thu, 17 Apr 2025 17:33:33 +0000 (13:33 -0400)]
iio: frequency: ad9832: Remove unused parameter from data documentation

This is a leftover from the patch: commit 566564e80b0e ("staging: iio:
ad9832: use clock framework for clock reference").

The AD9832 driver uses the Common Clock Framework (CCF) to obtain the
master clock (MCLK) frequency rather than relying on a frequency value
passed from platform data.

Signed-off-by: Gabriel Shahrouzi <gshahrouzi@gmail.com>
Link: https://patch.msgid.link/20250417173333.607844-1-gshahrouzi@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: frequency: ad9832: Use FIELD_PREP macro to set bit fields
Siddharth Menon [Wed, 16 Apr 2025 13:48:56 +0000 (19:18 +0530)]
iio: frequency: ad9832: Use FIELD_PREP macro to set bit fields

Use bitfield and bitmask macros to clearly specify AD9832 SPI
command fields to make register write code more readable.

Suggested-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Signed-off-by: Siddharth Menon <simeddon@gmail.com>
Link: https://patch.msgid.link/20250416140259.13431-1-simeddon@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: addac: ad74413r: use aligned_s64 for timestamp
David Lechner [Thu, 17 Apr 2025 16:52:35 +0000 (11:52 -0500)]
iio: addac: ad74413r: use aligned_s64 for timestamp

Follow the pattern of other drivers and use aligned_s64 for the
timestamp. Technically there was no issue here since
AD74413R_FRAME_SIZE * AD74413R_CHANNEL_MAX == 16 and IIO_DMA_MINALIGN
is always a multiple of 8. But best to conform in case someone copies
this to new code and then tweaks something.

Also move the unaligned.h header while touching this since it was the
only one not in alphabetical order.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250417-iio-more-timestamp-alignment-v1-3-eafac1e22318@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: mt6360-adc: use aligned_s64 for timestamp
David Lechner [Thu, 17 Apr 2025 16:52:34 +0000 (11:52 -0500)]
iio: adc: mt6360-adc: use aligned_s64 for timestamp

Follow the pattern of other drivers and use aligned_s64 for the
timestamp. This will ensure that the timestamp is correctly aligned on
all architectures. It also ensures that the struct itself it also 8-byte
aligned so we can drop the explicit __aligned(8) attribute.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250417-iio-more-timestamp-alignment-v1-2-eafac1e22318@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: magnetometer: Use iio_push_to_buffers_with_ts() to provide length for runtime...
Jonathan Cameron [Sun, 13 Apr 2025 10:34:43 +0000 (11:34 +0100)]
iio: magnetometer: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.

This new function allows us to perform debug checks in the helper to ensure
that the overrun does not occur.  Use it in all the simple cases where
either a static buffer or a structure is used in the drivers.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250413103443.2420727-21-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: pressure: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.
Jonathan Cameron [Sun, 13 Apr 2025 10:34:42 +0000 (11:34 +0100)]
iio: pressure: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.

This new function allows us to perform debug checks in the helper to ensure
that the overrun does not occur.  Use it in all the simple cases where
either a static buffer or a structure is used in the drivers.

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com> # ROHM BM1390
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250413103443.2420727-20-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: pressure: zpa2326: Use aligned_s64 for the timestamp
Jonathan Cameron [Sun, 13 Apr 2025 10:34:41 +0000 (11:34 +0100)]
iio: pressure: zpa2326: Use aligned_s64 for the timestamp

On x86_32 s64 fields are only 32-bit aligned.  Hence force the alignment of
the field and padding in the structure by using aligned_s64 instead.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250413103443.2420727-19-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: proximity: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.
Jonathan Cameron [Sun, 13 Apr 2025 10:34:40 +0000 (11:34 +0100)]
iio: proximity: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.

This new function allows us to perform debug checks in the helper to ensure
that the overrun does not occur. Use it in all the simple cases where
either a static buffer or a structure is used in the drivers.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250413103443.2420727-18-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: proximity: irsd200: Use a struct for scan and iio_push_to_buffers_with_ts()
Jonathan Cameron [Sun, 13 Apr 2025 10:34:39 +0000 (11:34 +0100)]
iio: proximity: irsd200: Use a struct for scan and iio_push_to_buffers_with_ts()

The driver previously used an array of two s64, then type cast the
pointer to write an s16 to the start. The code is made more readable
using a structure.  At the same time switch to the new
iio_push_to_buffers_with_ts() helper to enable runtime checking of the
size of the source buffer.

Note that this approach uses a structure with holes, so use memset()
to ensure those do not contain old kernel data as this data is passed
to userspace.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250413103443.2420727-17-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: resolver: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.
Jonathan Cameron [Sun, 13 Apr 2025 10:34:38 +0000 (11:34 +0100)]
iio: resolver: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.

This new function allows us to perform debug checks in the helper to ensure
that the overrun does not occur.  Use it in all the simple cases where
either a static buffer or a structure is used in the drivers.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250413103443.2420727-16-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: temperature: Use iio_push_to_buffers_with_ts() to provide length for runtime...
Jonathan Cameron [Sun, 13 Apr 2025 10:34:37 +0000 (11:34 +0100)]
iio: temperature: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.

This new function allows us to perform debug checks in the helper to ensure
that the overrun does not occur.  Use it in all the simple cases where
either a static buffer or a structure is used in the drivers.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250413103443.2420727-15-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: chemical: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.
Jonathan Cameron [Sun, 13 Apr 2025 10:34:35 +0000 (11:34 +0100)]
iio: chemical: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.

This new function allows us to perform debug checks in the helper to ensure
that the overrun does not occur.  Use it in all the simple cases where
either a static buffer or a structure is used in the drivers.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250413103443.2420727-13-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: accel: hid: Use iio_push_to_buffers_with_ts() to provide length for runtime...
Jonathan Cameron [Sun, 13 Apr 2025 10:34:34 +0000 (11:34 +0100)]
iio: accel: hid: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.

This new function allows us to perform debug checks in the helper to ensure
that the overrun does not occur. For this case, the length being provided
is already passed into the caller function so reuse that.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250413103443.2420727-12-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: accel: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.
Jonathan Cameron [Sun, 13 Apr 2025 10:34:33 +0000 (11:34 +0100)]
iio: accel: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.

This new function allows us to perform debug checks in the helper to ensure
that the overrun does not occur.  Use it in all the simple cases where
either a static buffer or a structure is used in the drivers.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250413103443.2420727-11-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.
Jonathan Cameron [Sun, 13 Apr 2025 10:34:32 +0000 (11:34 +0100)]
iio: adc: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.

This new function allows us to perform debug checks in the helper to ensure
that the overrun does not occur.  Use it in all the simple cases where
either a static buffer or a structure is used in the drivers.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250413103443.2420727-10-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: adc: ti-ads131e08: Use new iio_push_to_buffers_with_ts() to provide length sanit...
Jonathan Cameron [Sun, 13 Apr 2025 10:34:31 +0000 (11:34 +0100)]
iio: adc: ti-ads131e08: Use new iio_push_to_buffers_with_ts() to provide length sanity check.

By providing the size of the buffer used, runtime checks can be performed
to ensure not overrun.

Also change the pushed data pointer to be that of the structure that also
contains the timestamp.  Not an actual bug but semantically incorrect to
push the channel data when we want the storage with the timestamp as well.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250413103443.2420727-9-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: dummy: Switch to iio_push_to_buffers_with_ts() and provide size of storage
Jonathan Cameron [Sun, 13 Apr 2025 10:34:30 +0000 (11:34 +0100)]
iio: dummy: Switch to iio_push_to_buffers_with_ts() and provide size of storage

Provide the storage size so that the helper can sanity check that it
is large enough for the configured channels.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250413103443.2420727-8-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: dummy: Use a fixed structure to build up scan to push to buffers.
Jonathan Cameron [Sun, 13 Apr 2025 10:34:29 +0000 (11:34 +0100)]
iio: dummy: Use a fixed structure to build up scan to push to buffers.

It has long been discouraged for drivers to make use of iio_dev->scan_bytes
directly as that is an implementation detail of the core. As such our
example driver should definitely not be doing so.

In order to illustrate the more complex case, where a DMA safe buffer is
needed, continue to kzalloc() the storage (but with a structure definition
to provide an explicit data layout). Also add comments on when a DMA safe
buffer is necessary and the two common ways of obtaining one.

Whilst we have a mixture of signed and unsigned channels, the unsigned
channels have ranges that can be stored in a signed value - hence
use signed storage for all channels, simplifying the structure definition.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250413103443.2420727-7-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoiio: introduced iio_push_to_buffers_with_ts() that takes a data_total_len argument.
Jonathan Cameron [Sun, 13 Apr 2025 10:34:28 +0000 (11:34 +0100)]
iio: introduced iio_push_to_buffers_with_ts() that takes a data_total_len argument.

Check that data_total_len argument against iio_dev->scan_bytes.

The size needs to be at least as big as the scan. It can be larger,
which is typical if only part of fixed sized storage is used due to
a subset of channels being enabled.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250413103443.2420727-6-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agodocs: iio: ad3552r: fix malformed table
Angelo Dureghello [Tue, 15 Apr 2025 07:44:12 +0000 (09:44 +0200)]
docs: iio: ad3552r: fix malformed table

Fix malformed table.

Fixes: ede84c455659 ("docs: iio: add documentation for ad3552r driver")
Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250415-wip-bl-ad3552r-fix-doc-table-v1-1-717ffd320c9d@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 weeks agoirqdomain: spmi: Switch to irq_domain_create_tree()
Jiri Slaby (SUSE) [Sun, 18 May 2025 03:23:29 +0000 (20:23 -0700)]
irqdomain: spmi: Switch to irq_domain_create_tree()

irq_domain_add_tree() is going away as being obsolete now. Switch to
the preferred irq_domain_create_tree(). That differs in the first
parameter: It takes more generic struct fwnode_handle instead of struct
device_node. Therefore, of_fwnode_handle() is added around the
parameter.

Note some of the users can likely use dev->fwnode directly instead of
indirect of_fwnode_handle(dev->of_node). But dev->fwnode is not
guaranteed to be set for all, so this has to be investigated on case to
case basis (by people who can actually test with the HW).

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20250319092951.37667-37-jirislaby@kernel.org
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20250518032330.2959766-5-sboyd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 weeks agospmi: add a spmi driver for Apple SoC
Jean-Francois Bortolotti [Sun, 18 May 2025 03:23:28 +0000 (20:23 -0700)]
spmi: add a spmi driver for Apple SoC

The connected PMU contains several useful nvmem cells such as RTC offset,
boot failure counters, reboot/shutdown selector, and a few others.
In addition M3+ machines have their USB-PD controller connected via SPMI.

Signed-off-by: Jean-Francois Bortolotti <jeff@borto.fr>
Reviewed-by: Sven Peter <sven@svenpeter.dev>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Co-developed-by: Sasha Finkelstein <fnkl.kernel@gmail.com>
Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com>
Link: https://lore.kernel.org/r/20250409-spmi-v4-2-eb81ecfd1f64@gmail.com
Reviewed-by: Neal Gompa <neal@gompa.dev>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20250518032330.2959766-4-sboyd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 weeks agodt-bindings: spmi: Add Apple SPMI controller
Sasha Finkelstein [Sun, 18 May 2025 03:23:27 +0000 (20:23 -0700)]
dt-bindings: spmi: Add Apple SPMI controller

Add bindings for the SPMI controller present on most Apple SoCs

Reviewed-by: "Rob Herring (Arm)" <robh@kernel.org>
Reviewed-by: Sven Peter <sven@svenpeter.dev>
Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com>
Link: https://lore.kernel.org/r/20250409-spmi-v4-1-eb81ecfd1f64@gmail.com
Reviewed-by: Neal Gompa <neal@gompa.dev>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20250518032330.2959766-3-sboyd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 weeks agospmi: Only use Hikey 970 SPMI controller driver when ARM64
WangYuli [Sun, 18 May 2025 03:23:26 +0000 (20:23 -0700)]
spmi: Only use Hikey 970 SPMI controller driver when ARM64

SPMI_HISI3670, the Hikey 970 SPMI controller driver, is only
required to use the Kirin 970 SPMI bus.

And the Kirin 970 is an ARM64-based SoC, it cannot be used on
platforms of other architectures.

Link: https://lore.kernel.org/all/b4810f476e41e7de4efdf28b42472ae4ffe7defe.1597647359.git.mchehab+huawei@kernel.org/
Reported-by: Wentao Guan <guanwentao@uniontech.com>
Closes: https://github.com/deepin-community/kernel/pull/604
Signed-off-by: WangYuli <wangyuli@uniontech.com>
Link: https://lore.kernel.org/r/23BAA675A75EF4F5+20250218050552.57711-1-wangyuli@uniontech.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20250518032330.2959766-2-sboyd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 weeks agohpet: Remove unnecessary NULL check before unregister_sysctl_table()
Chen Ni [Wed, 14 May 2025 03:26:37 +0000 (11:26 +0800)]
hpet: Remove unnecessary NULL check before unregister_sysctl_table()

unregister_sysctl_table() checks for NULL pointers internally.
Remove unneeded NULL check here.

Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Link: https://lore.kernel.org/r/20250514032637.2317639-1-nichen@iscas.ac.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 weeks agoVMCI: fix race between vmci_host_setup_notify and vmci_ctx_unset_notify
Wupeng Ma [Sat, 10 May 2025 03:30:40 +0000 (11:30 +0800)]
VMCI: fix race between vmci_host_setup_notify and vmci_ctx_unset_notify

During our test, it is found that a warning can be trigger in try_grab_folio
as follow:

  ------------[ cut here ]------------
  WARNING: CPU: 0 PID: 1678 at mm/gup.c:147 try_grab_folio+0x106/0x130
  Modules linked in:
  CPU: 0 UID: 0 PID: 1678 Comm: syz.3.31 Not tainted 6.15.0-rc5 #163 PREEMPT(undef)
  RIP: 0010:try_grab_folio+0x106/0x130
  Call Trace:
   <TASK>
   follow_huge_pmd+0x240/0x8e0
   follow_pmd_mask.constprop.0.isra.0+0x40b/0x5c0
   follow_pud_mask.constprop.0.isra.0+0x14a/0x170
   follow_page_mask+0x1c2/0x1f0
   __get_user_pages+0x176/0x950
   __gup_longterm_locked+0x15b/0x1060
   ? gup_fast+0x120/0x1f0
   gup_fast_fallback+0x17e/0x230
   get_user_pages_fast+0x5f/0x80
   vmci_host_unlocked_ioctl+0x21c/0xf80
  RIP: 0033:0x54d2cd
  ---[ end trace 0000000000000000 ]---

Digging into the source, context->notify_page may init by get_user_pages_fast
and can be seen in vmci_ctx_unset_notify which will try to put_page. However
get_user_pages_fast is not finished here and lead to following
try_grab_folio warning. The race condition is shown as follow:

cpu0 cpu1
vmci_host_do_set_notify
vmci_host_setup_notify
get_user_pages_fast(uva, 1, FOLL_WRITE, &context->notify_page);
lockless_pages_from_mm
gup_pgd_range
gup_huge_pmd  // update &context->notify_page
vmci_host_do_set_notify
vmci_ctx_unset_notify
notify_page = context->notify_page;
if (notify_page)
put_page(notify_page); // page is freed
__gup_longterm_locked
__get_user_pages
follow_trans_huge_pmd
try_grab_folio // warn here

To slove this, use local variable page to make notify_page can be seen
after finish get_user_pages_fast.

Fixes: a1d88436d53a ("VMCI: Fix two UVA mapping bugs")
Cc: stable <stable@kernel.org>
Closes: https://lore.kernel.org/all/e91da589-ad57-3969-d979-879bbd10dddd@huawei.com/
Signed-off-by: Wupeng Ma <mawupeng1@huawei.com>
Link: https://lore.kernel.org/r/20250510033040.901582-1-mawupeng1@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>