From: Jonathan Cameron <jic23@kernel.org>
To: Shrikant Raskar via B4 Relay
<devnull+raskar.shree97.gmail.com@kernel.org>
Cc: raskar.shree97@gmail.com, "David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
skhan@linuxfoundation.org, david.hunter.linux@gmail.com,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 4/4] iio: proximity: rfd77402: Add interrupt handling support
Date: Sun, 11 Jan 2026 12:49:08 +0000 [thread overview]
Message-ID: <20260111124908.1adec88b@jic23-huawei> (raw)
In-Reply-To: <20260101-b4-rfd77402_irq-v4-4-42cd54359e9f@gmail.com>
On Thu, 01 Jan 2026 21:47:41 +0530
Shrikant Raskar via B4 Relay <devnull+raskar.shree97.gmail.com@kernel.org> wrote:
> From: Shrikant Raskar <raskar.shree97@gmail.com>
>
> Add interrupt handling support to enable event-driven data acquisition
> instead of continuous polling. This improves responsiveness, reduces
> CPU overhead, and supports low-power operation by allowing the system
> to remain idle until an interrupt occurs.
>
> Signed-off-by: Shrikant Raskar <raskar.shree97@gmail.com>
> ---
Hi Shrikant,
A few additional (some may overlap with Andy's) comments from me.
Thanks,
Jonathan
> +
> +static int rfd77402_wait_for_irq(struct rfd77402_data *data)
> +{
> + int ret;
Blank line here. Pretty much always the case are declarations
in kernel code.
> + /* As per datasheet, single measurement flow takes 100ms */
> + ret = wait_for_completion_timeout(&data->completion,
> + msecs_to_jiffies(100));
> + if (ret == 0)
> + return -ETIMEDOUT;
> +
> + return 0;
> +}
> static int rfd77402_init(struct i2c_client *client)
> {
> + struct iio_dev *indio_dev = i2c_get_clientdata(client);
> + struct rfd77402_data *data = iio_priv(indio_dev);
> int ret, i;
>
> ret = rfd77402_set_state(client, RFD77402_CMD_STANDBY,
> @@ -193,10 +263,24 @@ static int rfd77402_init(struct i2c_client *client)
> if (ret < 0)
> return ret;
>
> - /* configure INT pad as push-pull, active low */
> - ret = i2c_smbus_write_byte_data(client, RFD77402_ICSR,
> - RFD77402_ICSR_INT_MODE);
> - if (ret < 0)
> + if (data->irq_en) {
> + /* Enable interrupt mode:
/*
* Enable ...
is the comment syntax used in IIO.
> + * - Configure ICSR for auto-clear on read and
> + * push-pull output
> + * - Enable "result ready" interrupt in IER
> + */
> + ret = rfd77402_config_irq(client,
> + RFD77402_ICSR_CLR_CFG |
> + RFD77402_ICSR_INT_MODE,
> + RFD77402_IER_RESULT);
> + } else {
> + /* Disable all interrupts:
As above. Match local style for comments (which is not this!)
Oddly that was correct in v3 (indent is now fixed though)
> + * - Clear ICSR configuration
> + * - Disable all interrupts in IER
> + */
> + ret = rfd77402_config_irq(client, 0, 0);
> + }
> + if (ret)
> return ret;
>
> /* I2C configuration */
> @@ -271,7 +355,27 @@ static int rfd77402_probe(struct i2c_client *client)
>
> data = iio_priv(indio_dev);
> data->client = client;
> - mutex_init(&data->lock);
> + ret = devm_mutex_init(&client->dev, &data->lock);
> + if (ret)
> + return ret;
I'm not that fussy about it given it's so minor but this is an unrelated
changes so in ideal world would be a separate patch.
> +
> + init_completion(&data->completion);
> + i2c_set_clientdata(client, indio_dev);
> +
> + data->irq_en = false;
Not strictly necessary as it's kind of the obvious default and we
kzalloc data anyway so it's already false.
> + if (client->irq > 0) {
> + ret = devm_request_threaded_irq(&client->dev, client->irq,
> + NULL, rfd77402_interrupt_handler,
> + IRQF_ONESHOT,
> + "rfd77402", data);
> + if (ret)
> + return ret;
> +
> + data->irq_en = true;
> + dev_dbg(&client->dev, "Using interrupt mode\n");
> + } else {
> + dev_dbg(&client->dev, "Using polling mode\n");
> + }
>
> indio_dev->info = &rfd77402_info;
> indio_dev->channels = rfd77402_channels;
>
next prev parent reply other threads:[~2026-01-11 12:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-01 16:17 [PATCH v4 0/4] iio: proximity: Add interrupt support for RFD77402 Shrikant Raskar via B4 Relay
2026-01-01 16:17 ` [PATCH v4 1/4] dt-bindings: iio: proximity: Add RF Digital RFD77402 ToF sensor Shrikant Raskar via B4 Relay
2026-01-11 12:39 ` Jonathan Cameron
2026-01-01 16:17 ` [PATCH v4 2/4] iio: proximity: rfd77402: Add OF device ID for enumeration via DT Shrikant Raskar via B4 Relay
2026-01-01 16:17 ` [PATCH v4 3/4] iio: proximity: rfd77402: Use kernel helper for result polling Shrikant Raskar via B4 Relay
2026-01-02 12:24 ` Andy Shevchenko
2026-01-01 16:17 ` [PATCH v4 4/4] iio: proximity: rfd77402: Add interrupt handling support Shrikant Raskar via B4 Relay
2026-01-02 12:34 ` Andy Shevchenko
2026-01-06 0:09 ` Shrikant
2026-01-06 20:47 ` Andy Shevchenko
2026-01-11 12:36 ` Jonathan Cameron
2026-01-11 12:49 ` Jonathan Cameron [this message]
2026-01-02 12:26 ` [PATCH v4 0/4] iio: proximity: Add interrupt support for RFD77402 Andy Shevchenko
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=20260111124908.1adec88b@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=david.hunter.linux@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=devnull+raskar.shree97.gmail.com@kernel.org \
--cc=dlechner@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=raskar.shree97@gmail.com \
--cc=robh@kernel.org \
--cc=skhan@linuxfoundation.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