]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rust: devres: replace Devres::new_foreign_owned()
authorDanilo Krummrich <dakr@kernel.org>
Thu, 26 Jun 2025 20:00:40 +0000 (22:00 +0200)
committerDanilo Krummrich <dakr@kernel.org>
Sat, 28 Jun 2025 16:06:53 +0000 (18:06 +0200)
commit46ae8fd7386abf809355d1857abac5cf2d7c3f62
treef356d7df7a69455cb212971e1cea5cc2a8d4729e
parentce7c22b2e1fb1db467d33bd050546941ce82f21f
rust: devres: replace Devres::new_foreign_owned()

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>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/r/20250626200054.243480-3-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
rust/helpers/device.c
rust/kernel/cpufreq.rs
rust/kernel/devres.rs
rust/kernel/drm/driver.rs