From: Jonathan Cameron <jic23@kernel.org>
To: Abhash Jha <abhashkumarjha123@gmail.com>
Cc: linux-iio@vger.kernel.org, anshulusr@gmail.com, lars@metafoo.de,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] iio: light: ltr390: Add ALS channel and support for gain and resolution
Date: Sun, 28 Jul 2024 17:58:41 +0100 [thread overview]
Message-ID: <20240728175841.7ca04e58@jic23-huawei> (raw)
In-Reply-To: <20240728151957.310237-2-abhashkumarjha123@gmail.com>
On Sun, 28 Jul 2024 20:49:55 +0530
Abhash Jha <abhashkumarjha123@gmail.com> wrote:
> Add new ALS channel and allow reading raw and scale values.
> Also provide gain and resolution configuration for ALS channel.
> Add automatic mode switching between the UVS and ALS channel
> based on which channel is being accessed.
> The default mode in which the sensor start is ALS mode.
Same issue with indent as in patch 1.
>
> Signed-off-by: Abhash Jha <abhashkumarjha123@gmail.com>
Later patches should not be in reply to the first one.
Use a cover letter.
Minor comments inline on using the enum to maintain the type of the mode
setting.
> ---
> drivers/iio/light/ltr390.c | 111 ++++++++++++++++++++++++++++++++-----
> 1 file changed, 96 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/iio/light/ltr390.c b/drivers/iio/light/ltr390.c
> index 9f00661c3..d1a259141 100644
> --- a/drivers/iio/light/ltr390.c
> +++ b/drivers/iio/light/ltr390.c
> @@ -62,11 +62,17 @@
> */
> #define LTR390_WINDOW_FACTOR 1
>
> +enum ltr390_mode {
> + LTR390_SET_ALS_MODE,
> + LTR390_SET_UVS_MODE,
> +};
> +
> struct ltr390_data {
> struct regmap *regmap;
> struct i2c_client *client;
> /* Protects device from simulataneous reads */
> struct mutex lock;
> + int mode;
enum ltr380_mode mode;
> int gain;
> int int_time_us;
> };
> @@ -94,6 +100,28 @@ static int ltr390_register_read(struct ltr390_data *data, u8 register_address)
> return get_unaligned_le24(recieve_buffer);
> }
>
> +static int ltr390_set_mode(struct ltr390_data *data, int mode)
pass in the enum lt380_mode.
> +{
> + if (data->mode == mode)
> + return 0;
> +
> + switch (mode) {
> + case LTR390_SET_ALS_MODE:
> + regmap_clear_bits(data->regmap, LTR390_MAIN_CTRL, LTR390_UVS_MODE);
> + break;
> +
> + case LTR390_SET_UVS_MODE:
> + regmap_set_bits(data->regmap, LTR390_MAIN_CTRL, LTR390_UVS_MODE);
> + break;
> +
> + default:
> + return -EINVAL;
Should be able to drop this if passing in the enum as the compiler can see you
have cases for every value.
> + }
> +
> + data->mode = mode;
> + return 0;
> +}
> +
next prev parent reply other threads:[~2024-07-28 16:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-18 10:49 [PATCH] iio: light: ltr390: Add configurable gain, resolution and ALS reading Abhash Jha
2024-07-20 15:55 ` Jonathan Cameron
2024-07-26 12:55 ` Abhash jha
2024-07-27 12:27 ` Jonathan Cameron
2024-07-28 15:19 ` [PATCH v2 1/3] iio: light: ltr390: Add configurable gain and resolution Abhash Jha
2024-07-28 15:19 ` [PATCH v2 2/3] iio: light: ltr390: Add ALS channel and support for " Abhash Jha
2024-07-28 16:58 ` Jonathan Cameron [this message]
2024-07-28 15:19 ` [PATCH v2 3/3] iio: light: ltr390: Calculate 'counts_per_uvi' dynamically Abhash Jha
2024-07-28 17:03 ` Jonathan Cameron
2024-07-28 17:03 ` [PATCH v2 1/3] iio: light: ltr390: Add configurable gain and resolution 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=20240728175841.7ca04e58@jic23-huawei \
--to=jic23@kernel.org \
--cc=abhashkumarjha123@gmail.com \
--cc=anshulusr@gmail.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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