Skip to contentSkip to conversation

rust: io: cleanup imports and use "kernel vertical" style

PATCH In review Danilo Krummrich 2 participants 4 messages Nov 4, 2025 – Nov 11, 2025

Subsystems (2)
lore
Share & tools
lore

Danilo Krummrich

author maintainer
#0 lore raw

PATCH 1/1 rust: io: cleanup imports and use "kernel vertical" style

Commit 46f045db5a94 ("rust: Add read_poll_timeout_atomic function") initiated the first import change in the I/O module using the agreed "kernel vertical" import style [1].

For consistency throughout the module, adjust all other imports accordingly.

While at it, drop unnecessary imports covered by prelude::*.

---
 rust/kernel/io.rs          |  6 ++++--
 rust/kernel/io/mem.rs      | 28 ++++++++++++++++++----------
 rust/kernel/io/poll.rs     |  5 ++++-
 rust/kernel/io/resource.rs | 16 ++++++++++------
 4 files changed, 36 insertions(+), 19 deletions(-)
rust/kernel/io.rs +4 -2
index ee182b0b5452..1aa9495f7774 100644
@@ -4,8 +4,10 @@
 //!
 //! C header: [`include/asm-generic/io.h`](srctree/include/asm-generic/io.h)
 
-use crate::error::{code::EINVAL, Result};
-use crate::{bindings, build_assert, ffi::c_void};
+use crate::{
+    bindings,
+    prelude::*, //
+};
 
 pub mod mem;
 pub mod poll;
rust/kernel/io/mem.rs +18 -10
index 59096d579644..b03b82cd531b 100644
@@ -4,16 +4,24 @@
 
 use core::ops::Deref;
 
-use crate::c_str;
-use crate::device::Bound;
-use crate::device::Device;
-use crate::devres::Devres;
-use crate::io;
-use crate::io::resource::Region;
-use crate::io::resource::Resource;
-use crate::io::Io;
-use crate::io::IoRaw;
-use crate::prelude::*;
+use crate::{
+    c_str,
+    device::{
+        Bound,
+        Device, //
+    },
+    devres::Devres,
+    io::{
+        self,
+        resource::{
+            Region,
+            Resource, //
+        },
+        Io,
+        IoRaw, //
+    },
+    prelude::*,
+};
 
 /// An IO request for a specific device and resource.
 pub struct IoRequest<'a> {
rust/kernel/io/poll.rs +4 -1
index ebc29023d59d..e21ccf98b81a 100644
@@ -5,7 +5,10 @@
 //! C header: [`include/linux/iopoll.h`](srctree/include/linux/iopoll.h).
 
 use crate::{
-    error::{code::*, Result},
+    error::{
+        code::*,
+        Result, //
+    },
     processor::cpu_relax,
     task::might_sleep,
     time::{
rust/kernel/io/resource.rs +10 -6
index bea3ee0ed87b..81220493a7f3 100644
@@ -5,12 +5,16 @@
 //!
 //! C header: [`include/linux/ioport.h`](srctree/include/linux/ioport.h)
 
-use core::ops::Deref;
-use core::ptr::NonNull;
-
-use crate::prelude::*;
-use crate::str::{CStr, CString};
-use crate::types::Opaque;
+use core::{
+    ops::Deref,
+    ptr::NonNull, //
+};
+
+use crate::{
+    prelude::*,
+    str::CString,
+    types::Opaque, //
+};
 
 /// Resource Size type.
 ///
Signature · 1 line
2.51.2
author maintainer
#1 lore raw
Quoted 6 lines · Danilo Krummrich
rust/kernel/io/poll.rs +0 -0
index ebc29023d59d..e21ccf98b81a 100644
@@ -5,7 +5,10 @@
 //! C header: [`include/linux/iopoll.h`](srctree/include/linux/iopoll.h).

rust/kernel/io/poll.rs line 14

Quoted 10 lines
rust/kernel/io/poll.rs +4 -1
 
 use crate::{
-    error::{code::*, Result},
+    error::{
+        code::*,
+        Result, //
+    },
     processor::cpu_relax,
     task::might_sleep,
     time::{

Should instead be:

rust/kernel/io/poll.rs +1 -1
index ebc29023d59d..b1a2570364f4 100644
@@ -5,7 +5,7 @@
 //! C header: [`include/linux/iopoll.h`](srctree/include/linux/iopoll.h).
 
 use crate::{
-    error::{code::*, Result},
+    prelude::*,
     processor::cpu_relax,
     task::might_sleep,
     time::{
Reviewed-by
#2 lore raw
Quoted 11 lines · On Tue, 4 Nov 2025 17:25:11 +0100 Danilo Krummrich <[email protected]> wrote:
Quoted 10 lines · Danilo Krummrich
rust/kernel/io/poll.rs +0 -0
index ebc29023d59d..e21ccf98b81a 100644
@@ -5,7 +5,10 @@
 //! C header:

[include/linux/iopoll.h](srctree/include/linux/iopoll.h).
use crate::{

rust/kernel/io/poll.rs +1 -1
-    error::{code::*, Result},
+    error::{
Quoted 9 lines

rust/kernel/io/poll.rs line 11

Quoted 6 lines
rust/kernel/io/poll.rs +3 -0
+        code::*,
+        Result, //
+    },
     processor::cpu_relax,
     task::might_sleep,
     time::{

Should instead be:

LGTM. Tested on the driver-core-testing branch with this extra change.

Quoted 15 lines
rust/kernel/io/poll.rs +0 -0
index ebc29023d59d..b1a2570364f4 100644
@@ -5,7 +5,7 @@
 //! C header:

[include/linux/iopoll.h](srctree/include/linux/iopoll.h).

use crate::{

rust/kernel/io/poll.rs +1 -1
-    error::{code::*, Result},
+    prelude::*,
     processor::cpu_relax,
     task::might_sleep,
     time::{
author maintainer
#3 lore raw
In reply to Danilo Krummrich
Quoted 11 lines · Danilo Krummrich

Commit 46f045db5a94 ("rust: Add read_poll_timeout_atomic function") initiated the first import change in the I/O module using the agreed "kernel vertical" import style [1].

For consistency throughout the module, adjust all other imports accordingly.

While at it, drop unnecessary imports covered by prelude::*.

Applied to driver-core-testing, thanks!

[ Use prelude::* in io/poll.rs. - Danilo ]