linux-stable/drivers/iio/proximity
Julien Stephan b4b42f28a0 iio: fix write_event_config signature
write_event_config callback use an int for state, but it is actually a
boolean. iio_ev_state_store is actually using kstrtobool to check user
input, then gives the converted boolean value to write_event_config.

Fix signature and update all iio drivers to use the new signature.

This patch has been partially written using coccinelle with the
following script:

$ cat iio-bool.cocci
// Options: --all-includes

virtual patch

@c1@
identifier iioinfo;
identifier wecfunc;
@@
 static const struct iio_info iioinfo = {
        ...,
        .write_event_config =
(
 wecfunc
|
 &wecfunc
),
        ...,
 };

@@
identifier c1.wecfunc;
identifier indio_dev, chan, type, dir, state;
@@
 int wecfunc(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir,
-int
+bool
 state) {
  ...
 }

make coccicheck MODE=patch COCCI=iio-bool.cocci M=drivers/iio

Unfortunately, this script didn't match all files:
* all write_event_config callbacks using iio_device_claim_direct_scoped
  were not detected and not patched.
* all files that do not assign and declare the write_event_config
  callback in the same file.

iio.h was also manually updated.

The patch was build tested using allmodconfig config.

cc: Julia Lawall <julia.lawall@inria.fr>
Signed-off-by: Julien Stephan <jstephan@baylibre.com>
Link: https://patch.msgid.link/20241031-iio-fix-write-event-config-signature-v2-7-2bcacbb517a2@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-03 20:33:44 +00:00
..
as3935.c iio: Rename iio_trigger_poll_chained and add kernel-doc 2023-03-11 12:18:29 +00:00
aw96103.c iio: fix write_event_config signature 2024-11-03 20:33:44 +00:00
cros_ec_mkbp_proximity.c iio: fix write_event_config signature 2024-11-03 20:33:44 +00:00
hx9023s.c iio: fix write_event_config signature 2024-11-03 20:33:44 +00:00
irsd200.c iio: fix write_event_config signature 2024-11-03 20:33:44 +00:00
isl29501.c iio: Drop explicit initialization of struct i2c_device_id::driver_data to 0 2024-05-27 09:48:57 +01:00
Kconfig iio: proximity: mb1232: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig 2024-10-06 16:30:15 +01:00
Makefile iio: proximity: aw96103: Add support for aw96103/aw96105 proximity sensor 2024-09-05 19:27:06 +01:00
mb1232.c iio: mb1232: relax return value check for IRQ get 2023-08-01 18:55:46 +01:00
ping.c iio: proximity: ping: fix typo in comment 2022-06-11 14:35:27 +01:00
pulsedlight-lidar-lite-v2.c iio: Drop explicit initialization of struct i2c_device_id::driver_data to 0 2024-05-27 09:48:57 +01:00
rfd77402.c iio: Drop explicit initialization of struct i2c_device_id::driver_data to 0 2024-05-27 09:48:57 +01:00
srf04.c iio: Switch back to struct platform_driver::remove() 2024-10-10 19:31:50 +01:00
srf08.c iio: Switch i2c drivers back to use .probe() 2023-05-21 18:54:53 +01:00
sx9310.c iio: proximity: sx9310: Use automated cleanup for locks and IIO mode claiming. 2024-02-17 16:16:11 +00:00
sx9324.c iio: proximity: sx_common: Unexport sx_common_get_raw_register_config() 2024-09-30 09:20:59 +01:00
sx9360.c iio: proximity: sx_common: Drop unused acpi.h 2024-09-30 09:20:59 +01:00
sx9500.c iio: fix write_event_config signature 2024-11-03 20:33:44 +00:00
sx_common.c iio: fix write_event_config signature 2024-11-03 20:33:44 +00:00
sx_common.h iio: fix write_event_config signature 2024-11-03 20:33:44 +00:00
vcnl3020.c iio: fix write_event_config signature 2024-11-03 20:33:44 +00:00
vl53l0x-i2c.c Linux 6.12-rc2 2024-10-12 11:43:29 +01:00