Skip to content

Commit 89b4964

Browse files
LyudeDanilo Krummrich
authored andcommitted
rust: drm: gem: Add raw_dma_resv() function
For retrieving a pointer to the struct dma_resv for a given GEM object. We also introduce it in a new trait, BaseObjectPrivate, which we automatically implement for all gem objects and don't expose to users outside of the crate. Signed-off-by: Lyude Paul <lyude@redhat.com> Reviewed-by: Janne Grunau <j@jananu.net> Tested-by: Janne Grunau <j@jannau.net> Tested-by: Deborah Brouwer <deborah.brouwer@collabora.com> Link: https://patch.msgid.link/20260316211646.650074-3-lyude@redhat.com [ Fix incorrect reference in safety comment. - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
1 parent 9b83664 commit 89b4964

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

rust/kernel/drm/gem/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,18 @@ pub trait BaseObject: IntoGEMObject {
215215

216216
impl<T: IntoGEMObject> BaseObject for T {}
217217

218+
/// Crate-private base operations shared by all GEM object classes.
219+
#[expect(unused)]
220+
pub(crate) trait BaseObjectPrivate: IntoGEMObject {
221+
/// Return a pointer to this object's dma_resv.
222+
fn raw_dma_resv(&self) -> *mut bindings::dma_resv {
223+
// SAFETY: `self.as_raw()` always returns a valid pointer to the base DRM GEM object.
224+
unsafe { (*self.as_raw()).resv }
225+
}
226+
}
227+
228+
impl<T: IntoGEMObject> BaseObjectPrivate for T {}
229+
218230
/// A base GEM object.
219231
///
220232
/// # Invariants

0 commit comments

Comments
 (0)