diff mbox series

[5/7] iio: imu: inv_mpu6050: simplify code in write_event_config callback

Message ID 20241024-iio-fix-write-event-config-signature-v1-5-7d29e5a31b00@baylibre.com (mailing list archive)
State Accepted
Headers show
Series iio: fix write_event_config signature | expand

Commit Message

Julien Stephan Oct. 24, 2024, 9:11 a.m. UTC
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.

Signed-off-by: Julien Stephan <jstephan@baylibre.com>
---
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 7 ++-----
 drivers/iio/light/apds9960.c               | 2 --
 2 files changed, 2 insertions(+), 7 deletions(-)

Comments

Jean-Baptiste Maneyrol Oct. 24, 2024, 12:16 p.m. UTC | #1
Hello Julien,

good thing to know, thanks for the patch.

Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

Best regards,
JB
Jonathan Cameron Oct. 26, 2024, 12:27 p.m. UTC | #2
On Thu, 24 Oct 2024 12:16:42 +0000
Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com> wrote:

> Hello Julien,
> 
> good thing to know, thanks for the patch.
> 
> Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Applied.
> 
> Best regards,
> JB
> 
> ________________________________________
> From: Julien Stephan <jstephan@baylibre.com>
> Sent: Thursday, October 24, 2024 11:11
> To: Mudit Sharma <muditsharma.info@gmail.com>; Jonathan Cameron <jic23@kernel.org>; Lars-Peter Clausen <lars@metafoo.de>; Anshul Dalal <anshulusr@gmail.com>; Javier Carrasco <javier.carrasco.cruz@gmail.com>; Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com>; Michael Hennerich <Michael.Hennerich@analog.com>; Cosmin Tanislav <cosmin.tanislav@analog.com>; Ramona Gradinariu <ramona.gradinariu@analog.com>; Antoniu Miclaus <antoniu.miclaus@analog.com>; Dan Robertson <dan@dlrobertson.com>; Marcelo Schmitt <marcelo.schmitt@analog.com>; Matteo Martelli <matteomartelli3@gmail.com>; Anand Ashok Dumbre <anand.ashok.dumbre@xilinx.com>; Michal Simek <michal.simek@amd.com>; Mariel Tinaco <Mariel.Tinaco@analog.com>; Jagath Jog J <jagathjog1996@gmail.com>; Lorenzo Bianconi <lorenzo@kernel.org>; Subhajit Ghosh <subhajit.ghosh@tweaklogic.com>; Kevin Tsai <ktsai@capellamicro.com>; Linus Walleij <linus.walleij@linaro.org>; Benson Leung <bleung@chromium.org>; Guenter Roeck <groeck@chromium.org>
> Cc: linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>; linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>; linux-arm-kernel@lists.infradead.org <linux-arm-kernel@lists.infradead.org>; chrome-platform@lists.linux.dev <chrome-platform@lists.linux.dev>; Julien Stephan <jstephan@baylibre.com>
> 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.
> 
> Signed-off-by: Julien Stephan <jstephan@baylibre.com>
> ---
>  drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 7 ++-----
>  drivers/iio/light/apds9960.c               | 2 --
>  2 files changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index 5680be153127711777b6074da18a7a0f86211d6c..21ebf0f7e28fec302cbf8ab890fc53a3de6f36cd 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -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,
> diff --git a/drivers/iio/light/apds9960.c b/drivers/iio/light/apds9960.c
> index 3c14e4c30805e1b596ef2380f94e6aa3e92082b1..3a56eaae5a68f2891d061871c7013f0b5447bb47 100644
> --- a/drivers/iio/light/apds9960.c
> +++ b/drivers/iio/light/apds9960.c
> @@ -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)
>
diff mbox series

Patch

diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 5680be153127711777b6074da18a7a0f86211d6c..21ebf0f7e28fec302cbf8ab890fc53a3de6f36cd 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -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,
diff --git a/drivers/iio/light/apds9960.c b/drivers/iio/light/apds9960.c
index 3c14e4c30805e1b596ef2380f94e6aa3e92082b1..3a56eaae5a68f2891d061871c7013f0b5447bb47 100644
--- a/drivers/iio/light/apds9960.c
+++ b/drivers/iio/light/apds9960.c
@@ -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)