linux/rust/kernel/io
FUJITA Tomonori 349a642565 rust: Add read_poll_timeout function
Add read_poll_timeout function which polls periodically until a
condition is met, an error occurs, or the 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@kernel.org>
Reviewed-by: Fiona Behrens <me@kloenk.dev>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Tested-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Tested-by: Daniel Almeida <daniel.almeida@collabora.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Link: https://lore.kernel.org/r/20250821002055.3654160-3-fujita.tomonori@gmail.com
[ Fix a minor typo and add missing backticks. - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2025-08-21 21:09:48 +02:00
..
mem.rs rust: io: fix broken intra-doc links to platform::Device 2025-07-22 11:08:59 +02:00
poll.rs rust: Add read_poll_timeout function 2025-08-21 21:09:48 +02:00
resource.rs rust: io: fix broken intra-doc link to missing flags module 2025-07-22 11:08:59 +02:00