Re: [PATCH v2 3/4] iio: proximity: rfd77402: Move polling logic into helper

From: Andy Shevchenko

Date: Sun Nov 30 2025 - 11:52:40 EST


On Sun, Nov 30, 2025 at 5:37 PM Shrikant Raskar
<raskar.shree97@xxxxxxxxx> wrote:
>
> This change extracts the polling logic into a dedicated helper,

Imperative voice.

> rfd77402_result_polling(), which improves readability and keeps
> rfd77402_measure() focused on the high-level measurement flow.
>
> This refactoring is also a necessary preparation step for adding
> interrupt-based result handling in a follow-up patch.

...

> + while (tries-- > 0) {
> + ret = i2c_smbus_read_byte_data(client, RFD77402_ICSR);
> + if (ret < 0)
> + return ret;
> +
> + if (ret & RFD77402_ICSR_RESULT)
> + return 0;
> +
> + msleep(20);
> + }
> +
> + return -ETIMEDOUT;

Reimplementation of one macro from iopoll.h. Include that and use a
single call, will be something like

return read_poll_timeout(...);

...

> + ret = rfd77402_result_polling(client);

Ah, even better, you don't need a function for that at all. Just use
that macro here inline.

> + if (ret < 0)
> goto err;

--
With Best Regards,
Andy Shevchenko