Re: [PATCH v2 2/4] rust: devres: replace Devres::new_foreign_owned()
From: Benno Lossin
Date: Sun Jun 22 2025 - 16:25:39 EST
On Sun Jun 22, 2025 at 6:40 PM CEST, Danilo Krummrich wrote:
> Replace Devres::new_foreign_owned() with devres::register().
>
> The current implementation of Devres::new_foreign_owned() creates a full
> Devres container instance, including the internal Revocable and
> completion.
>
> However, none of that is necessary for the intended use of giving full
> ownership of an object to devres and getting it dropped once the given
> device is unbound.
>
> Hence, implement devres::register(), which is limited to consume the
> given data, wrap it in a KBox and drop the KBox once the given device is
> unbound, without any other synchronization.
>
> Cc: Dave Airlie <airlied@xxxxxxxxxx>
> Cc: Simona Vetter <simona.vetter@xxxxxxxx>
> Cc: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
> Acked-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
> Signed-off-by: Danilo Krummrich <dakr@xxxxxxxxxx>
> ---
Reviewed-by: Benno Lossin <lossin@xxxxxxxxxx>
---
Cheers,
Benno
> rust/helpers/device.c | 7 ++++
> rust/kernel/cpufreq.rs | 11 +++---
> rust/kernel/devres.rs | 70 +++++++++++++++++++++++++++++++++------
> rust/kernel/drm/driver.rs | 14 ++++----
> 4 files changed, 82 insertions(+), 20 deletions(-)