[PATCH v6 2/5] rust: make Owned::into_raw() and Owned::from_raw() public

Oliver Mangold posted 5 patches 11 months ago
There is a newer version of this series
[PATCH v6 2/5] rust: make Owned::into_raw() and Owned::from_raw() public
Posted by Oliver Mangold 11 months ago
It might be necessary to be used from some drivers containing C code like,
e.g. binder. It basically is needed for every implementation of an Ownable
outside of the kernel crate. Also the examples for OwnableRefCounted need
it.

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 v6 2/5] rust: make Owned::into_raw() and Owned::from_raw() public
Posted by Alice Ryhl 11 months ago
On Mon, Mar 10, 2025 at 08:49:50AM +0000, Oliver Mangold wrote:
> It might be necessary to be used from some drivers containing C code like,
> e.g. binder. It basically is needed for every implementation of an Ownable
> outside of the kernel crate. Also the examples for OwnableRefCounted need
> it.
> 
> Signed-off-by: Oliver Mangold <oliver.mangold@pm.me>

I would probably just fold this into the previous patch.

Alice
Re: [PATCH v6 2/5] rust: make Owned::into_raw() and Owned::from_raw() public
Posted by Oliver Mangold 11 months ago
On 250310 0950, Alice Ryhl wrote:
> 
> You can't send a patch by others without adding your own SoB.

Ok. Sorry, didn't know that.

On 250310 0950, Alice Ryhl wrote:
> 
> I would probably just fold this into the previous patch.

That is okay with different authors? Just leave that authorship with
Asahi Lina, then, I assume?

Oliver
Re: [PATCH v6 2/5] rust: make Owned::into_raw() and Owned::from_raw() public
Posted by Danilo Krummrich 11 months ago
On 3/10/25 11:00 AM, Oliver Mangold wrote:
> On 250310 0950, Alice Ryhl wrote:
>> I would probably just fold this into the previous patch.
> 
> That is okay with different authors? Just leave that authorship with
> Asahi Lina, then, I assume?

There is a 'Co-developed-by:' tag, please see [1].

[1] 
https://docs.kernel.org/process/submitting-patches.html#developer-s-certificate-of-origin-1-1
Re: [PATCH v6 2/5] rust: make Owned::into_raw() and Owned::from_raw() public
Posted by Oliver Mangold 11 months ago
On 250310 1132, Danilo Krummrich wrote:
> On 3/10/25 11:00 AM, Oliver Mangold wrote:
> > On 250310 0950, Alice Ryhl wrote:
> >> I would probably just fold this into the previous patch.
> >
> > That is okay with different authors? Just leave that authorship with
> > Asahi Lina, then, I assume?
> 
> There is a 'Co-developed-by:' tag, please see [1].
> 
> [1]
> https://docs.kernel.org/process/submitting-patches.html#developer-s-certificate-of-origin-1-1

Ah, okay. Thanks.

Best regards,

Oliver