Re: [PATCH v4 3/4] iio: proximity: rfd77402: Use kernel helper for result polling
From: Andy Shevchenko
Date: Fri Jan 02 2026 - 07:28:56 EST
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