[PATCH v2 0/5] Use struct devres_node in Devres<T>
From: Danilo Krummrich
Date: Fri Feb 13 2026 - 17:08:03 EST
Currently, the Devres<T> container uses devm_add_action() to register a
devres callback.
devm_add_action() allocates a struct action_devres, which on top of
struct devres_node, just keeps a data pointer and release function
pointer.
This is an unnecessary indirection, given that analogous to struct
devres, the Devres<T> container can just embed a struct devres_node
directly without an additional allocation.
In contrast to struct devres, we don't need to force an alignment of
ARCH_DMA_MINALIGN (as struct devres does to account for the worst case)
since we have generics in Rust. I.e. the compiler already ensures
correct alignment of the embedded T in Devres<T>.
Thus, get rid of devm_add_action() and instead embed a struct
devres_node directly.
This patch series is based on [1].
[1] https://lore.kernel.org/lkml/20260202235210.55176-1-dakr@xxxxxxxxxx/
Changes in v2:
- Prevent driver-core internal C APIs from potentially being called directly
from driver modules due to monomorphisation, to prevent unnecessary symbol
exports.
Danilo Krummrich (5):
devres: move struct devres_node into base.h
devres: export devres_node_init() and devres_node_add()
devres: add devres_node_remove()
devres: rename and export set_node_dbginfo()
rust: devres: embed struct devres_node directly
drivers/base/base.h | 18 +++++
drivers/base/devres.c | 50 ++++++------
rust/kernel/devres.rs | 182 +++++++++++++++++++++++++++++++-----------
3 files changed, 180 insertions(+), 70 deletions(-)
base-commit: 1680377f05a809e4489731ad0e5a5fd5471ec40e
--
2.53.0