rust/drm: Fixup import styles
Subsystems (3)
PATCH 1/1 rust/drm: Fixup import styles
This is to match
https://docs.kernel.org/rust/coding-guidelines.html#imports
There should be no functional changes in this patch.
--- rust/kernel/drm/device.rs | 29 +++++++++++++++++++++++------ rust/kernel/drm/driver.rs | 10 ++++++++-- rust/kernel/drm/file.rs | 14 +++++++++++--- rust/kernel/drm/gem/mod.rs | 25 ++++++++++++++++++++----- 4 files changed, 62 insertions(+), 16 deletions(-)
rust/kernel/drm/device.rs +23 -6
@@ -6,15 +6,32 @@use crate ::{ alloc::allocator::Kmalloc , - bindings, device, drm, - drm::driver::AllocImpl , - error::from_err_ptr, - error::Result , + bindings, + device,// + drm::{ + self, + driver::AllocImpl ,// + }, + error::{ + from_err_ptr, +Result ,// + }, prelude::*, - sync::aref::{ARef ,AlwaysRefCounted }, + sync::aref::{ +ARef , +AlwaysRefCounted ,// + }, types::Opaque , }; -use core::{alloc::Layout , mem, ops::Deref , ptr, ptr::NonNull }; +use core::{ + alloc::Layout , + mem, + ops::Deref , + ptr::{ + self, +NonNull ,// + }, +};#[cfg( CONFIG_DRM_LEGACY )] macro_rules! drm_legacy_fields {
rust/kernel/drm/driver.rs +8 -2
@@ -5,8 +5,14 @@//! C header: [`include/drm/drm_drv.h`](srctree/include/drm/drm_drv.h) use crate ::{ - bindings, device, devres, drm, - error::{to_result,Result }, + bindings, + device, + devres, + drm,// + error::{ + to_result, +Result ,// + }, prelude::*, sync::aref::ARef , };
rust/kernel/drm/file.rs +11 -3
@@ -4,9 +4,17 @@//! //! C header: [`include/drm/drm_file.h`](srctree/include/drm/drm_file.h) -use crate ::{bindings, drm, error::Result , prelude::*, types::Opaque }; -use core::marker::PhantomData ; -use core::pin::Pin ; +use crate ::{ + bindings, + drm, + error::Result , + prelude::*, + types::Opaque ,// +}; +use core::{ + marker::PhantomData , + pin::Pin ,// +};/// Trait that must be implemented by DRM drivers to represent a DRM File (a client instance). pub trait DriverFile {
rust/kernel/drm/gem/mod.rs +20 -5
@@ -6,14 +6,29 @@use crate ::{ alloc::flags::*, - bindings, drm, - drm::driver::{AllocImpl ,AllocOps }, - error::{to_result,Result }, + bindings, + drm::{ + self, + driver::{ +AllocImpl , +AllocOps ,// + }, + }, + error::{ + to_result, +Result ,// + }, prelude::*, - sync::aref::{ARef ,AlwaysRefCounted }, + sync::aref::{ +ARef , +AlwaysRefCounted ,// + }, types::Opaque , }; -use core::{ops::Deref , ptr::NonNull }; +use core::{ + ops::Deref , + ptr::NonNull ,// +};/// A type alias for retrieving a [`Driver`]s [`DriverFile`] implementation from its /// [`DriverObject`] implementation.
base-commit: 6ea52b6d8f33ae627f4dcf43b12b6e713a8b9331
Signature · 1 line
2.52.0
Danilo Krummrich
maintainerQuoted 4 lines · Lyude Paul
This is to match
https://docs.kernel.org/rust/coding-guidelines.html#importsThere should be no functional changes in this patch.
Thanks! While at it, can you please drop imports that are in prelude and use prelude instead?
Quoted 9 lines · Danilo Krummrich
Quoted 4 lines · Lyude Paul
This is to match
https://docs.kernel.org/rust/coding-guidelines.html#importsThere should be no functional changes in this patch.
Thanks! While at it, can you please drop imports that are in prelude and use
prelude instead?
Just a random musing - it would actually be quite nice if we could have some sort of automated style check for this. I have to assume the linux kernel probably isn't the only project out there with its own prelude…
Quoted 4 lines · On Thu, Jan 22, 2026 at 10:34 PM <[email protected]> wrote:
Just a random musing - it would actually be quite nice if we could have some sort of automated style check for this. I have to assume the linux kernel probably isn't the only project out there with its own prelude…
Yeah, that would be quite nice indeed -- we have discussed this a few times (most recently a couple weeks ago, including whether Klint could be used for that and for detecting "long import paths", i.e. when we have a re-export we prefer, but that has edge cases; as well as related bits like a klint::moved annotation -- Cc'ing Gary).
Cheers,
Miguel
Gary Guo
reviewerQuoted 11 lines · Miguel Ojeda
Quoted 4 lines · On Thu, Jan 22, 2026 at 10:34 PM <[email protected]> wrote:
Just a random musing - it would actually be quite nice if we could have some sort of automated style check for this. I have to assume the linux kernel probably isn't the only project out there with its own prelude…
Yeah, that would be quite nice indeed -- we have discussed this a few times (most recently a couple weeks ago, including whether Klint could be used for that and for detecting "long import paths", i.e. when we have a re-export we prefer, but that has edge cases; as well as related bits like a
klint::movedannotation -- Cc'ing Gary).
This is tracked in https://github.com/Rust-for-Linux/klint/issues/5.
Best,
Gary
Quoted 3 lines
Cheers,
Miguel
Quoted 2 lines · Gary Guo
This is tracked in https://github.com/Rust-for-Linux/klint/issues/5.
Linked, thanks!
Cheers,
Miguel