Re: [PATCH v2 2/2] rust: Add read_poll_timeout functions

From: Alice Ryhl
Date: Wed Aug 20 2025 - 06:04:34 EST


On Sun, Aug 17, 2025 at 01:47:23PM +0900, FUJITA Tomonori wrote:
> Add read_poll_timeout function which poll periodically until a
> condition is met or a timeout is reached.
>
> The C's read_poll_timeout (include/linux/iopoll.h) is a complicated
> macro and a simple wrapper for Rust doesn't work. So this implements
> the same functionality in Rust.
>
> The C version uses usleep_range() while the Rust version uses
> fsleep(), which uses the best sleep method so it works with spans that
> usleep_range() doesn't work nicely with.
>
> The sleep_before_read argument isn't supported since there is no user
> for now. It's rarely used in the C version.
>
> Reviewed-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
> Reviewed-by: Fiona Behrens <me@xxxxxxxxxx>
> Tested-by: Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxx>

Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>