mirror-linux/include
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
..
acpi LoongArch changes for v6.14 2025-01-28 08:52:01 -08:00
asm-generic The various patchsets are summarized below. Plus of course many 2025-01-26 18:36:23 -08:00
clocksource KVM/arm64 updates for 6.14 2025-01-28 09:01:36 -08:00
crypto
cxl
drm
dt-bindings dt-bindings: iio: adc: adi,ad4695: add SPI offload properties 2025-02-11 19:32:31 +00:00
hyperv
keys
kunit
kvm
linux iio: core: Rework claim and release of direct mode to work with sparse. 2025-02-17 12:57:13 +00:00
math-emu
media
memory
misc
net ipsec-2025-01-27 2025-01-27 15:15:12 -08:00
pcmcia
ras
rdma
rv
scsi Driver core and debugfs updates 2025-01-28 12:25:12 -08:00
soc
sound
target
trace f2fs-for-6.14-rc1 2025-01-27 20:58:58 -08:00
uapi iio: introduce the FAULT event type 2025-02-08 15:16:29 +00:00
ufs
vdso
video
xen