Skip to content

Commit 342b6ff

Browse files
Lyudejannau
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>
1 parent 6a516d0 commit 342b6ff

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
@@ -199,6 +199,18 @@ pub trait BaseObject: IntoGEMObject {
199199

200200
impl<T: IntoGEMObject> BaseObject for T {}
201201

202+
/// Crate-private base operations shared by all GEM object classes.
203+
#[expect(unused)]
204+
pub(crate) trait BaseObjectPrivate: IntoGEMObject {
205+
/// Return a pointer to this object's dma_resv.
206+
fn raw_dma_resv(&self) -> *mut bindings::dma_resv {
207+
// SAFETY: `as_gem_obj()` always returns a valid pointer to the base DRM gem object
208+
unsafe { (*self.as_raw()).resv }
209+
}
210+
}
211+
212+
impl<T: IntoGEMObject> BaseObjectPrivate for T {}
213+
202214
/// A base GEM object.
203215
///
204216
/// Invariants

0 commit comments

Comments
 (0)