mirror-linux/include/linux/iio
Jonathan Cameron d795e38df4 iio: core: Rework claim and release of direct mode to work with sparse.
Initial thought was to do something similar to __cond_lock()

	do_iio_device_claim_direct_mode(iio_dev) ? : ({ __acquire(iio_dev); 0; })
+ Appropriate static inline iio_device_release_direct_mode()

However with that, sparse generates false positives. E.g.

drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c:1811:17: warning: context imbalance in 'st_lsm6dsx_read_raw' - unexpected unlock

So instead, this patch rethinks the return type and makes it more
'conditional lock like' (which is part of what is going on under the hood
anyway) and return a boolean - true for successfully acquired, false for
did not acquire.

To allow a migration path given the rework is now non trivial, take a leaf
out of the naming of the conditional guard we currently have for IIO
device direct mode and drop the _mode postfix from the new functions giving
iio_device_claim_direct() and iio_device_release_direct()

Whilst the kernel supports __cond_acquires() upstream sparse does not
yet do so.  Hence rely on sparse expanding a static inline wrapper
to explicitly see whether __acquire() is called.

Note that even with the solution here, sparse sometimes gives false
positives. However in the few cases seen they were complex code
structures that benefited from simplification anyway.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250209180624.701140-2-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-02-17 12:57:13 +00:00
..
accel
adc iio: adc: ad7173: move fwnode_irq_get_byname() call site 2025-02-03 19:15:37 +00:00
afe
common iio: invensense: fix timestamp glitches when switching frequency 2024-05-03 11:48:56 +01:00
dac
frequency
gyro
imu iio: imu: adis: Remove documented not used elements 2024-12-07 17:49:11 +00:00
timer iio: trigger: stm32-timer: add support for stm32mp25 2024-12-28 14:28:14 +00:00
backend.h iio: backend: add API for oversampling 2025-02-16 15:12:11 +00:00
buffer-dma.h iio: buffer-dma: Enable support for DMABUFs 2024-06-30 11:29:24 +01:00
buffer-dmaengine.h iio: buffer-dmaengine: add devm_iio_dmaengine_buffer_setup_with_handle() 2025-02-10 18:47:49 +00:00
buffer.h iio: core: mark scan_timestamp as __private 2024-12-28 14:28:14 +00:00
buffer_impl.h iio: core: Add new DMABUF interface infrastructure 2024-06-30 11:29:17 +01:00
configfs.h
consumer.h iio: consumers: ensure read buffers for labels and ext_info are page aligned 2024-12-11 19:20:49 +00:00
driver.h iio: adc: Constify struct iio_map 2024-09-30 09:21:02 +01:00
events.h iio: events: make IIO_EVENT_CODE macro private 2024-11-03 20:33:45 +00:00
hw-consumer.h
iio-gts-helper.h iio: gts-helper: export iio_gts_get_total_gain() 2025-02-08 15:16:29 +00:00
iio-opaque.h iio: core: fix doc reference to iio_push_to_buffers_with_ts_unaligned 2024-12-07 17:52:44 +00:00
iio.h iio: core: Rework claim and release of direct mode to work with sparse. 2025-02-17 12:57:13 +00:00
kfifo_buf.h
machine.h
sw_device.h iio: Remove unused declarations 2023-09-12 10:42:03 +01:00
sw_trigger.h iio: Remove unused declarations 2023-09-12 10:42:03 +01:00
sysfs.h
trigger.h iio: trigger: Add simple trigger_validation helper 2023-05-23 21:20:17 +01:00
trigger_consumer.h
triggered_buffer.h
triggered_event.h
types.h iio: core: introduce trough info element for minimum values 2023-12-11 19:37:10 +00:00