Lines Matching defs:ptr
17 use core::{alloc::Layout, mem, ops::Deref, ptr, ptr::NonNull};
118 let raw_data = unsafe { ptr::addr_of_mut!((*raw_drm.as_ptr()).data) };
144 /// `ptr` must be a valid pointer to a `struct device` embedded in `Self`.
145 unsafe fn from_drm_device(ptr: *const bindings::drm_device) -> *mut Self {
146 // SAFETY: By the safety requirements of this function `ptr` is a valid pointer to a
148 unsafe { crate::container_of!(Opaque::cast_from(ptr), Self, dev) }.cast_mut()
153 /// `ptr` must be a valid pointer to `Self`.
154 unsafe fn into_drm_device(ptr: NonNull<Self>) -> *mut bindings::drm_device {
155 // SAFETY: By the safety requirements of this function, `ptr` is a valid pointer to `Self`.
156 unsafe { &raw mut (*ptr.as_ptr()).dev }.cast()
163 /// Callers must ensure that `ptr` is valid, non-null, and has a non-zero reference count,
164 /// i.e. it must be ensured that the reference count of the C `struct drm_device` `ptr` points
168 /// Additionally, callers must ensure that the `struct device`, `ptr` is pointing to, is
171 pub unsafe fn from_raw<'a>(ptr: *const bindings::drm_device) -> &'a Self {
172 // SAFETY: By the safety requirements of this function `ptr` is a valid pointer to a
174 let ptr = unsafe { Self::from_drm_device(ptr) };
176 // SAFETY: `ptr` is valid by the safety requirements of this function.
177 unsafe { &*ptr.cast() }
180 extern "C" fn release(ptr: *mut bindings::drm_device) {
181 // SAFETY: `ptr` is a valid pointer to a `struct drm_device` and embedded in `Self`.
182 let this = unsafe { Self::from_drm_device(ptr) };
187 unsafe { core::ptr::drop_in_place(this) };