From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: raskar.shree97@gmail.com
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
skhan@linuxfoundation.org, david.hunter.linux@gmail.com,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 2/5] iio: proximity: rfd77402: Use kernel helper for result polling
Date: Wed, 21 Jan 2026 11:05:19 +0200 [thread overview]
Message-ID: <aXCWz6O2CdU_Sp8r@smile.fi.intel.com> (raw)
In-Reply-To: <20260121-b4-rfd77402_v5-v6-2-5b944d0605dd@gmail.com>
On Wed, Jan 21, 2026 at 02:05:42AM +0530, Shrikant Raskar via B4 Relay wrote:
> Replace the manually written polling loop with read_poll_timeout(),
> the kernel's standard helper for waiting on hardware status.
> Move the polling logic into a dedicated helper function, as it will
> be reused by future updates.
>
> This makes the code easier to read and avoids repeating the same
> polling code in the driver.
It has some repetitions, I would rephrase as:
Replace the manually written polling loop with read_poll_timeout(),
the kernel's standard helper for waiting on hardware status. This
makes the code easier to read.
Move the polling logic into a dedicated helper function, as it will
be reused by future updates.
(also mind the blank lines and paragraphs).
...
> +static int rfd77402_wait_for_result(struct rfd77402_data *data)
> {
> + struct i2c_client *client = data->client;
> + int ret;
I would named it "data" to distinguish from the usual returned code of the calls,
so like in more verbose case
int data;
int ret;
ret = read_poll_timeout(..., data, data & ..., ...);
if (data < 0)
return data;
if (ret)
return ret;
> + return read_poll_timeout(i2c_smbus_read_byte_data, ret,
> + ret & RFD77402_ICSR_RESULT,
'data' (ex-"ret") may be negative and this will be triggered.
I think you want 'data < 0 || (data & RFD77402_ICSR_RESULT)
> + 10 * USEC_PER_MSEC,
> + 10 * 10 * USEC_PER_MSEC,
This makes sleeps shorter by 2. Why?
> + false,
> + client, RFD77402_ICSR);
> +}
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-01-21 9:05 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-20 20:35 [PATCH v6 0/5] iio: proximity: Add interrupt support for RFD77402 Shrikant Raskar via B4 Relay
2026-01-20 20:35 ` [PATCH v6 1/5] iio: proximity: rfd77402: Reorder header includes Shrikant Raskar via B4 Relay
2026-01-21 8:54 ` Andy Shevchenko
2026-01-22 20:57 ` Jonathan Cameron
2026-01-23 3:42 ` Shrikant
2026-01-23 9:59 ` Jonathan Cameron
2026-01-20 20:35 ` [PATCH v6 2/5] iio: proximity: rfd77402: Use kernel helper for result polling Shrikant Raskar via B4 Relay
2026-01-21 9:05 ` Andy Shevchenko [this message]
2026-01-24 16:56 ` Shrikant
2026-01-26 9:44 ` Andy Shevchenko
2026-01-26 15:28 ` Shrikant
2026-01-26 16:11 ` Andy Shevchenko
2026-01-20 20:35 ` [PATCH v6 3/5] iio: proximity: rfd77402: Use devm-managed mutex initialization Shrikant Raskar via B4 Relay
2026-01-21 9:16 ` Andy Shevchenko
2026-01-20 20:35 ` [PATCH v6 4/5] iio: proximity: rfd77402: Document device private data structure Shrikant Raskar via B4 Relay
2026-01-21 9:18 ` Andy Shevchenko
2026-01-22 17:42 ` Shrikant
2026-01-20 20:35 ` [PATCH v6 5/5] iio: proximity: rfd77402: Add interrupt handling support Shrikant Raskar via B4 Relay
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=aXCWz6O2CdU_Sp8r@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=david.hunter.linux@gmail.com \
--cc=dlechner@baylibre.com \
--cc=jic23@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=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