iio: fix write_event_config signature
Subsystems (21)
cover iio: fix write_event_config signature
Hello,
This series update the write_event_config callback signature to use a boolean instead of an int for state variable. iio_ev_state_store is actually using kstrtobool to check user input, then gives the converted boolean value to write_event_config.
First, fix the write_event_config callbacks from iio drivers that are checking state input, or that are converting state to bool. This is useless code, then update 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.
---
Julien Stephan (7):
iio: light: bh1745: simplify code in write_event_config callback
iio: light: ltr390: simplify code in write_event_config callback
iio: light: ltr501: simplify code in write_event_config callback
iio: light: veml6030: simplify code in write_event_config callback
iio: imu: inv_mpu6050: simplify code in write_event_config callback
iio: light: stk3310: simplify code in write_event_config callback
iio: fix write_event_config signature
drivers/iio/accel/adxl367.c | 2 +- drivers/iio/accel/adxl372.c | 2 +- drivers/iio/accel/adxl380.c | 2 +- drivers/iio/accel/bma400_core.c | 2 +- drivers/iio/accel/bmc150-accel-core.c | 2 +- drivers/iio/accel/fxls8962af-core.c | 2 +- drivers/iio/accel/kxcjk-1013.c | 2 +- drivers/iio/accel/mma8452.c | 2 +- drivers/iio/accel/mma9551.c | 2 +- drivers/iio/accel/mma9553.c | 3 +- drivers/iio/accel/sca3000.c | 2 +- drivers/iio/adc/ad7091r-base.c | 3 +- drivers/iio/adc/ad7291.c | 2 +- drivers/iio/adc/ad799x.c | 2 +- drivers/iio/adc/hi8435.c | 2 +- drivers/iio/adc/max1363.c | 2 +- drivers/iio/adc/pac1921.c | 3 +- drivers/iio/adc/palmas_gpadc.c | 2 +- drivers/iio/adc/ti-ads1015.c | 2 +- drivers/iio/adc/xilinx-ams.c | 2 +- drivers/iio/adc/xilinx-xadc-events.c | 2 +- drivers/iio/adc/xilinx-xadc.h | 2 +- drivers/iio/cdc/ad7150.c | 2 +- drivers/iio/dac/ad5421.c | 2 +- drivers/iio/dac/ad8460.c | 2 +- drivers/iio/dummy/iio_simple_dummy.h | 2 +- drivers/iio/dummy/iio_simple_dummy_events.c | 2 +- drivers/iio/gyro/bmg160_core.c | 2 +- drivers/iio/imu/bmi323/bmi323_core.c | 2 +- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 9 ++--- drivers/iio/imu/kmx61.c | 2 +- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 2 +- drivers/iio/light/adux1020.c | 3 +- drivers/iio/light/apds9300.c | 2 +- drivers/iio/light/apds9306.c | 2 +- drivers/iio/light/apds9960.c | 4 +-- drivers/iio/light/bh1745.c | 50 ++++++++++++-------------- drivers/iio/light/cm36651.c | 2 +- drivers/iio/light/gp2ap002.c | 2 +- drivers/iio/light/gp2ap020a00f.c | 2 +- drivers/iio/light/iqs621-als.c | 2 +- drivers/iio/light/ltr390.c | 5 +-- drivers/iio/light/ltr501.c | 6 +--- drivers/iio/light/max44009.c | 2 +- drivers/iio/light/opt3001.c | 2 +- drivers/iio/light/stk3310.c | 5 +-- drivers/iio/light/tcs3472.c | 2 +- drivers/iio/light/tsl2563.c | 2 +- drivers/iio/light/tsl2591.c | 2 +- drivers/iio/light/tsl2772.c | 2 +- drivers/iio/light/us5182d.c | 2 +- drivers/iio/light/vcnl4000.c | 5 +-- drivers/iio/light/veml6030.c | 5 +-- drivers/iio/position/iqs624-pos.c | 2 +- drivers/iio/proximity/aw96103.c | 2 +- drivers/iio/proximity/cros_ec_mkbp_proximity.c | 2 +- drivers/iio/proximity/hx9023s.c | 2 +- drivers/iio/proximity/irsd200.c | 3 +- drivers/iio/proximity/sx9500.c | 2 +- drivers/iio/proximity/sx_common.c | 2 +- drivers/iio/proximity/sx_common.h | 2 +- drivers/iio/proximity/vcnl3020.c | 2 +- drivers/iio/temperature/mcp9600.c | 2 +- drivers/iio/temperature/tmp007.c | 2 +- include/linux/iio/iio.h | 2 +- 65 files changed, 96 insertions(+), 112 deletions(-)
---
base-commit: 9090ececac9ff1e22fb7e042f3c886990a8fb090
change-id: 20241023-iio-fix-write-event-config-signature-1bc1f52fdedf
Best regards,
Signature · 1 line
Julien Stephan <[email protected]>
PATCH 1/7 iio: light: bh1745: simplify code in write_event_config callback
iio_ev_state_store is actually using kstrtobool to check user input, then gives the converted boolean value to the write_event_config callback.
Remove useless code in write_event_config callback.
--- drivers/iio/light/bh1745.c | 48 +++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 26 deletions(-)
drivers/iio/light/bh1745.c +22 -26
@@ -643,41 +643,37 @@ static int bh1745_write_event_config(struct iio_dev *indio_dev,struct bh1745_data *data =iio_priv (indio_dev);int value; -if (state ==0 ) +if (!state)return regmap_clear_bits (data->regmap,BH1745_INTR ,BH1745_INTR_ENABLE ); -if (state ==1 ) { -/* Latch is always enabled when enabling interrupt */ - value =BH1745_INTR_ENABLE ; +/* Latch is always enabled when enabling interrupt */ + value =BH1745_INTR_ENABLE ; -switch (chan->channel2) { -case IIO_MOD_LIGHT_RED : -return regmap_write (data->regmap,BH1745_INTR , - value |FIELD_PREP (BH1745_INTR_SOURCE_MASK , -BH1745_INTR_SOURCE_RED )); +switch (chan->channel2) { +case IIO_MOD_LIGHT_RED : +return regmap_write (data->regmap,BH1745_INTR , + value |FIELD_PREP (BH1745_INTR_SOURCE_MASK , +BH1745_INTR_SOURCE_RED )); -case IIO_MOD_LIGHT_GREEN : -return regmap_write (data->regmap,BH1745_INTR , - value |FIELD_PREP (BH1745_INTR_SOURCE_MASK , -BH1745_INTR_SOURCE_GREEN )); +case IIO_MOD_LIGHT_GREEN : +return regmap_write (data->regmap,BH1745_INTR , + value |FIELD_PREP (BH1745_INTR_SOURCE_MASK , +BH1745_INTR_SOURCE_GREEN )); -case IIO_MOD_LIGHT_BLUE : -return regmap_write (data->regmap,BH1745_INTR , - value |FIELD_PREP (BH1745_INTR_SOURCE_MASK , -BH1745_INTR_SOURCE_BLUE )); +case IIO_MOD_LIGHT_BLUE : +return regmap_write (data->regmap,BH1745_INTR , + value |FIELD_PREP (BH1745_INTR_SOURCE_MASK , +BH1745_INTR_SOURCE_BLUE )); -case IIO_MOD_LIGHT_CLEAR : -return regmap_write (data->regmap,BH1745_INTR , - value |FIELD_PREP (BH1745_INTR_SOURCE_MASK , -BH1745_INTR_SOURCE_CLEAR )); +case IIO_MOD_LIGHT_CLEAR : +return regmap_write (data->regmap,BH1745_INTR , + value |FIELD_PREP (BH1745_INTR_SOURCE_MASK , +BH1745_INTR_SOURCE_CLEAR )); -default : -return -EINVAL ; - } +default : +return -EINVAL ; } - -return -EINVAL ; } static int bh1745_read_avail(struct iio_dev *indio_dev,
Signature · 1 line
2.47.0
Jonathan Cameron
maintainerRe: [PATCH 1/7] iio: light: bh1745: simplify code in write_event_config callback
Quoted 7 lines · On Thu, 24 Oct 2024 11:11:23 +0200 Julien Stephan <[email protected]> wrote:
iio_ev_state_storeis actually using kstrtobool to check user input, then gives the converted boolean value to thewrite_event_configcallback.Remove useless code in
write_event_configcallback.Signed-off-by Julien Stephan <[email protected]>
There are a few additions needed to the final patch. I'll pick up the earlier ones now though.
Applied this one.
Quoted 73 lines
--- drivers/iio/light/bh1745.c | 48 +++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 26 deletions(-)drivers/iio/light/bh1745.c +22
-26@@ -643,41 +643,37 @@ static int bh1745_write_event_config(struct iio_dev *indio_dev,struct bh1745_data *data =iio_priv (indio_dev);int value; -if (state ==0 ) +if (!state)return regmap_clear_bits (data->regmap,BH1745_INTR ,BH1745_INTR_ENABLE ); -if (state ==1 ) { -/* Latch is always enabled when enabling interrupt */ - value =BH1745_INTR_ENABLE ; +/* Latch is always enabled when enabling interrupt */ + value =BH1745_INTR_ENABLE ; -switch (chan->channel2) { -case IIO_MOD_LIGHT_RED : -return regmap_write (data->regmap,BH1745_INTR , - value |FIELD_PREP (BH1745_INTR_SOURCE_MASK , -BH1745_INTR_SOURCE_RED )); +switch (chan->channel2) { +case IIO_MOD_LIGHT_RED : +return regmap_write (data->regmap,BH1745_INTR , + value |FIELD_PREP (BH1745_INTR_SOURCE_MASK , +BH1745_INTR_SOURCE_RED )); -case IIO_MOD_LIGHT_GREEN : -return regmap_write (data->regmap,BH1745_INTR , - value |FIELD_PREP (BH1745_INTR_SOURCE_MASK , -BH1745_INTR_SOURCE_GREEN )); +case IIO_MOD_LIGHT_GREEN : +return regmap_write (data->regmap,BH1745_INTR , + value |FIELD_PREP (BH1745_INTR_SOURCE_MASK , +BH1745_INTR_SOURCE_GREEN )); -case IIO_MOD_LIGHT_BLUE : -return regmap_write (data->regmap,BH1745_INTR , - value |FIELD_PREP (BH1745_INTR_SOURCE_MASK , -BH1745_INTR_SOURCE_BLUE )); +case IIO_MOD_LIGHT_BLUE : +return regmap_write (data->regmap,BH1745_INTR , + value |FIELD_PREP (BH1745_INTR_SOURCE_MASK , +BH1745_INTR_SOURCE_BLUE )); -case IIO_MOD_LIGHT_CLEAR : -return regmap_write (data->regmap,BH1745_INTR , - value |FIELD_PREP (BH1745_INTR_SOURCE_MASK , -BH1745_INTR_SOURCE_CLEAR )); +case IIO_MOD_LIGHT_CLEAR : +return regmap_write (data->regmap,BH1745_INTR , + value |FIELD_PREP (BH1745_INTR_SOURCE_MASK , +BH1745_INTR_SOURCE_CLEAR )); -default : -return -EINVAL ; - } +default : +return -EINVAL ; } - -return -EINVAL ; } static int bh1745_read_avail(struct iio_dev *indio_dev,
PATCH 2/7 iio: light: ltr390: simplify code in write_event_config callback
In reply to Julien Stephaniio_ev_state_store is actually using kstrtobool to check user input, then gives the converted boolean value to the write_event_config callback.
Remove useless code in write_event_config callback.
--- drivers/iio/light/ltr390.c | 3 --- 1 file changed, 3 deletions(-)
drivers/iio/light/ltr390.c +0 -3
@@ -558,9 +558,6 @@ static int ltr390_write_event_config(struct iio_dev *indio_dev,struct ltr390_data *data =iio_priv (indio_dev);int ret; -if (state !=1 && state !=0 ) -return -EINVAL ; -if (state ==0 )return regmap_clear_bits (data->regmap,LTR390_INT_CFG ,LTR390_LS_INT_EN );
Signature · 1 line
2.47.0
Jonathan Cameron
maintainerRe: [PATCH 2/7] iio: light: ltr390: simplify code in write_event_config callback
Quoted 16 lines · On Thu, 24 Oct 2024 11:11:24 +0200 Julien Stephan <[email protected]> wrote:
iio_ev_state_storeis actually using kstrtobool to check user input, then gives the converted boolean value to thewrite_event_configcallback.Remove useless code in
write_event_configcallback.Signed-off-by Julien Stephan <[email protected]>--- drivers/iio/light/ltr390.c | 3 --- 1 file changed, 3 deletions(-)drivers/iio/light/ltr390.c +0
-0
drivers/iio/light/ltr390.c static int ltr390_write_event_config(struct iio_dev *indio_dev, · line 561
Quoted 7 lines
drivers/iio/light/ltr390.c +0
-3@@ -558,9 +558,6 @@ static int ltr390_write_event_config(struct iio_dev *indio_dev,struct ltr390_data *data =iio_priv (indio_dev);int ret; -if (state !=1 && state !=0 ) -return -EINVAL ; -if (state ==0 )
Once you apply the final patch, the == 0 here will make less sense. Can tidy that up here or in that final patch by just making this if (!state) etc
Quoted 3 lines
drivers/iio/light/ltr390.c +0
-0return regmap_clear_bits (data->regmap,LTR390_INT_CFG ,LTR390_LS_INT_EN );
PATCH 3/7 iio: light: ltr501: simplify code in write_event_config callback
In reply to Julien Stephaniio_ev_state_store is actually using kstrtobool to check user input, then gives the converted boolean value to the write_event_config callback.
Remove useless code in write_event_config callback.
--- drivers/iio/light/ltr501.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/iio/light/ltr501.c +0 -4
@@ -1083,10 +1083,6 @@ static int ltr501_write_event_config(struct iio_dev *indio_dev,struct ltr501_data *data =iio_priv (indio_dev);int ret; -/* only 1 and 0 are valid inputs */ -if (state !=1 && state !=0 ) -return -EINVAL ; -switch (chan->type) {case IIO_INTENSITY :mutex_lock (&data->lock_als);
Signature · 1 line
2.47.0
Re: [PATCH 3/7] iio: light: ltr501: simplify code in write_event_config callback
Quoted 7 lines · On Thu, 24 Oct 2024 11:11:25 +0200 Julien Stephan <[email protected]> wrote:
iio_ev_state_storeis actually using kstrtobool to check user input, then gives the converted boolean value to thewrite_event_configcallback.Remove useless code in
write_event_configcallback.Signed-off-by Julien Stephan <[email protected]>
Applied.
PATCH 4/7 iio: light: veml6030: simplify code in write_event_config callback
In reply to Julien Stephaniio_ev_state_store is actually using kstrtobool to check user input, then gives the converted boolean value to the write_event_config callback.
Remove useless code in write_event_config callback.
--- drivers/iio/light/veml6030.c | 3 --- 1 file changed, 3 deletions(-)
drivers/iio/light/veml6030.c +0 -3
@@ -826,9 +826,6 @@ static int veml6030_write_interrupt_config(struct iio_dev *indio_dev,int ret;struct veml6030_data *data =iio_priv (indio_dev); -if (state <0 || state >1 ) -return -EINVAL ; - ret =veml6030_als_shut_down (data);if (ret <0 ) { dev_err(&data->client->dev,
Signature · 1 line
2.47.0
Re: [PATCH 4/7] iio: light: veml6030: simplify code in write_event_config callback
Quoted 7 lines · On Thu, 24 Oct 2024 11:11:26 +0200 Julien Stephan <[email protected]> wrote:
iio_ev_state_storeis actually using kstrtobool to check user input, then gives the converted boolean value to thewrite_event_configcallback.Remove useless code in
write_event_configcallback.Signed-off-by Julien Stephan <[email protected]>
Applied.
After patch 7 this will include a shift of a bool which is a little unusual but valid C.
Quoted 19 lines
--- drivers/iio/light/veml6030.c | 3 --- 1 file changed, 3 deletions(-)drivers/iio/light/veml6030.c +0
-3@@ -826,9 +826,6 @@ static int veml6030_write_interrupt_config(struct iio_dev *indio_dev,int ret;struct veml6030_data *data =iio_priv (indio_dev); -if (state <0 || state >1 ) -return -EINVAL ; - ret =veml6030_als_shut_down (data);if (ret <0 ) { dev_err(&data->client->dev,
PATCH 5/7 iio: imu: inv_mpu6050: simplify code in write_event_config callback
In reply to Julien Stephaniio_ev_state_store is actually using kstrtobool to check user input, then gives the converted boolean value to the write_event_config callback.
Remove useless code in write_event_config callback.
--- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 7 ++----- drivers/iio/light/apds9960.c | 2 -- 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +2 -5
@@ -1176,21 +1176,18 @@ static int inv_mpu6050_write_event_config(struct iio_dev *indio_dev, int state) {struct inv_mpu6050_state *st =iio_priv (indio_dev); -int enable;/* support only WoM (accel roc rising) event */ if (chan->type !=IIO_ACCEL || type !=IIO_EV_TYPE_ROC || dir !=IIO_EV_DIR_RISING )return -EINVAL ; - enable = !!state; -guard (mutex)(&st->lock); -if (st->chip_config.wom_en == enable) +if (st->chip_config.wom_en == state)return 0 ; -return inv_mpu6050_enable_wom (st, enable); +return inv_mpu6050_enable_wom (st, state); } static int inv_mpu6050_read_event_value(struct iio_dev *indio_dev,
drivers/iio/light/apds9960.c +0 -2
@@ -762,8 +762,6 @@ static int apds9960_write_event_config(struct iio_dev *indio_dev,struct apds9960_data *data =iio_priv (indio_dev);int ret; - state = !!state; -switch (chan->type) {case IIO_PROXIMITY :if (data->pxs_int == state)
Signature · 1 line
2.47.0
Re: [PATCH 5/7] iio: imu: inv_mpu6050: simplify code in write_event_config callback
Hello Julien,
good thing to know, thanks for the patch.
Best regards,
JB
________________________________________
From: Julien Stephan <[email protected]>
Sent: Thursday, October 24, 2024 11:11
To: Mudit Sharma <[email protected]>; Jonathan Cameron <[email protected]>; Lars-Peter Clausen <[email protected]>; Anshul Dalal <[email protected]>; Javier Carrasco <[email protected]>; Jean-Baptiste Maneyrol <[email protected]>; Michael Hennerich <[email protected]>; Cosmin Tanislav <[email protected]>; Ramona Gradinariu <[email protected]>; Antoniu Miclaus <[email protected]>; Dan Robertson <[email protected]>; Marcelo Schmitt <[email protected]>; Matteo Martelli <[email protected]>; Anand Ashok Dumbre <[email protected]>; Michal Simek <[email protected]>; Mariel Tinaco <[email protected]>; Jagath Jog J <[email protected]>; Lorenzo Bianconi <[email protected]>; Subhajit Ghosh <[email protected]>; Kevin Tsai <[email protected]>; Linus Walleij <[email protected]>; Benson Leung <[email protected]>; Guenter Roeck <[email protected]> Cc: [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Julien Stephan <[email protected]>
Subject: [PATCH 5/7] iio: imu: inv_mpu6050: simplify code in write_event_config callback
This Message Is From an External Sender
This message came from outside your organization.iio_ev_state_store is actually using kstrtobool to check user
input, then gives the converted boolean value to the write_event_config
callback.
Remove useless code in write_event_config callback.
--- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 7 ++----- drivers/iio/light/apds9960.c | 2 -- 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +2 -5
@@ -1176,21 +1176,18 @@ static int inv_mpu6050_write_event_config(struct iio_dev *indio_dev, int state) {struct inv_mpu6050_state *st =iio_priv (indio_dev); -int enable;/* support only WoM (accel roc rising) event */ if (chan->type !=IIO_ACCEL || type !=IIO_EV_TYPE_ROC || dir !=IIO_EV_DIR_RISING )return -EINVAL ; - enable = !!state; -guard (mutex)(&st->lock); -if (st->chip_config.wom_en == enable) +if (st->chip_config.wom_en == state)return 0 ; -return inv_mpu6050_enable_wom (st, enable); +return inv_mpu6050_enable_wom (st, state); } static int inv_mpu6050_read_event_value(struct iio_dev *indio_dev,
drivers/iio/light/apds9960.c +0 -2
@@ -762,8 +762,6 @@ static int apds9960_write_event_config(struct iio_dev *indio_dev,struct apds9960_data *data =iio_priv (indio_dev);int ret; - state = !!state; -switch (chan->type) {case IIO_PROXIMITY :if (data->pxs_int == state)
Signature · 1 line
2.47.0
Re: [PATCH 5/7] iio: imu: inv_mpu6050: simplify code in write_event_config callback
Quoted 5 lines · On Thu, 24 Oct 2024 12:16:42 +0000 Jean-Baptiste Maneyrol…
Hello Julien,
good thing to know, thanks for the patch.
Applied.
Quoted 68 lines
Best regards,
JB________________________________________
From: Julien Stephan <[email protected]>
Sent: Thursday, October 24, 2024 11:11
To: Mudit Sharma <[email protected]>; Jonathan Cameron <[email protected]>; Lars-Peter Clausen <[email protected]>; Anshul Dalal <[email protected]>; Javier Carrasco <[email protected]>; Jean-Baptiste Maneyrol <[email protected]>; Michael Hennerich <[email protected]>; Cosmin Tanislav <[email protected]>; Ramona Gradinariu <[email protected]>; Antoniu Miclaus <[email protected]>; Dan Robertson <[email protected]>; Marcelo Schmitt <[email protected]>; Matteo Martelli <[email protected]>; Anand Ashok Dumbre <[email protected]>; Michal Simek <[email protected]>; Mariel Tinaco <[email protected]>; Jagath Jog J <[email protected]>; Lorenzo Bianconi <[email protected]>; Subhajit Ghosh <[email protected]>; Kevin Tsai <[email protected]>; Linus Walleij <[email protected]>; Benson Leung <[email protected]>; Guenter Roeck <[email protected]> Cc: [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Julien Stephan <[email protected]>
Subject: [PATCH 5/7] iio: imu:inv_mpu6050: simplify code inwrite_event_configcallback
This Message Is From an External Sender
This message came from outside your organization.iio_ev_state_storeis actually using kstrtobool to check user
input, then gives the converted boolean value to thewrite_event_config
callback.Remove useless code in
write_event_configcallback.Signed-off-by Julien Stephan <[email protected]>--- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 7 ++----- drivers/iio/light/apds9960.c | 2 -- 2 files changed, 2 insertions(+), 7 deletions(-)drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +2
-5@@ -1176,21 +1176,18 @@ static int inv_mpu6050_write_event_config(struct iio_dev *indio_dev, int state) {struct inv_mpu6050_state *st =iio_priv (indio_dev); -int enable;/* support only WoM (accel roc rising) event */ if (chan->type !=IIO_ACCEL || type !=IIO_EV_TYPE_ROC || dir !=IIO_EV_DIR_RISING )return -EINVAL ; - enable = !!state; -guard (mutex)(&st->lock); -if (st->chip_config.wom_en == enable) +if (st->chip_config.wom_en == state)return 0 ; -return inv_mpu6050_enable_wom (st, enable); +return inv_mpu6050_enable_wom (st, state); } static int inv_mpu6050_read_event_value(struct iio_dev *indio_dev,drivers/iio/light/apds9960.c +0
-2@@ -762,8 +762,6 @@ static int apds9960_write_event_config(struct iio_dev *indio_dev,struct apds9960_data *data =iio_priv (indio_dev);int ret; - state = !!state; -switch (chan->type) {case IIO_PROXIMITY :if (data->pxs_int == state)
PATCH 6/7 iio: light: stk3310: simplify code in write_event_config callback
In reply to Julien Stephaniio_ev_state_store is actually using kstrtobool to check user input, then gives the converted boolean value to the write_event_config callback.
Remove useless code in write_event_config callback.
--- drivers/iio/light/stk3310.c | 3 --- 1 file changed, 3 deletions(-)
drivers/iio/light/stk3310.c +0 -3
@@ -330,9 +330,6 @@ static int stk3310_write_event_config(struct iio_dev *indio_dev,struct stk3310_data *data =iio_priv (indio_dev);struct i2c_client *client = data->client; -if (state <0 || state >7 ) -return -EINVAL ; -/* Set INT_PS value */ mutex_lock (&data->lock); ret =regmap_field_write (data->reg_int_ps, state);
Signature · 1 line
2.47.0
Re: [PATCH 6/7] iio: light: stk3310: simplify code in write_event_config callback
Quoted 7 lines · On Thu, 24 Oct 2024 11:11:28 +0200 Julien Stephan <[email protected]> wrote:
iio_ev_state_storeis actually using kstrtobool to check user input, then gives the converted boolean value to thewrite_event_configcallback.Remove useless code in
write_event_configcallback.Signed-off-by Julien Stephan <[email protected]>
This one is odd. The field is 1 bit so I've no idea why checking against 7 would ever have made sense.
Applied, but if anyone is familiar with this part I would like more eyes on that code to see if there is a bug hiding there.
Jonathan
Quoted 19 lines
--- drivers/iio/light/stk3310.c | 3 --- 1 file changed, 3 deletions(-)drivers/iio/light/stk3310.c +0
-3@@ -330,9 +330,6 @@ static int stk3310_write_event_config(struct iio_dev *indio_dev,struct stk3310_data *data =iio_priv (indio_dev);struct i2c_client *client = data->client; -if (state <0 || state >7 ) -return -EINVAL ; -/* Set INT_PS value */ mutex_lock (&data->lock); ret =regmap_field_write (data->reg_int_ps, state);
PATCH 7/7 iio: fix write_event_config signature
In reply to Julien Stephanwrite_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.
--- drivers/iio/accel/adxl367.c | 2 +- drivers/iio/accel/adxl372.c | 2 +- drivers/iio/accel/adxl380.c | 2 +- drivers/iio/accel/bma400_core.c | 2 +- drivers/iio/accel/bmc150-accel-core.c | 2 +- drivers/iio/accel/fxls8962af-core.c | 2 +- drivers/iio/accel/kxcjk-1013.c | 2 +- drivers/iio/accel/mma8452.c | 2 +- drivers/iio/accel/mma9551.c | 2 +- drivers/iio/accel/mma9553.c | 3 ++- drivers/iio/accel/sca3000.c | 2 +- drivers/iio/adc/ad7091r-base.c | 3 ++- drivers/iio/adc/ad7291.c | 2 +- drivers/iio/adc/ad799x.c | 2 +- drivers/iio/adc/hi8435.c | 2 +- drivers/iio/adc/max1363.c | 2 +- drivers/iio/adc/pac1921.c | 3 ++- drivers/iio/adc/palmas_gpadc.c | 2 +- drivers/iio/adc/ti-ads1015.c | 2 +- drivers/iio/adc/xilinx-ams.c | 2 +- drivers/iio/adc/xilinx-xadc-events.c | 2 +- drivers/iio/adc/xilinx-xadc.h | 2 +- drivers/iio/cdc/ad7150.c | 2 +- drivers/iio/dac/ad5421.c | 2 +- drivers/iio/dac/ad8460.c | 2 +- drivers/iio/dummy/iio_simple_dummy.h | 2 +- drivers/iio/dummy/iio_simple_dummy_events.c | 2 +- drivers/iio/gyro/bmg160_core.c | 2 +- drivers/iio/imu/bmi323/bmi323_core.c | 2 +- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 2 +- drivers/iio/imu/kmx61.c | 2 +- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 2 +- drivers/iio/light/adux1020.c | 3 ++- drivers/iio/light/apds9300.c | 2 +- drivers/iio/light/apds9306.c | 2 +- drivers/iio/light/apds9960.c | 2 +- drivers/iio/light/bh1745.c | 2 +- drivers/iio/light/cm36651.c | 2 +- drivers/iio/light/gp2ap002.c | 2 +- drivers/iio/light/gp2ap020a00f.c | 2 +- drivers/iio/light/iqs621-als.c | 2 +- drivers/iio/light/ltr390.c | 2 +- drivers/iio/light/ltr501.c | 2 +- drivers/iio/light/max44009.c | 2 +- drivers/iio/light/opt3001.c | 2 +- drivers/iio/light/stk3310.c | 2 +- drivers/iio/light/tcs3472.c | 2 +- drivers/iio/light/tsl2563.c | 2 +- drivers/iio/light/tsl2591.c | 2 +- drivers/iio/light/tsl2772.c | 2 +- drivers/iio/light/us5182d.c | 2 +- drivers/iio/light/vcnl4000.c | 5 +++-- drivers/iio/light/veml6030.c | 2 +- drivers/iio/position/iqs624-pos.c | 2 +- drivers/iio/proximity/aw96103.c | 2 +- drivers/iio/proximity/cros_ec_mkbp_proximity.c | 2 +- drivers/iio/proximity/hx9023s.c | 2 +- drivers/iio/proximity/irsd200.c | 3 ++- drivers/iio/proximity/sx9500.c | 2 +- drivers/iio/proximity/sx_common.c | 2 +- drivers/iio/proximity/sx_common.h | 2 +- drivers/iio/proximity/vcnl3020.c | 2 +- drivers/iio/temperature/mcp9600.c | 2 +- drivers/iio/temperature/tmp007.c | 2 +- include/linux/iio/iio.h | 2 +- 65 files changed, 72 insertions(+), 66 deletions(-)
drivers/iio/accel/adxl367.c +1 -1
@@ -1073,7 +1073,7 @@ static int adxl367_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { enum adxl367_activity_type act;
drivers/iio/accel/adxl372.c +1 -1
@@ -940,7 +940,7 @@ static int adxl372_read_event_config(struct iio_dev *indio_dev, const struct iiostatic int adxl372_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type,enum iio_event_direction dir, -int state) +bool state) {struct adxl372_state *st =iio_priv (indio_dev);
drivers/iio/accel/adxl380.c +1 -1
@@ -1386,7 +1386,7 @@ static int adxl380_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct adxl380_state *st = iio_priv(indio_dev);enum adxl380_axis axis;
drivers/iio/accel/bma400_core.c +1 -1
@@ -1293,7 +1293,7 @@ static int bma400_disable_adv_interrupt(struct bma400_data *data)static int bma400_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct bma400_data *data =iio_priv (indio_dev);int ret;
drivers/iio/accel/bmc150-accel-core.c +1 -1
@@ -804,7 +804,7 @@ static int bmc150_accel_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct bmc150_accel_data *data = iio_priv(indio_dev);int ret;
drivers/iio/accel/fxls8962af-core.c +1 -1
@@ -617,7 +617,7 @@ static int fxls8962af_write_event_config(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, enum iio_event_type type, - enum iio_event_direction dir, int state) + enum iio_event_direction dir, bool state) { struct fxls8962af_data *data = iio_priv(indio_dev);u8 enable_event, enable_bits;
drivers/iio/accel/kxcjk-1013.c +1 -1
@@ -1064,7 +1064,7 @@ static int kxcjk1013_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct kxcjk1013_data *data = iio_priv(indio_dev);int ret;
drivers/iio/accel/mma8452.c +1 -1
@@ -974,7 +974,7 @@ static int mma8452_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct mma8452_data *data = iio_priv(indio_dev);int val, ret;
drivers/iio/accel/mma9551.c +1 -1
@@ -225,7 +225,7 @@ static int mma9551_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct mma9551_data *data = iio_priv(indio_dev);int ret;
drivers/iio/accel/mma9553.c +2 -1
@@ -725,7 +725,8 @@ static int mma9553_read_event_config(struct iio_dev *indio_dev,static int mma9553_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir, +bool state) {struct mma9553_data *data =iio_priv (indio_dev);struct mma9553_event *event;
drivers/iio/accel/sca3000.c +1 -1
@@ -1253,7 +1253,7 @@ static int sca3000_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct sca3000_state *st = iio_priv(indio_dev);int ret;
drivers/iio/adc/ad7091r-base.c +2 -1
@@ -150,7 +150,8 @@ static int ad7091r_read_event_config(struct iio_dev *indio_dev,static int ad7091r_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir, +bool state) {struct ad7091r_state *st =iio_priv (indio_dev);
drivers/iio/adc/ad7291.c +1 -1
@@ -269,7 +269,7 @@ static int ad7291_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { int ret = 0;struct ad7291_chip_info *chip =iio_priv (indio_dev);
drivers/iio/adc/ad799x.c +1 -1
@@ -406,7 +406,7 @@ static int ad799x_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct ad799x_state *st = iio_priv(indio_dev);int ret;
drivers/iio/adc/hi8435.c +1 -1
@@ -132,7 +132,7 @@ static int hi8435_read_event_config(struct iio_dev *idev,static int hi8435_write_event_config (struct iio_dev *idev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct hi8435_priv *priv =iio_priv (idev);int ret;
drivers/iio/adc/max1363.c +1 -1
@@ -944,7 +944,7 @@ static inline int __max1363_check_event_mask(int thismask, int checkmask)static int max1363_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct max1363_state *st =iio_priv (indio_dev);
drivers/iio/adc/pac1921.c +2 -1
@@ -699,7 +699,8 @@ static int pac1921_read_event_config(struct iio_dev *indio_dev,static int pac1921_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir, +bool state) {struct pac1921_priv *priv =iio_priv (indio_dev);u8 ovf_bit;
drivers/iio/adc/palmas_gpadc.c +1 -1
@@ -676,7 +676,7 @@ static int palmas_gpadc_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct palmas_gpadc *adc = iio_priv(indio_dev);int adc_chan = chan->channel;
drivers/iio/adc/ti-ads1015.c +1 -1
@@ -806,7 +806,7 @@ static int ads1015_disable_event_config(struct ads1015_data *data,static int ads1015_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct ads1015_data *data =iio_priv (indio_dev);int ret;
drivers/iio/adc/xilinx-ams.c +1 -1
@@ -905,7 +905,7 @@ static int ams_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct ams *ams = iio_priv(indio_dev);unsigned int alarm;
drivers/iio/adc/xilinx-xadc-events.c +1 -1
@@ -121,7 +121,7 @@ int xadc_read_event_config(struct iio_dev *indio_dev,int xadc_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {unsigned int alarm =xadc_get_alarm_mask (chan);struct xadc *xadc =iio_priv (indio_dev);
drivers/iio/adc/xilinx-xadc.h +1 -1
@@ -25,7 +25,7 @@ int xadc_read_event_config(struct iio_dev *indio_dev, enum iio_event_direction dir);int xadc_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state); +enum iio_event_direction dir,bool state); int xadc_read_event_value(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, enum iio_event_info info,
drivers/iio/cdc/ad7150.c +1 -1
@@ -232,7 +232,7 @@ static int ad7150_write_event_params(struct iio_dev *indio_dev,static int ad7150_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct ad7150_chip_info *chip =iio_priv (indio_dev);int ret =0 ;
drivers/iio/dac/ad5421.c +1 -1
@@ -384,7 +384,7 @@ static int ad5421_write_raw(struct iio_dev *indio_dev,static int ad5421_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct ad5421_state *st =iio_priv (indio_dev);unsigned int mask;
drivers/iio/dac/ad8460.c +1 -1
@@ -573,7 +573,7 @@ static int ad8460_read_event_value(struct iio_dev *indio_dev,static int ad8460_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int val) +enum iio_event_direction dir,bool val) {struct ad8460_state *state =iio_priv (indio_dev);int fault;
drivers/iio/dummy/iio_simple_dummy.h +1 -1
@@ -60,7 +60,7 @@ int iio_simple_dummy_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state); + bool state); int iio_simple_dummy_read_event_value(struct iio_dev *indio_dev, const struct iio_chan_spec *chan,
drivers/iio/dummy/iio_simple_dummy_events.c +1 -1
@@ -53,7 +53,7 @@ int iio_simple_dummy_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct iio_dummy_state *st = iio_priv(indio_dev);
drivers/iio/gyro/bmg160_core.c +1 -1
@@ -749,7 +749,7 @@ static int bmg160_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct bmg160_data *data = iio_priv(indio_dev);int ret;
drivers/iio/imu/bmi323/bmi323_core.c +1 -1
@@ -785,7 +785,7 @@ static const struct attribute_group bmi323_event_attribute_group = {static int bmi323_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct bmi323_data *data =iio_priv (indio_dev);
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +1 -1
@@ -1173,7 +1173,7 @@ static int inv_mpu6050_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct inv_mpu6050_state *st = iio_priv(indio_dev);
drivers/iio/imu/kmx61.c +1 -1
@@ -942,7 +942,7 @@ static int kmx61_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct kmx61_data *data = kmx61_get_data(indio_dev);int ret =0 ;
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +1 -1
@@ -1959,7 +1959,7 @@ static int st_lsm6dsx_write_event_config(struct iio_dev *iio_dev, const struct iio_chan_spec *chan, enum iio_event_type type, - enum iio_event_direction dir, int state) + enum iio_event_direction dir, bool state) { struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev);struct st_lsm6dsx_hw *hw = sensor->hw;
drivers/iio/light/adux1020.c +2 -1
@@ -502,7 +502,8 @@ static int adux1020_write_raw(struct iio_dev *indio_dev,static int adux1020_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir, +bool state) {struct adux1020_data *data =iio_priv (indio_dev);int ret, mask;
drivers/iio/light/apds9300.c +1 -1
@@ -321,7 +321,7 @@ static int apds9300_read_interrupt_config(struct iio_dev *indio_dev,static int apds9300_write_interrupt_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct apds9300_data *data =iio_priv (indio_dev);int ret;
drivers/iio/light/apds9306.c +1 -1
@@ -1071,7 +1071,7 @@ static int apds9306_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct apds9306_data *data = iio_priv(indio_dev);struct apds9306_regfields *rf = &data->rf;
drivers/iio/light/apds9960.c +1 -1
@@ -757,7 +757,7 @@ static int apds9960_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct apds9960_data *data = iio_priv(indio_dev);int ret;
drivers/iio/light/bh1745.c +1 -1
@@ -638,7 +638,7 @@ static int bh1745_read_event_config(struct iio_dev *indio_dev,static int bh1745_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct bh1745_data *data =iio_priv (indio_dev);int value;
drivers/iio/light/cm36651.c +1 -1
@@ -529,7 +529,7 @@ static int cm36651_write_prox_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct cm36651_data *cm36651 = iio_priv(indio_dev);int cmd, ret;
drivers/iio/light/gp2ap002.c +1 -1
@@ -340,7 +340,7 @@ static int gp2ap002_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct gp2ap002 *gp2ap002 = iio_priv(indio_dev);
drivers/iio/light/gp2ap020a00f.c +1 -1
@@ -1159,7 +1159,7 @@ static int gp2ap020a00f_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct gp2ap020a00f_data *data = iio_priv(indio_dev);enum gp2ap020a00f_cmd cmd;
drivers/iio/light/iqs621-als.c +1 -1
@@ -271,7 +271,7 @@ static int iqs621_als_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct iqs621_als_private *iqs621_als = iio_priv(indio_dev);struct iqs62x_core *iqs62x = iqs621_als->iqs62x;
drivers/iio/light/ltr390.c +1 -1
@@ -553,7 +553,7 @@ static int ltr390_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct ltr390_data *data = iio_priv(indio_dev);int ret;
drivers/iio/light/ltr501.c +1 -1
@@ -1078,7 +1078,7 @@ static int ltr501_read_event_config(struct iio_dev *indio_dev,static int ltr501_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct ltr501_data *data =iio_priv (indio_dev);int ret;
drivers/iio/light/max44009.c +1 -1
@@ -422,7 +422,7 @@ static int max44009_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct max44009_data *data = iio_priv(indio_dev);int ret;
drivers/iio/light/opt3001.c +1 -1
@@ -634,7 +634,7 @@ static int opt3001_read_event_config(struct iio_dev *iio,static int opt3001_write_event_config (struct iio_dev *iio,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct opt3001 *opt =iio_priv (iio);int ret;
drivers/iio/light/stk3310.c +1 -1
@@ -324,7 +324,7 @@ static int stk3310_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { int ret;struct stk3310_data *data =iio_priv (indio_dev);
drivers/iio/light/tcs3472.c +1 -1
@@ -327,7 +327,7 @@ static int tcs3472_read_event_config(struct iio_dev *indio_dev,static int tcs3472_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct tcs3472_data *data =iio_priv (indio_dev);int ret =0 ;
drivers/iio/light/tsl2563.c +1 -1
@@ -630,7 +630,7 @@ static irqreturn_t tsl2563_event_handler(int irq, void *private)static int tsl2563_write_interrupt_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct tsl2563_chip *chip =iio_priv (indio_dev);int ret =0 ;
drivers/iio/light/tsl2591.c +1 -1
@@ -985,7 +985,7 @@ static int tsl2591_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct tsl2591_chip *chip = iio_priv(indio_dev);struct i2c_client *client = chip->client;
drivers/iio/light/tsl2772.c +1 -1
@@ -1081,7 +1081,7 @@ static int tsl2772_write_interrupt_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int val) + bool val) { struct tsl2772_chip *chip = iio_priv(indio_dev);
drivers/iio/light/us5182d.c +1 -1
@@ -627,7 +627,7 @@ static int us5182d_read_event_config(struct iio_dev *indio_dev,static int us5182d_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct us5182d_data *data =iio_priv (indio_dev);int ret;
drivers/iio/light/vcnl4000.c +3 -2
@@ -1456,7 +1456,7 @@ static int vcnl4010_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { switch (chan->type) { case IIO_PROXIMITY:
@@ -1501,7 +1501,8 @@ static int vcnl4040_read_event_config(struct iio_dev *indio_dev,static int vcnl4040_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir, +bool state) {int ret = -EINVAL ;u16 val, mask;
drivers/iio/light/veml6030.c +1 -1
@@ -821,7 +821,7 @@ static int veml6030_read_interrupt_config(struct iio_dev *indio_dev,*/ static int veml6030_write_interrupt_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {int ret;struct veml6030_data *data =iio_priv (indio_dev);
drivers/iio/position/iqs624-pos.c +1 -1
@@ -181,7 +181,7 @@ static int iqs624_pos_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct iqs624_pos_private *iqs624_pos = iio_priv(indio_dev);struct iqs62x_core *iqs62x = iqs624_pos->iqs62x;
drivers/iio/proximity/aw96103.c +1 -1
@@ -422,7 +422,7 @@ static int aw96103_read_event_config(struct iio_dev *indio_dev,static int aw96103_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct aw96103 *aw96103 =iio_priv (indio_dev);
drivers/iio/proximity/cros_ec_mkbp_proximity.c +1 -1
@@ -167,7 +167,7 @@ static int cros_ec_mkbp_proximity_read_event_config(struct iio_dev *indio_dev,static int cros_ec_mkbp_proximity_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct cros_ec_mkbp_proximity_data *data =iio_priv (indio_dev);
drivers/iio/proximity/hx9023s.c +1 -1
@@ -874,7 +874,7 @@ static int hx9023s_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct hx9023s_data *data = iio_priv(indio_dev);
drivers/iio/proximity/irsd200.c +2 -1
@@ -648,7 +648,8 @@ static int irsd200_read_event_config(struct iio_dev *indio_dev,static int irsd200_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir, +bool state) {struct irsd200_data *data =iio_priv (indio_dev);unsigned int tmp;
drivers/iio/proximity/sx9500.c +1 -1
@@ -540,7 +540,7 @@ static int sx9500_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct sx9500_data *data = iio_priv(indio_dev);int ret;
drivers/iio/proximity/sx_common.c +1 -1
@@ -268,7 +268,7 @@ EXPORT_SYMBOL_NS_GPL(sx_common_read_event_config, SEMTECH_PROX);int sx_common_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct sx_common_data *data =iio_priv (indio_dev);unsigned int eventirq =SX_COMMON_FAR_IRQ |SX_COMMON_CLOSE_IRQ ;
drivers/iio/proximity/sx_common.h +1 -1
@@ -143,7 +143,7 @@ int sx_common_read_event_config(struct iio_dev *indio_dev,int sx_common_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state); +enum iio_event_direction dir,bool state); int sx_common_probe(struct i2c_client *client, const struct sx_common_chip_info *chip_info,
drivers/iio/proximity/vcnl3020.c +1 -1
@@ -449,7 +449,7 @@ static int vcnl3020_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { switch (chan->type) { case IIO_PROXIMITY:
drivers/iio/temperature/mcp9600.c +1 -1
@@ -200,7 +200,7 @@ static int mcp9600_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct mcp9600_data *data = iio_priv(indio_dev);struct i2c_client *client = data->client;
drivers/iio/temperature/tmp007.c +1 -1
@@ -216,7 +216,7 @@ static irqreturn_t tmp007_interrupt_handler(int irq, void *private)static int tmp007_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct tmp007_data *data =iio_priv (indio_dev);unsigned int status_mask;
include/linux/iio/iio.h +1 -1
@@ -514,7 +514,7 @@ struct iio_info {const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state); + bool state); int (*read_event_value)(struct iio_dev *indio_dev, const struct iio_chan_spec *chan,
Signature · 1 line
2.47.0
Jonathan Cameron
maintainerQuoted 48 lines · On Thu, 24 Oct 2024 11:11:29 +0200 Julien Stephan <[email protected]> wrote:
write_event_configcallback use an int for state, but it is actually a boolean.iio_ev_state_storeis actually using kstrtobool to check user input, then gives the converted boolean value towrite_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-includesvirtual patch
@c1@
identifier iioinfo;
identifier wecfunc;
@@static const struct iio_info iioinfo = { ..., .write_event_config =(
wecfunc
|
&wecfunc
),...,};
@@
identifier c1.wecfunc;
identifierindio_dev, chan, type, dir, state;
@@
int wecfunc(structiio_dev*indio_dev, const structiio_chan_spec*chan, enumiio_event_typetype, enumiio_event_directiondir,(quoted diff) +1
-1-int +bool state) { }make coccicheck MODE=patch COCCI=iio-bool.cocci M=drivers/iio
Unfortunately, this script didn't match all files:
* allwrite_event_configcallbacks usingiio_device_claim_direct_scopedwere not detected and not patched.
* all files that do not assign and declare thewrite_event_configcallback in the same file.
Quoted 6 lines
iio.hwas also manually updated.The patch was build tested using allmodconfig config.
cc Julia Lawall <[email protected]>Signed-off-by Julien Stephan <[email protected]>
Hi Julien,
It's a nice cleanup, but the challenge of this sort of change is the odd ways various drivers use what you are changing.
So ever single case needs close inspection. I took a fairly broad look at it and there is at least one case that I think is broken by the change :(
+ a bunch of others where the result needs tidying up to not end up confusing.
Jonathan
Quoted 22 lines
drivers/iio/accel/adxl380.c +1
-1@@ -1386,7 +1386,7 @@ static int adxl380_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct adxl380_state *st = iio_priv(indio_dev);enum adxl380_axis axis;drivers/iio/accel/mma9551.c +0
-0
drivers/iio/accel/mma9551.c static int mma9551_write_event_config(struct iio_dev *indio_dev, · line 231
Quoted 8 lines
drivers/iio/accel/mma9551.c +1
-1@@ -225,7 +225,7 @@ static int mma9551_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct mma9551_data *data = iio_priv(indio_dev);int ret;
Good to push down into functions called.
drivers/iio/accel/sca3000.c static int sca3000_write_event_config(struct iio_dev *indio_dev, · line 1259
Quoted 13 lines
drivers/iio/accel/sca3000.c +1
-1@@ -1253,7 +1253,7 @@ static int sca3000_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct sca3000_state *st = iio_priv(indio_dev);int ret;
Good to push down the state into the functions called.
drivers/iio/imu/bmi323/bmi323_core.c static const struct attribute_group bmi323_event_attribute_group = { · line 791
Quoted 13 lines
drivers/iio/imu/bmi323/bmi323_core.c +1
-1@@ -785,7 +785,7 @@ static const struct attribute_group bmi323_event_attribute_group = {static int bmi323_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct bmi323_data *data =iio_priv (indio_dev);
Mix of types used to store state. Would be good to chase the boolean though. But no need to do that for this series.
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c static int · line 1965
Quoted 13 lines
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +1
-1@@ -1959,7 +1959,7 @@ static int st_lsm6dsx_write_event_config(struct iio_dev *iio_dev, const struct iio_chan_spec *chan, enum iio_event_type type, - enum iio_event_direction dir, int state) + enum iio_event_direction dir, bool state) { struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev);struct st_lsm6dsx_hw *hw = sensor->hw;
state is stored in a mix of bool and int in this driver. Might be a nice to cleanup thing but not strictly part of what you are doing here.
drivers/iio/light/adux1020.c static int adux1020_write_raw(struct iio_dev *indio_dev, · line 506
Quoted 11 lines
drivers/iio/light/adux1020.c +2
-1@@ -502,7 +502,8 @@ static int adux1020_write_raw(struct iio_dev *indio_dev,static int adux1020_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir, +bool state)
This one is a bug, because state is used as an intermediate for other stuff. Bad code, but needs fixing before you can do this.
Quoted 8 lines
drivers/iio/light/adux1020.c +0
-0{struct adux1020_data *data =iio_priv (indio_dev);int ret, mask;drivers/iio/light/apds9300.c +0
-0
drivers/iio/light/apds9300.c static int apds9300_read_interrupt_config(struct iio_dev *indio_dev, · line 327
Quoted 8 lines
drivers/iio/light/apds9300.c +1
-1@@ -321,7 +321,7 @@ static int apds9300_read_interrupt_config(struct iio_dev *indio_dev,static int apds9300_write_interrupt_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct apds9300_data *data =iio_priv (indio_dev);int ret;
Tidying up the interrupt state to all be tracked with a bool in here would make this better, but not strictly related to what you have here.
drivers/iio/light/apds9306.c static int apds9306_write_event_config(struct iio_dev *indio_dev, · line 1077
Quoted 13 lines
drivers/iio/light/apds9306.c +1
-1@@ -1071,7 +1071,7 @@ static int apds9306_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct apds9306_data *data = iio_priv(indio_dev);struct apds9306_regfields *rf = &data->rf;
This has a rather silly regmap_field_write() related if statement you could clean up but that's an optional extra.
drivers/iio/light/apds9960.c static int apds9960_write_event_config(struct iio_dev *indio_dev, · line 763
Quoted 13 lines
drivers/iio/light/apds9960.c +1
-1@@ -757,7 +757,7 @@ static int apds9960_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct apds9960_data *data = iio_priv(indio_dev);int ret;
Should change type of pxs_int etc to bool.
drivers/iio/light/ltr390.c static int ltr390_write_event_config(struct iio_dev *indio_dev, · line 559
Quoted 13 lines
drivers/iio/light/ltr390.c +1
-1@@ -553,7 +553,7 @@ static int ltr390_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct ltr390_data *data = iio_priv(indio_dev);int ret;
See review of patch 2.
drivers/iio/light/tsl2772.c static int tsl2772_write_interrupt_config(struct iio_dev *indio_dev, · line 1087
Quoted 13 lines
drivers/iio/light/tsl2772.c +1
-1@@ -1081,7 +1081,7 @@ static int tsl2772_write_interrupt_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int val) + bool val) { struct tsl2772_chip *chip = iio_priv(indio_dev);
val ? true : false
in here should go.
drivers/iio/proximity/hx9023s.c static int hx9023s_write_event_config(struct iio_dev *indio_dev, · line 879
Quoted 12 lines
drivers/iio/proximity/hx9023s.c +1
-1@@ -874,7 +874,7 @@ static int hx9023s_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct hx9023s_data *data = iio_priv(indio_dev);
Has a !!state that should go.
drivers/iio/proximity/irsd200.c static int irsd200_read_event_config(struct iio_dev *indio_dev,
Quoted 6 lines
drivers/iio/proximity/irsd200.c +0
-0@@ -648,7 +648,8 @@ static int irsd200_read_event_config(struct iio_dev *indio_dev,
This has a !!state that should go.
Quoted 14 lines
drivers/iio/proximity/irsd200.c +2
-1static int irsd200_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir, +bool state) {struct irsd200_data *data =iio_priv (indio_dev);unsigned int tmp;drivers/iio/proximity/sx9500.c +0
-0
drivers/iio/proximity/sx9500.c static int sx9500_write_event_config(struct iio_dev *indio_dev, · line 544
Quoted 6 lines
drivers/iio/proximity/sx9500.c +1
-1@@ -540,7 +540,7 @@ static int sx9500_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) {
This one treats state as an integer. We should change that before applying this patch.
Quoted 2 lines
drivers/iio/proximity/sx9500.c +0
-0struct sx9500_data *data =iio_priv (indio_dev);int ret;
Quoted 61 lines · Jonathan Cameron
Quoted 48 lines · On Thu, 24 Oct 2024 11:11:29 +0200 Julien Stephan <[email protected]> wrote:
write_event_configcallback use an int for state, but it is actually a boolean.iio_ev_state_storeis actually using kstrtobool to check user input, then gives the converted boolean value towrite_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-includesvirtual patch
@c1@
identifier iioinfo;
identifier wecfunc;
@@static const struct iio_info iioinfo = { ..., .write_event_config =(
wecfunc
|
&wecfunc
),...,};
@@
identifier c1.wecfunc;
identifierindio_dev, chan, type, dir, state;
@@
int wecfunc(structiio_dev*indio_dev, const structiio_chan_spec*chan, enumiio_event_typetype, enumiio_event_directiondir,(quoted diff) +1
-1-int +bool state) { }make coccicheck MODE=patch COCCI=iio-bool.cocci M=drivers/iio
Unfortunately, this script didn't match all files:
* allwrite_event_configcallbacks usingiio_device_claim_direct_scopedwere not detected and not patched.
* all files that do not assign and declare thewrite_event_configcallback in the same file.Quoted 6 lines
iio.hwas also manually updated.The patch was build tested using allmodconfig config.
cc Julia Lawall <[email protected]>Signed-off-by Julien Stephan <[email protected]>Hi Julien,
Quoted 8 lines
It's a nice cleanup, but the challenge of this sort of change is the odd ways various drivers use what you are changing.
So ever single case needs close inspection. I took a fairly broad look at it and there is at least one case that I think is broken by the change :(
+ a bunch of others where the result needs tidying up to not end up confusing.
Hi Jonathan,
I apologize for missing some cleanup in a few callbacks. Thank you for pointing it out. I’ll send a v2 with these updates.
Cheers
Julien
Quoted 232 lines
Jonathan
Quoted 22 lines
drivers/iio/accel/adxl380.c +1
-1@@ -1386,7 +1386,7 @@ static int adxl380_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct adxl380_state *st = iio_priv(indio_dev);enum adxl380_axis axis;drivers/iio/accel/mma9551.c +0
-0drivers/iio/accel/mma9551.c static int mma9551_write_event_config(struct iio_dev *indio_dev, · line 231
Quoted 8 lines
drivers/iio/accel/mma9551.c +1
-1@@ -225,7 +225,7 @@ static int mma9551_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct mma9551_data *data = iio_priv(indio_dev);int ret;Good to push down into functions called.
drivers/iio/accel/sca3000.c static int sca3000_write_event_config(struct iio_dev *indio_dev, · line 1259
Quoted 13 lines
drivers/iio/accel/sca3000.c +1
-1@@ -1253,7 +1253,7 @@ static int sca3000_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct sca3000_state *st = iio_priv(indio_dev);int ret;Good to push down the state into the functions called.
drivers/iio/imu/bmi323/bmi323_core.c static const struct attribute_group bmi323_event_attribute_group = { · line 791
Quoted 13 lines
drivers/iio/imu/bmi323/bmi323_core.c +1
-1@@ -785,7 +785,7 @@ static const struct attribute_group bmi323_event_attribute_group = {static int bmi323_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct bmi323_data *data =iio_priv (indio_dev);Mix of types used to store state. Would be good to chase the boolean though. But no need to do that for this series.
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c static int · line 1965
Quoted 13 lines
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +1
-1@@ -1959,7 +1959,7 @@ static int st_lsm6dsx_write_event_config(struct iio_dev *iio_dev, const struct iio_chan_spec *chan, enum iio_event_type type, - enum iio_event_direction dir, int state) + enum iio_event_direction dir, bool state) { struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev);struct st_lsm6dsx_hw *hw = sensor->hw;state is stored in a mix of bool and int in this driver. Might be a nice to cleanup thing but not strictly part of what you are doing here.
drivers/iio/light/adux1020.c static int adux1020_write_raw(struct iio_dev *indio_dev, · line 506
Quoted 11 lines
drivers/iio/light/adux1020.c +2
-1@@ -502,7 +502,8 @@ static int adux1020_write_raw(struct iio_dev *indio_dev,static int adux1020_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir, +bool state)This one is a bug, because state is used as an intermediate for other stuff. Bad code, but needs fixing before you can do this.
Quoted 8 lines
drivers/iio/light/adux1020.c +0
-0{struct adux1020_data *data =iio_priv (indio_dev);int ret, mask;drivers/iio/light/apds9300.c +0
-0drivers/iio/light/apds9300.c static int apds9300_read_interrupt_config(struct iio_dev *indio_dev, · line 327
Quoted 8 lines
drivers/iio/light/apds9300.c +1
-1@@ -321,7 +321,7 @@ static int apds9300_read_interrupt_config(struct iio_dev *indio_dev,static int apds9300_write_interrupt_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir,bool state) {struct apds9300_data *data =iio_priv (indio_dev);int ret;Tidying up the interrupt state to all be tracked with a bool in here would make this better, but not strictly related to what you have here.
drivers/iio/light/apds9306.c static int apds9306_write_event_config(struct iio_dev *indio_dev, · line 1077
Quoted 13 lines
drivers/iio/light/apds9306.c +1
-1@@ -1071,7 +1071,7 @@ static int apds9306_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct apds9306_data *data = iio_priv(indio_dev);struct apds9306_regfields *rf = &data->rf;This has a rather silly
regmap_field_write()related if statement you could clean up but that's an optional extra.drivers/iio/light/apds9960.c static int apds9960_write_event_config(struct iio_dev *indio_dev, · line 763
Quoted 13 lines
drivers/iio/light/apds9960.c +1
-1@@ -757,7 +757,7 @@ static int apds9960_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct apds9960_data *data = iio_priv(indio_dev);int ret;Should change type of
pxs_intetc to bool.drivers/iio/light/ltr390.c static int ltr390_write_event_config(struct iio_dev *indio_dev, · line 559
Quoted 13 lines
drivers/iio/light/ltr390.c +1
-1@@ -553,7 +553,7 @@ static int ltr390_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct ltr390_data *data = iio_priv(indio_dev);int ret;See review of patch 2.
drivers/iio/light/tsl2772.c static int tsl2772_write_interrupt_config(struct iio_dev *indio_dev, · line 1087
Quoted 13 lines
drivers/iio/light/tsl2772.c +1
-1@@ -1081,7 +1081,7 @@ static int tsl2772_write_interrupt_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int val) + bool val) { struct tsl2772_chip *chip = iio_priv(indio_dev);val ? true : false
in here should go.drivers/iio/proximity/hx9023s.c static int hx9023s_write_event_config(struct iio_dev *indio_dev, · line 879
Quoted 12 lines
drivers/iio/proximity/hx9023s.c +1
-1@@ -874,7 +874,7 @@ static int hx9023s_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) { struct hx9023s_data *data = iio_priv(indio_dev);Has a !!state that should go.
drivers/iio/proximity/irsd200.c static int irsd200_read_event_config(struct iio_dev *indio_dev,
Quoted 6 lines
drivers/iio/proximity/irsd200.c +0
-0@@ -648,7 +648,8 @@ static int irsd200_read_event_config(struct iio_dev *indio_dev,This has a !!state that should go.
Quoted 14 lines
drivers/iio/proximity/irsd200.c +2
-1static int irsd200_write_event_config (struct iio_dev *indio_dev,const struct iio_chan_spec *chan,enum iio_event_type type, -enum iio_event_direction dir,int state) +enum iio_event_direction dir, +bool state) {struct irsd200_data *data =iio_priv (indio_dev);unsigned int tmp;drivers/iio/proximity/sx9500.c +0
-0drivers/iio/proximity/sx9500.c static int sx9500_write_event_config(struct iio_dev *indio_dev, · line 544
Quoted 6 lines
drivers/iio/proximity/sx9500.c +1
-1@@ -540,7 +540,7 @@ static int sx9500_write_event_config(struct iio_dev *indio_dev,const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, - int state) + bool state) {This one treats state as an integer. We should change that before applying this patch.
Quoted 2 lines
drivers/iio/proximity/sx9500.c +0
-0struct sx9500_data *data =iio_priv (indio_dev);int ret;