[PATCH 0/5] Use struct devres_node in Devres<T>

From: Danilo Krummrich

Date: Thu Feb 05 2026 - 17:48:22 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] and [2].

[1] https://lore.kernel.org/lkml/20260205222529.91465-1-dakr@xxxxxxxxxx/
[2] https://lore.kernel.org/lkml/20260202235210.55176-1-dakr@xxxxxxxxxx/

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 | 54 +++++++++++--------
rust/kernel/devres.rs | 123 ++++++++++++++++++++++++++----------------
3 files changed, 127 insertions(+), 68 deletions(-)


base-commit: c98d3727720db5f74bf40a8cd1c2da05081845ee
--
2.52.0