[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241026132025.1d7a700c@jic23-huawei>
Date: Sat, 26 Oct 2024 13:20:25 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Julien Stephan <jstephan@...libre.com>
Cc: Mudit Sharma <muditsharma.info@...il.com>, Lars-Peter Clausen
<lars@...afoo.de>, Anshul Dalal <anshulusr@...il.com>, Javier Carrasco
<javier.carrasco.cruz@...il.com>, Jean-Baptiste Maneyrol
<jean-baptiste.maneyrol@....com>, Michael Hennerich
<Michael.Hennerich@...log.com>, Cosmin Tanislav
<cosmin.tanislav@...log.com>, Ramona Gradinariu
<ramona.gradinariu@...log.com>, Antoniu Miclaus
<antoniu.miclaus@...log.com>, Dan Robertson <dan@...obertson.com>, Marcelo
Schmitt <marcelo.schmitt@...log.com>, Matteo Martelli
<matteomartelli3@...il.com>, Anand Ashok Dumbre
<anand.ashok.dumbre@...inx.com>, Michal Simek <michal.simek@....com>,
Mariel Tinaco <Mariel.Tinaco@...log.com>, Jagath Jog J
<jagathjog1996@...il.com>, Lorenzo Bianconi <lorenzo@...nel.org>, Subhajit
Ghosh <subhajit.ghosh@...aklogic.com>, Kevin Tsai <ktsai@...ellamicro.com>,
Linus Walleij <linus.walleij@...aro.org>, Benson Leung
<bleung@...omium.org>, Guenter Roeck <groeck@...omium.org>,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, chrome-platform@...ts.linux.dev
Subject: Re: [PATCH 1/7] iio: light: bh1745: simplify code in
write_event_config callback
On Thu, 24 Oct 2024 11:11:23 +0200
Julien Stephan <jstephan@...libre.com> wrote:
> 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@...libre.com>
There are a few additions needed to the final patch.
I'll pick up the earlier ones now though.
Applied this one.
> ---
> drivers/iio/light/bh1745.c | 48 +++++++++++++++++++++-------------------------
> 1 file changed, 22 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/iio/light/bh1745.c b/drivers/iio/light/bh1745.c
> index 2e458e9d5d85308fb6a13d9dbd845fa03b56a40e..fc6bf062d4f510886f909509d8115f0cf892f3c4 100644
> --- a/drivers/iio/light/bh1745.c
> +++ b/drivers/iio/light/bh1745.c
> @@ -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,
>
Powered by blists - more mailing lists