diff mbox series

[RFC,v3,22/33] rust: drm/kms: Add RawCrtcState::active()

Message ID 20250305230406.567126-23-lyude@redhat.com (mailing list archive)
State New
Headers show
Series Rust bindings for KMS + RVKMS | expand

Commit Message

Lyude Paul March 5, 2025, 10:59 p.m. UTC
A binding for checking drm_crtc_state.active.

Signed-off-by: Lyude Paul <lyude@redhat.com>
---
 rust/kernel/drm/kms/crtc.rs | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/rust/kernel/drm/kms/crtc.rs b/rust/kernel/drm/kms/crtc.rs
index 50f5b68f4a3fe..99719c4e288e6 100644
--- a/rust/kernel/drm/kms/crtc.rs
+++ b/rust/kernel/drm/kms/crtc.rs
@@ -607,6 +607,14 @@  fn crtc(&self) -> &Self::Crtc {
         //   state
         unsafe { <Self::Crtc as AsRawCrtc>::from_raw((*self.as_raw()).crtc) }
     }
+
+    /// Returns whether or not the CRTC is active in this atomic state.
+    fn active(&self) -> bool {
+        // SAFETY: `active` and the rest of its containing bitfield can only be modified from the
+        // atomic check context, and are invariant beyond that point - so our interface can ensure
+        // this access is serialized
+        unsafe { (*self.as_raw()).active }
+    }
 }
 impl<T: AsRawCrtcState> RawCrtcState for T {}