summaryrefslogtreecommitdiff
path: root/rust/helpers
diff options
context:
space:
mode:
authorDanilo Krummrich <dakr@kernel.org>2025-06-26 22:00:40 +0200
committerDanilo Krummrich <dakr@kernel.org>2025-06-28 18:06:53 +0200
commit46ae8fd7386abf809355d1857abac5cf2d7c3f62 (patch)
treef356d7df7a69455cb212971e1cea5cc2a8d4729e /rust/helpers
parentce7c22b2e1fb1db467d33bd050546941ce82f21f (diff)
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>
Diffstat (limited to 'rust/helpers')
-rw-r--r--rust/helpers/device.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/rust/helpers/device.c b/rust/helpers/device.c
index b2135c6686b0..502fef7e9ae8 100644
--- a/rust/helpers/device.c
+++ b/rust/helpers/device.c
@@ -8,3 +8,10 @@ int rust_helper_devm_add_action(struct device *dev,
{
return devm_add_action(dev, action, data);
}
+
+int rust_helper_devm_add_action_or_reset(struct device *dev,
+ void (*action)(void *),
+ void *data)
+{
+ return devm_add_action_or_reset(dev, action, data);
+}