[PATCH v6 2/3] rust/drm/gem: Add DriverAllocImpl type alias

From: Lyude Paul

Date: Thu May 07 2026 - 18:01:55 EST


This is just a type alias that resolves into the AllocImpl for a given
T: drm::gem::DriverObject

Signed-off-by: Lyude Paul <lyude@xxxxxxxxxx>
Reviewed-by: Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>
---
rust/kernel/drm/gem/mod.rs | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
index 75acda7ba5001..568b5c08019e7 100644
--- a/rust/kernel/drm/gem/mod.rs
+++ b/rust/kernel/drm/gem/mod.rs
@@ -73,6 +73,11 @@ unsafe fn dec_ref(obj: core::ptr::NonNull<Self>) {
/// [`DriverFile`]: drm::file::DriverFile
pub type DriverFile<T> = drm::File<<<T as DriverObject>::Driver as drm::Driver>::File>;

+/// A type alias for retrieving the current [`AllocImpl`] for a given [`DriverObject`].
+///
+/// [`Driver`]: drm::Driver
+pub type DriverAllocImpl<T> = <<T as DriverObject>::Driver as drm::Driver>::Object;
+
/// GEM object functions, which must be implemented by drivers.
pub trait DriverObject: Sync + Send + Sized {
/// Parent `Driver` for this object.
@@ -89,12 +94,12 @@ fn new(
) -> impl PinInit<Self, Error>;

/// Open a new handle to an existing object, associated with a File.
- fn open(_obj: &<Self::Driver as drm::Driver>::Object, _file: &DriverFile<Self>) -> Result {
+ fn open(_obj: &DriverAllocImpl<Self>, _file: &DriverFile<Self>) -> Result {
Ok(())
}

/// Close a handle to an existing object, associated with a File.
- fn close(_obj: &<Self::Driver as drm::Driver>::Object, _file: &DriverFile<Self>) {}
+ fn close(_obj: &DriverAllocImpl<Self>, _file: &DriverFile<Self>) {}
}

/// Trait that represents a GEM object subtype
--
2.54.0