public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Julien Stephan <jstephan@baylibre.com>
Cc: Mudit Sharma <muditsharma.info@gmail.com>,
	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>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	chrome-platform@lists.linux.dev,
	Julia Lawall <julia.lawall@inria.fr>
Subject: Re: [PATCH v2 07/15] iio: fix write_event_config signature
Date: Fri, 1 Nov 2024 16:32:55 +0000	[thread overview]
Message-ID: <20241101163255.5f4d9d70@jic23-huawei> (raw)
In-Reply-To: <20241031-iio-fix-write-event-config-signature-v2-7-2bcacbb517a2@baylibre.com>

On Thu, 31 Oct 2024 16:27:02 +0100
Julien Stephan <jstephan@baylibre.com> wrote:

> 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>

Hi Julien,

I went through these by hand.  There are somewhere maybe it is worth
passing booleans down into leaf functions and only convert to int
right at the end (for a field write) but I don't think we care.
The cases here are more of the variety of converting a bool to an int
to use it as a bool (like the ones you clear up later in this series).

Neither is wrong, just inefficient, so applied and pushed out as testing
for 0-day to take a look.
Fingers crossed nothing got missed!

Jonathan

> diff --git a/drivers/iio/accel/fxls8962af-core.c b/drivers/iio/accel/fxls8962af-core.c
> index ab427f3461dbbef535c2ec2cf2982202ca97bb82..f07fba17048e7b5c1958807b14d4bcb3ff87e26d 100644
> --- a/drivers/iio/accel/fxls8962af-core.c
> +++ b/drivers/iio/accel/fxls8962af-core.c
> @@ -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;
This passes the state variable into fxls8962af_event_setup() as an integer
and uses it as a boolean.  Might as well be bool all the way.


> diff --git a/drivers/iio/light/gp2ap020a00f.c b/drivers/iio/light/gp2ap020a00f.c
> index 81e718cdeae32d60581cb490148f4f1c0bd695c7..1a352c88598e5d701256aa8659a7f9683bce56f9 100644
> --- a/drivers/iio/light/gp2ap020a00f.c
> +++ b/drivers/iio/light/gp2ap020a00f.c
> @@ -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)
This one could do with a follow up as the state variable is passed as an integer
to another function that then uses it as a bool.

>  {
>  	struct gp2ap020a00f_data *data = iio_priv(indio_dev);
>  	enum gp2ap020a00f_cmd cmd;


  reply	other threads:[~2024-11-01 17:46 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-31 15:26 [PATCH v2 00/15] iio: fix write_event_config signature Julien Stephan
2024-10-31 15:26 ` [PATCH v2 01/15] iio: light: ltr390: simplify code in write_event_config callback Julien Stephan
2024-11-01 15:32   ` Jonathan Cameron
2024-10-31 15:26 ` [PATCH v2 02/15] iio: proximity: hx9023s: " Julien Stephan
2024-11-01 15:34   ` Jonathan Cameron
2024-10-31 15:26 ` [PATCH v2 03/15] iio: light: tsl2772: " Julien Stephan
2024-11-01 15:35   ` Jonathan Cameron
2024-10-31 15:26 ` [PATCH v2 04/15] iio: proximity: irsd200: " Julien Stephan
2024-11-01 15:36   ` Jonathan Cameron
2024-10-31 15:27 ` [PATCH v2 05/15] iio: proximity: sx9500: " Julien Stephan
2024-11-01 15:36   ` Jonathan Cameron
2024-10-31 15:27 ` [PATCH v2 06/15] iio: light: adux1020: write_event_config: use local variable for interrupt value Julien Stephan
2024-10-31 16:27   ` David Lechner
2024-11-01 15:44     ` Jonathan Cameron
2024-11-01 18:18       ` Julien Stephan
2024-10-31 15:27 ` [PATCH v2 07/15] iio: fix write_event_config signature Julien Stephan
2024-11-01 16:32   ` Jonathan Cameron [this message]
2024-10-31 15:27 ` [PATCH v2 08/15] iio: accel: mma9551: use bool for event state Julien Stephan
2024-11-01 16:33   ` Jonathan Cameron
2024-10-31 15:27 ` [PATCH v2 09/15] iio: accel: sca3000: " Julien Stephan
2024-11-01 16:34   ` Jonathan Cameron
2024-10-31 15:27 ` [PATCH v2 10/15] iio: imu: bmi323: " Julien Stephan
2024-11-01 16:35   ` Jonathan Cameron
2024-10-31 15:27 ` [PATCH v2 11/15] iio: imu: st_lsm6dsx: " Julien Stephan
2024-11-01 16:36   ` Jonathan Cameron
2024-10-31 15:27 ` [PATCH v2 12/15] iio: light: apds9300: " Julien Stephan
2024-11-01 16:40   ` Jonathan Cameron
2024-10-31 15:27 ` [PATCH v2 13/15] iio: light: apds9306: simplifies if branch in apds9306_write_event_config Julien Stephan
2024-11-01 16:41   ` Jonathan Cameron
2024-11-02 13:21     ` Subhajit Ghosh
2024-11-02 14:29       ` Julien Stephan
2024-11-02 15:09         ` Subhajit Ghosh
2024-10-31 15:27 ` [PATCH v2 14/15] iio: light: apds9960: convert als_int and pxs_int to bool Julien Stephan
2024-11-01 16:42   ` Jonathan Cameron
2024-10-31 15:27 ` [PATCH v2 15/15] iio: light: apds9960: remove useless return Julien Stephan
2024-11-01 16:44   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241101163255.5f4d9d70@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Mariel.Tinaco@analog.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=anand.ashok.dumbre@xilinx.com \
    --cc=anshulusr@gmail.com \
    --cc=antoniu.miclaus@analog.com \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=cosmin.tanislav@analog.com \
    --cc=dan@dlrobertson.com \
    --cc=groeck@chromium.org \
    --cc=jagathjog1996@gmail.com \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=jean-baptiste.maneyrol@tdk.com \
    --cc=jstephan@baylibre.com \
    --cc=julia.lawall@inria.fr \
    --cc=ktsai@capellamicro.com \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=marcelo.schmitt@analog.com \
    --cc=matteomartelli3@gmail.com \
    --cc=michal.simek@amd.com \
    --cc=muditsharma.info@gmail.com \
    --cc=ramona.gradinariu@analog.com \
    --cc=subhajit.ghosh@tweaklogic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox