From: Javier Carrasco <javier.carrasco.cruz@gmail.com>
To: Mudit Sharma <muditsharma.info@gmail.com>,
jic23@kernel.org, lars@metafoo.de, krzk+dt@kernel.org,
conor+dt@kernel.org, robh@kernel.org
Cc: ivan.orlov0322@gmail.com, linux-kernel@vger.kernel.org,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v5 2/2] iio: light: ROHM BH1745 colour sensor
Date: Tue, 25 Jun 2024 00:27:45 +0200 [thread overview]
Message-ID: <cf06ea77-c8b0-4476-94d1-32171c96f22f@gmail.com> (raw)
In-Reply-To: <20240624215543.459797-2-muditsharma.info@gmail.com>
On 24/06/2024 23:55, Mudit Sharma wrote:
> Add support for BH1745, which is an I2C colour sensor with red, green,
> blue and clear channels. It has a programmable active low interrupt
> pin. Interrupt occurs when the signal from the selected interrupt
> source channel crosses set interrupt threshold high or low level.
>
> Interrupt source for the device can be configured by enabling the
> corresponding event and interrupt latch is always enabled when setting
> up interrupt.
>
> Add myself as the maintainer for this driver in MAINTAINERS.
>
> Signed-off-by: Mudit Sharma <muditsharma.info@gmail.com>
> Reviewed-by: Ivan Orlov <ivan.orlov0322@gmail.com>
> Reviewed-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
> ---
Hi Mudit, some minor comments inline form my side.
...
> +
> +struct bh1745_data {
> + /*
> + * Lock to prevent device setting update or read before related
typo: calculations. I would recommend you to use checkpatch.pl
--codespell to cach such typos.
> + * caluculations or event push are completed
> + */
> + struct mutex lock;
> + struct regmap *regmap;
> + struct i2c_client *client;
> + struct iio_trigger *trig;
> + struct iio_gts gts;
> + u8 int_src;
> +};
> +
...
> +static int bh1745_int_time_to_us(int val, int val2)
> +{
> + for (u8 i = 0; i < ARRAY_SIZE(bh1745_int_time); i++) {
> + if (val == bh1745_int_time[i][0] && val2 == bh1745_int_time[i][1])
> + return bh1745_int_time_us[i];
Nit: unnecessary blank line before a close brace.
> +
> + }
> +
> + return -EINVAL;
> +}
...
> +static int bh1745_read_raw(struct iio_dev *indio_dev,
> + struct iio_chan_spec const *chan,
> + int *val, int *val2, long mask)
> +{
> + struct bh1745_data *data = iio_priv(indio_dev);
> + int ret;
> + int value;
> +
> + switch (mask) {
> + case IIO_CHAN_INFO_RAW: {
> + iio_device_claim_direct_scoped(return -EBUSY, indio_dev) {
Missing scope indentation.
> + ret = regmap_bulk_read(data->regmap, chan->address, &value, 2);
> + if (ret)
> + return ret;
> + *val = value;
> +
> + return IIO_VAL_INT;
> + }
> + unreachable();
> + }
> +
...
> +static int bh1745_set_trigger_state(struct iio_trigger *trig, bool state)
> +{
> + int ret;
Why is value initialized here? If regmap returns an error, you will not
use value anyway. I caught my eye because it is initialized here, and
not in the other functions where you use the same pattern.
> + int value = 0;
> + struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
> + struct bh1745_data *data = iio_priv(indio_dev);
> +
> + guard(mutex)(&data->lock);
> + if (state) {
> + ret = regmap_read(data->regmap, BH1745_INTR, &value);
> + if (ret)
> + return ret;
> + // Latch is always set when enabling interrupt
> + value |= BH1745_INT_ENABLE |
> + FIELD_PREP(BH1745_INT_SIGNAL_LATCHED, 1) |
> + FIELD_PREP(BH1745_INT_SOURCE_MASK, data->int_src);
> + return regmap_write(data->regmap, BH1745_INTR, value);
> + }
> +
> + return regmap_write(data->regmap, BH1745_INTR, value);
> +}
Best regards,
Javier Carrasco
next prev parent reply other threads:[~2024-06-24 22:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-24 21:55 [PATCH v5 1/2] dt-bindings: iio: light: ROHM BH1745 Mudit Sharma
2024-06-24 21:55 ` [PATCH v5 2/2] iio: light: ROHM BH1745 colour sensor Mudit Sharma
2024-06-24 22:27 ` Javier Carrasco [this message]
2024-06-25 19:25 ` Mudit Sharma
2024-06-25 23:44 ` Javier Carrasco
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=cf06ea77-c8b0-4476-94d1-32171c96f22f@gmail.com \
--to=javier.carrasco.cruz@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=ivan.orlov0322@gmail.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=muditsharma.info@gmail.com \
--cc=robh@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;
as well as URLs for NNTP newsgroup(s).