[PATCH v5 2/4] rust: make Owned::into_raw() and Owned::from_raw() public

From: Oliver Mangold
Date: Fri Mar 07 2025 - 05:05:02 EST


It might be necessary to be used from some drivers

Signed-off-by: Oliver Mangold <oliver.mangold@xxxxx>
---
rust/kernel/types.rs | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/rust/kernel/types.rs b/rust/kernel/types.rs
index 0cae5ba6607f0a86d2f0e3494f956f6daad78067..e0ce3646a4d3b70c069322a9b0f25c00265a2af8 100644
--- a/rust/kernel/types.rs
+++ b/rust/kernel/types.rs
@@ -616,7 +616,7 @@ impl<T: Ownable> Owned<T> {
///
/// Callers must ensure that the underlying object is acquired and can be considered owned by
/// Rust.
- pub(crate) unsafe fn from_raw(ptr: NonNull<T>) -> Self {
+ pub unsafe fn from_raw(ptr: NonNull<T>) -> Self {
// INVARIANT: The safety requirements guarantee that the new instance now owns the
// reference.
Self {
@@ -630,8 +630,7 @@ pub(crate) unsafe fn from_raw(ptr: NonNull<T>) -> Self {
/// This function does not actually relinquish ownership of the object.
/// After calling this function, the caller is responsible for ownership previously managed
/// by the `Owned`.
- #[allow(dead_code)]
- pub(crate) fn into_raw(me: Self) -> NonNull<T> {
+ pub fn into_raw(me: Self) -> NonNull<T> {
ManuallyDrop::new(me).ptr
}
}

--
2.48.1