On 5/19/26 19:58, Gary Guo wrote:
On Tue May 19, 2026 at 7:26 AM BST, Alvin Sun wrote:
Add a `ThisModule` associated type bound by `ModuleMetadata` to the
`drm::Driver` trait, allowing DRM drivers to expose their module
pointer for use in file operations.
FWIW, I was considering adding this automatically to the `#[vtable]` macro
(associated types/consts won't have any costs if they're unused anyway).

That's a great suggestion. I've implemented it in v2 — please review.

Best regards,
Alvin


But requiring an explicit specification isn't too bad either.

Best,
Gary

Signed-off-by: Alvin Sun <[email protected]>
---
  rust/kernel/drm/driver.rs | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/rust/kernel/drm/driver.rs b/rust/kernel/drm/driver.rs
index 5233bdebc9fcd..c798961650c1a 100644
--- a/rust/kernel/drm/driver.rs
+++ b/rust/kernel/drm/driver.rs
@@ -115,6 +115,9 @@ pub trait Driver {
/// IOCTL list. See `kernel::drm::ioctl::declare_drm_ioctls!{}`.
      const IOCTLS: &'static [drm::ioctl::DrmIoctlDescriptor];
+
+    /// The module implementing this driver.
+    type ThisModule: crate::ModuleMetadata;
  }
/// The registration type of a `drm::Device`.

Reply via email to