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

Oliver Mangold posted 4 patches 11 months, 1 week ago
There is a newer version of this series
[PATCH v5 2/4] rust: make Owned::into_raw() and Owned::from_raw() public
Posted by Oliver Mangold 11 months, 1 week ago
It might be necessary to be used from some drivers

Signed-off-by: Oliver Mangold <oliver.mangold@pm.me>
---
 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
Re: [PATCH v5 2/4] rust: make Owned::into_raw() and Owned::from_raw() public
Posted by Miguel Ojeda 11 months, 1 week ago
On Fri, Mar 7, 2025 at 11:04 AM Oliver Mangold <oliver.mangold@pm.me> wrote:
>
> It might be necessary to be used from some drivers

Which ones? i.e. could we be a bit more explicit?

Thanks!

Cheers,
Miguel