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: linux-kernel@vger.kernel.org, mazziesaccount@gmail.com,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
Ivan Orlov <ivan.orlov0322@gmail.com>
Subject: Re: [PATCH v8 2/2] iio: light: ROHM BH1745 colour sensor
Date: Fri, 19 Jul 2024 18:02:34 +0200 [thread overview]
Message-ID: <2505dee2-c503-4566-a4ef-73103da9479d@gmail.com> (raw)
In-Reply-To: <20240718220208.331942-2-muditsharma.info@gmail.com>
On 19/07/2024 00:02, 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. 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,
a couple of nitpicks inline.
...
> +static int bh1745_set_int_time(struct bh1745_data *data, int val, int val2)
> +{
> + struct device *dev = data->dev;
> + int ret;
> + int value;
> + int current_int_time, current_hwgain_sel, current_hwgain;
> + int new_hwgain, new_hwgain_sel, new_int_time_sel;
> + int req_int_time = (1000000 * val) + val2;
> +
> + if (!iio_gts_valid_time(&data->gts, req_int_time)) {
> + dev_dbg(dev, "Unsupported integration time requested: %d\n",
> + req_int_time);
> + return -EINVAL;
> + }
> +
> + ret = bh1745_get_int_time(data, ¤t_int_time);
> + if (ret)
> + return ret;
> +
> + if (current_int_time == req_int_time)
> + return 0;
> +
> + ret = regmap_read(data->regmap, BH1745_MODE_CTRL2, &value);
> + if (ret)
> + return ret;
> +
> + current_hwgain_sel = FIELD_GET(BH1745_CTRL2_ADC_GAIN_MASK, value);
> + current_hwgain = iio_gts_find_gain_by_sel(&data->gts, current_hwgain_sel);
> + ret = iio_gts_find_new_gain_by_old_gain_time(&data->gts, current_hwgain,
> + current_int_time, req_int_time,
> + &new_hwgain);
> + if (new_hwgain < 0) {
Typo in debug message: corresponding. I would recommend you to pass
codespell to checkpatch. It will often catch such things.
> + dev_dbg(dev, "No corrosponding gain for requested integration time\n");
> + return ret;
> + }
> +
...
> +static int bh1745_write_raw_get_fmt(struct iio_dev *indio_dev,
Nit: the alignment seems to be a bit off here.
> + struct iio_chan_spec const *chan,
> + long mask)
> +{
> + switch (mask) {
> + case IIO_CHAN_INFO_SCALE:
> + return IIO_VAL_INT;
> +
> + case IIO_CHAN_INFO_INT_TIME:
> + return IIO_VAL_INT_PLUS_MICRO;
> +
> + default:
> + return -EINVAL;
> + }
> +}
> +
...
> +static int bh1745_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)
> +{
> + struct bh1745_data *data = iio_priv(indio_dev);
> + int value;
> +
> + if (state == 0)
> + return regmap_clear_bits(data->regmap, BH1745_INTR, BH1745_INTR_ENABLE);
> +
> + if (state == 1) {
Nit: empty line at the beginning of the scope.
> +
> + /* 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));
> +
> + 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_CLEAR:
> + return regmap_write(data->regmap, BH1745_INTR,
> + value | FIELD_PREP(BH1745_INTR_SOURCE_MASK,
> + BH1745_INTR_SOURCE_CLEAR));
> +
> + default:
> + return -EINVAL;
> + }
> + }
> +
> + return -EINVAL;
> +}
> +
>
Best regards,
Javier Carrasco
next prev parent reply other threads:[~2024-07-19 16:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-18 22:02 [PATCH v8 1/2] dt-bindings: iio: light: ROHM BH1745 Mudit Sharma
2024-07-18 22:02 ` [PATCH v8 2/2] iio: light: ROHM BH1745 colour sensor Mudit Sharma
2024-07-19 16:02 ` Javier Carrasco [this message]
2024-07-20 18:29 ` Mudit Sharma
2024-07-20 16:29 ` Jonathan Cameron
2024-07-20 18:25 ` Mudit Sharma
2024-08-05 10:28 ` Matti Vaittinen
2024-08-06 20:45 ` Mudit Sharma
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=2505dee2-c503-4566-a4ef-73103da9479d@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=mazziesaccount@gmail.com \
--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).