diff --git a/rust/kernel/drm/device.rs b/rust/kernel/drm/device.rs index 425c7f5c715af6e3eb5678746c52669d332af481..2000c2b4c36dc300a8d271ccfde6b67778317144 100644 --- a/rust/kernel/drm/device.rs +++ b/rust/kernel/drm/device.rs @@ -15,6 +15,7 @@ use crate::{ error::from_err_ptr, error::Result, types::{ARef, AlwaysRefCounted, ForeignOwnable, Opaque}, + sync::*, }; use core::{ ffi::c_void, @@ -161,6 +162,12 @@ impl<T: drm::drv::Driver> Device<T> { unsafe { <T::Data as ForeignOwnable>::from_foreign(drm.raw_data()) }; } + /// Returns a reference to the `event` spinlock + pub(crate) fn event_lock(&self) -> &SpinLockIrq<()> { + // SAFETY: `event_lock` is initialized for as long as `self` is exposed to users + unsafe { SpinLockIrq::from_raw(&mut (*self.as_raw()).event_lock) } + } + pub(crate) const fn has_kms() -> bool { <T::Kms as KmsImplPrivate>::MODE_CONFIG_OPS.is_some() }