Re: [PATCH v3] rust: device: change the from_raw() function

From: Boqun Feng
Date: Wed Oct 02 2024 - 22:18:34 EST




On Thu, Oct 3, 2024, at 12:07 AM, Greg KH wrote:
> On Wed, Oct 02, 2024 at 03:58:29PM +0200, Danilo Krummrich wrote:
>> On Tue, Oct 01, 2024 at 05:56:03PM -0300, Guilherme Giacomo Simoes wrote:
>> > The function Device::from_raw() increments a refcount by a call to
>> > bindings::get_device(ptr). This can be confused because usually
>> > from_raw() functions don't increment a refcount.
>> > Hence, rename Device::from_raw() to avoid confuion with other "from_raw"
>> > semantics.
>> >
>> > The new name of function should be "get_device" to be consistent with
>> > the function get_device() already exist in .c files.
>> >
>> > This function body also changed, because the `into()` will convert the
>> > `&'a Device` into `ARef<Device>` and also call `inc_ref` from the
>> > `AlwaysRefCounted` trait implemented for Device.
>> >

This work is because we have an issue, so this should really have a:

Closes: https://github.com/Rust-for-Linux/linux/issues/1088

tag.

Greg, could you add this when you queue this?

Guilherme, please add such a tag next time, so we can have things
tracked. Thanks!

Regards,
Boqun

>> > Signed-off-by: Guilherme Giacomo Simoes <trintaeoitogc@xxxxxxxxx>
>>
>> Acked-by: Danilo Krummrich <dakr@xxxxxxxxxx>
>
> Thanks for the review, and Guilherme, for all of the revisions. I'll
> queue this up for this release soon so we don't get any code building on
> the old api.
>
> thanks,
>
> greg k-h