diff --git a/rust/kernel/types.rs b/rust/kernel/types.rs index e961e68568868b..80aa3037cf1a35 100644 --- a/rust/kernel/types.rs +++ b/rust/kernel/types.rs @@ -128,6 +128,22 @@ impl PointerWrapper for Pin { } } +impl PointerWrapper for *mut T { + type Borrowed<'a> = *mut T; + + fn into_pointer(self) -> *const c_types::c_void { + self as _ + } + + unsafe fn borrow<'a>(ptr: *const c_types::c_void) -> Self::Borrowed<'a> { + ptr as _ + } + + unsafe fn from_pointer(ptr: *const c_types::c_void) -> Self { + ptr as _ + } +} + /// Runs a cleanup function/closure when dropped. /// /// The [`ScopeGuard::dismiss`] function prevents the cleanup function from running.