Skip to contentSkip to conversation

rust/drm: Fixup import styles

PATCH Applied Lyude Paul 3 participants 5 messages Jan 22 – Feb 24

Subsystems (3)

v2 of 3 Applied Latest is v3 →

lore
Share & tools
lore

Lyude Paul

author
#0 lore raw

PATCH v2 1/2 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
index 3ce8f62a00569..23c457c90a6ab 100644
@@ -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
index f30ee4c6245cd..c8ec5c0819a06 100644
@@ -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
index 8c46f8d519516..7dade6dfa1ba2 100644
@@ -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
index d49a9ba026356..56b7641b1405e 100644
@@ -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
author
#1 lore raw

PATCH v2 2/2 rust/drm: Remove imports covered by prelude::*

This just removes any explicit imports of items in files that are already being pulled in by use prelude::*;.

There should be no functional changes in this patch.

---
 rust/kernel/drm/device.rs  |  5 +----
 rust/kernel/drm/driver.rs  | 10 +++-------
 rust/kernel/drm/file.rs    |  6 +-----
 rust/kernel/drm/gem/mod.rs |  6 +-----
 4 files changed, 6 insertions(+), 21 deletions(-)
rust/kernel/drm/device.rs +1 -4
index 23c457c90a6ab..30116d78cabe0 100644
@@ -12,10 +12,7 @@
         self,
         driver::AllocImpl, //
     },
-    error::{
-        from_err_ptr,
-        Result, //
-    },
+    error::from_err_ptr,
     prelude::*,
     sync::aref::{
         ARef,
rust/kernel/drm/driver.rs +3 -7
index c8ec5c0819a06..2940fece7d59e 100644
@@ -8,15 +8,11 @@
     bindings,
     device,
     devres,
-    drm, //
-    error::{
-        to_result,
-        Result, //
-    },
+    drm,
+    error::to_result,
     prelude::*,
-    sync::aref::ARef,
+    sync::aref::ARef, //
 };
-use macros::vtable;
 
 /// Driver use the GEM memory manager. This should be set for all modern drivers.
 pub(crate) const FEAT_GEM: u32 = bindings::drm_driver_feature_DRIVER_GEM;
rust/kernel/drm/file.rs +1 -5
index 7dade6dfa1ba2..10160601ce5af 100644
@@ -7,14 +7,10 @@
 use crate::{
     bindings,
     drm,
-    error::Result,
     prelude::*,
     types::Opaque, //
 };
-use core::{
-    marker::PhantomData,
-    pin::Pin, //
-};
+use core::marker::PhantomData;
 
 /// 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 +1 -5
index 56b7641b1405e..b4199945db378 100644
@@ -5,7 +5,6 @@
 //! C header: [`include/drm/drm_gem.h`](srctree/include/drm/drm_gem.h)
 
 use crate::{
-    alloc::flags::*,
     bindings,
     drm::{
         self,
@@ -14,10 +13,7 @@
             AllocOps, //
         },
     },
-    error::{
-        to_result,
-        Result, //
-    },
+    error::to_result,
     prelude::*,
     sync::aref::{
         ARef,
Signature · 1 line
2.52.0
maintainer Applied
#2 lore raw

Re: [PATCH v2 2/2] rust/drm: Remove imports covered by prelude::*

Quoted 6 lines · Lyude Paul

This just removes any explicit imports of items in files that are already being pulled in by use prelude::*;.

There should be no functional changes in this patch.

Applied to drm-rust-next, thanks!

reviewer
#3 lore raw
In reply to Lyude Paul
Quoted 18 lines · Lyude Paul

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 +0 -0
index 3ce8f62a00569..23c457c90a6ab 100644

rust/kernel/drm/device.rs line 10

Quoted 9 lines
rust/kernel/drm/device.rs +2 -4
@@ -6,15 +6,32 @@
 
 use crate::{
     alloc::allocator::Kmalloc,
-    bindings, device, drm,
-    drm::driver::AllocImpl,
-    error::from_err_ptr,
-    error::Result,
+    bindings,
+    device, //

I think this // is supposed to go to the last item in the import?

Best,
Gary

Quoted 116 lines
rust/kernel/drm/device.rs +21 -2
+    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
index f30ee4c6245cd..c8ec5c0819a06 100644
@@ -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
index 8c46f8d519516..7dade6dfa1ba2 100644
@@ -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
index d49a9ba026356..56b7641b1405e 100644
@@ -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