Re: [PATCH v2 2/4] rust: devres: replace Devres::new_foreign_owned()

Benno Lossin
2025-06-22T20:25:28Z

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@redhat.com>
> Cc: Simona Vetter <simona.vetter@ffwll.ch>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
> ---

Reviewed-by: Benno Lossin <lossin@kernel.org>

---
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(-)