Skip to contentSkip to conversation

rust: pci: use "kernel vertical" style for imports

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

Subsystems (3)
lore
Share & tools
lore

Danilo Krummrich

author maintainer
#0 lore raw

PATCH 1/1 rust: pci: use "kernel vertical" style for imports

Convert all imports in the PCI Rust module to use "kernel vertical" style.

With this subsequent patches neither introduce unrelated changes nor leave an inconsistent import pattern.

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

---
 rust/kernel/pci.rs     | 35 +++++++++++++++++++++++++++--------
 rust/kernel/pci/id.rs  |  5 ++++-
 rust/kernel/pci/io.rs  | 13 ++++++++-----
 rust/kernel/pci/irq.rs | 14 +++++++++-----
 4 files changed, 48 insertions(+), 19 deletions(-)
rust/kernel/pci.rs +27 -8
index b68ef4e575fc..410b79d46632 100644
@@ -5,27 +5,46 @@
 //! C header: [`include/linux/pci.h`](srctree/include/linux/pci.h)
 
 use crate::{
-    bindings, container_of, device,
-    device_id::{RawDeviceId, RawDeviceIdIndex},
+    bindings,
+    container_of,
+    device,
+    device_id::{
+        RawDeviceId,
+        RawDeviceIdIndex, //
+    },
     driver,
-    error::{from_result, to_result, Result},
+    error::{
+        from_result,
+        to_result, //
+    },
+    prelude::*,
     str::CStr,
     types::Opaque,
-    ThisModule,
+    ThisModule, //
 };
 use core::{
     marker::PhantomData,
-    ptr::{addr_of_mut, NonNull},
+    ptr::{
+        addr_of_mut,
+        NonNull, //
+    },
 };
-use kernel::prelude::*;
 
 mod id;
 mod io;
 mod irq;
 
-pub use self::id::{Class, ClassMask, Vendor};
+pub use self::id::{
+    Class,
+    ClassMask,
+    Vendor, //
+};
 pub use self::io::Bar;
-pub use self::irq::{IrqType, IrqTypes, IrqVector};
+pub use self::irq::{
+    IrqType,
+    IrqTypes,
+    IrqVector, //
+};
 
 /// An adapter for the registration of PCI drivers.
 pub struct Adapter<T: Driver>(T);
rust/kernel/pci/id.rs +4 -1
index 7f2a7f57507f..a1de70b2176a 100644
@@ -4,7 +4,10 @@
 //!
 //! This module contains PCI class codes, Vendor IDs, and supporting types.
 
-use crate::{bindings, error::code::EINVAL, error::Error, prelude::*};
+use crate::{
+    bindings,
+    prelude::*, //
+};
 use core::fmt;
 
 /// PCI device class codes.
rust/kernel/pci/io.rs +8 -5
index 3684276b326b..0d55c3139b6f 100644
@@ -4,14 +4,17 @@
 
 use super::Device;
 use crate::{
-    bindings, device,
+    bindings,
+    device,
     devres::Devres,
-    io::{Io, IoRaw},
-    str::CStr,
-    sync::aref::ARef,
+    io::{
+        Io,
+        IoRaw, //
+    },
+    prelude::*,
+    sync::aref::ARef, //
 };
 use core::ops::Deref;
-use kernel::prelude::*;
 
 /// A PCI BAR to perform I/O-Operations on.
 ///
rust/kernel/pci/irq.rs +9 -5
index 782a524fe11c..063b6a5101ff 100644
@@ -4,16 +4,20 @@
 
 use super::Device;
 use crate::{
-    bindings, device,
+    bindings,
+    device,
     device::Bound,
     devres,
-    error::{to_result, Result},
-    irq::{self, IrqRequest},
+    error::to_result,
+    irq::{
+        self,
+        IrqRequest, //
+    },
+    prelude::*,
     str::CStr,
-    sync::aref::ARef,
+    sync::aref::ARef, //
 };
 use core::ops::RangeInclusive;
-use kernel::prelude::*;
 
 /// IRQ type flags for PCI interrupt allocation.
 #[derive(Debug, Clone, Copy)]
Signature · 1 line
2.51.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · On Wed, 5 Nov 2025 13:03:28 +0100 Danilo Krummrich <[email protected]> wrote:

Convert all imports in the PCI Rust module to use "kernel vertical" style.

With this subsequent patches neither introduce unrelated changes nor leave an inconsistent import pattern.

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

Looking good to me and test on the driver-core-testing branch.

Quoted 141 lines
---
 rust/kernel/pci.rs     | 35 +++++++++++++++++++++++++++--------
 rust/kernel/pci/id.rs  |  5 ++++-
 rust/kernel/pci/io.rs  | 13 ++++++++-----
 rust/kernel/pci/irq.rs | 14 +++++++++-----
 4 files changed, 48 insertions(+), 19 deletions(-)
rust/kernel/pci.rs +27 -8
index b68ef4e575fc..410b79d46632 100644
@@ -5,27 +5,46 @@
 //! C header: [`include/linux/pci.h`](srctree/include/linux/pci.h)
 
 use crate::{
-    bindings, container_of, device,
-    device_id::{RawDeviceId, RawDeviceIdIndex},
+    bindings,
+    container_of,
+    device,
+    device_id::{
+        RawDeviceId,
+        RawDeviceIdIndex, //
+    },
     driver,
-    error::{from_result, to_result, Result},
+    error::{
+        from_result,
+        to_result, //
+    },
+    prelude::*,
     str::CStr,
     types::Opaque,
-    ThisModule,
+    ThisModule, //
 };
 use core::{
     marker::PhantomData,
-    ptr::{addr_of_mut, NonNull},
+    ptr::{
+        addr_of_mut,
+        NonNull, //
+    },
 };
-use kernel::prelude::*;
 
 mod id;
 mod io;
 mod irq;
 
-pub use self::id::{Class, ClassMask, Vendor};
+pub use self::id::{
+    Class,
+    ClassMask,
+    Vendor, //
+};
 pub use self::io::Bar;
-pub use self::irq::{IrqType, IrqTypes, IrqVector};
+pub use self::irq::{
+    IrqType,
+    IrqTypes,
+    IrqVector, //
+};
 
 /// An adapter for the registration of PCI drivers.
 pub struct Adapter<T: Driver>(T);
rust/kernel/pci/id.rs +0 -0
index 7f2a7f57507f..a1de70b2176a 100644
@@ -4,7 +4,10 @@
 //!
 //! This module contains PCI class codes, Vendor IDs, and supporting

types.

rust/kernel/pci/id.rs +4 -1
-use crate::{bindings, error::code::EINVAL, error::Error, prelude::*};
+use crate::{
+    bindings,
+    prelude::*, //
+};
 use core::fmt;
 
 /// PCI device class codes.
rust/kernel/pci/io.rs +8 -5
index 3684276b326b..0d55c3139b6f 100644
@@ -4,14 +4,17 @@
 
 use super::Device;
 use crate::{
-    bindings, device,
+    bindings,
+    device,
     devres::Devres,
-    io::{Io, IoRaw},
-    str::CStr,
-    sync::aref::ARef,
+    io::{
+        Io,
+        IoRaw, //
+    },
+    prelude::*,
+    sync::aref::ARef, //
 };
 use core::ops::Deref;
-use kernel::prelude::*;
 
 /// A PCI BAR to perform I/O-Operations on.
 ///
rust/kernel/pci/irq.rs +9 -5
index 782a524fe11c..063b6a5101ff 100644
@@ -4,16 +4,20 @@
 
 use super::Device;
 use crate::{
-    bindings, device,
+    bindings,
+    device,
     device::Bound,
     devres,
-    error::{to_result, Result},
-    irq::{self, IrqRequest},
+    error::to_result,
+    irq::{
+        self,
+        IrqRequest, //
+    },
+    prelude::*,
     str::CStr,
-    sync::aref::ARef,
+    sync::aref::ARef, //
 };
 use core::ops::RangeInclusive;
-use kernel::prelude::*;
 
 /// IRQ type flags for PCI interrupt allocation.
 #[derive(Debug, Clone, Copy)]
author maintainer
#2 lore raw
In reply to Danilo Krummrich
Quoted 10 lines · Danilo Krummrich

Convert all imports in the PCI Rust module to use "kernel vertical" style.

With this subsequent patches neither introduce unrelated changes nor leave an inconsistent import pattern.

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

Applied to driver-core-testing, thanks!