public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
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>,
	"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 3/4] iio: proximity: rfd77402: Use kernel helper for result polling
Date: Fri, 2 Jan 2026 14:24:26 +0200	[thread overview]
Message-ID: <aVe4-rUD9aM58xhT@smile.fi.intel.com> (raw)
In-Reply-To: <20260101-b4-rfd77402_irq-v4-3-42cd54359e9f@gmail.com>

On Thu, Jan 01, 2026 at 09:47:40PM +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.
> This makes the code easier to read and avoids repeating the same
> polling code in the driver.

...

> index 3262af6f6882..496c1412ebf8 100644
> --- a/drivers/iio/proximity/rfd77402.c
> +++ b/drivers/iio/proximity/rfd77402.c
> @@ -13,6 +13,7 @@
>  #include <linux/module.h>
>  #include <linux/i2c.h>
>  #include <linux/delay.h>
> +#include <linux/iopoll.h>

Even if the original is unsorted, try to place the new inclusion into the
longest sorted (but maybe be sparse) chain. From the given context it might
be somewhere before module.h or less likely after i2c.h.

>  #include <linux/iio/iio.h>

...

> +	/* Poll ICSR until RESULT bit is set */
> +	ret = read_poll_timeout(i2c_smbus_read_byte_data, ret,
> +				ret & RFD77402_ICSR_RESULT,
> +				10000,    /* sleep: 10ms */
> +				100000,   /* timeout: 100ms */

Instead of the noisy comments use proper multipliers

 10 * USEC_PER_MSEC
 10 * 10 * USEC_PER_MSEC

(yes, 10 * 10 is to distinguish between one iteration delay and the whole op
 timeout.)

> +				false,
> +				client, RFD77402_ICSR);
> +	if (ret < 0)
>  		goto err;

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-01-02 12:24 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 [this message]
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
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=aVe4-rUD9aM58xhT@smile.fi.intel.com \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=david.hunter.linux@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --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