]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rust: simplify read_poll_timeout's example code
authorFUJITA Tomonori <fujita.tomonori@gmail.com>
Thu, 23 Oct 2025 06:11:24 +0000 (15:11 +0900)
committerDanilo Krummrich <dakr@kernel.org>
Sun, 26 Oct 2025 16:56:14 +0000 (17:56 +0100)
- Drop unnecessary Result's '<()>'
- Use '?' instead of match

Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
rust/kernel/io/poll.rs

index 613eb25047efc432ab96cbff7c8cff9b9db2c2d0..8f8886543f342fb0aa231bc032a7d4245a522151 100644 (file)
@@ -42,8 +42,8 @@ use crate::{
 ///
 /// const HW_READY: u16 = 0x01;
 ///
-/// fn wait_for_hardware<const SIZE: usize>(io: &Io<SIZE>) -> Result<()> {
-///     match read_poll_timeout(
+/// fn wait_for_hardware<const SIZE: usize>(io: &Io<SIZE>) -> Result {
+///     read_poll_timeout(
 ///         // The `op` closure reads the value of a specific status register.
 ///         || io.try_read16(0x1000),
 ///         // The `cond` closure takes a reference to the value returned by `op`
@@ -51,14 +51,8 @@ use crate::{
 ///         |val: &u16| *val == HW_READY,
 ///         Delta::from_millis(50),
 ///         Delta::from_secs(3),
-///     ) {
-///         Ok(_) => {
-///             // The hardware is ready. The returned value of the `op` closure
-///             // isn't used.
-///             Ok(())
-///         }
-///         Err(e) => Err(e),
-///     }
+///     )?;
+///     Ok(())
 /// }
 /// ```
 #[track_caller]