Re: [PATCH v2 1/3] dmaengine: of: Add managed DMA router registration
From: Vladimir Zapolskiy
Date: Sat Nov 28 2026 - 08:18:33 EST
On 11/27/26 13:03, Tian Xuechen wrote:
Add devm_of_dma_router_register() to unregister a router when its
device is detached. Reuse the controller cleanup action, since routers
share the same OF registry. If registering the cleanup action fails,
remove the newly registered router immediately.
Signed-off-by: Tian Xuechen <202300460064@xxxxxxxxxxxxxxx>
---
Changes in v2:
- Add the reusable managed router helper.
include/linux/of_dma.h | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/include/linux/of_dma.h b/include/linux/of_dma.h
index 16b08234d03b..7f9198ea9627 100644
--- a/include/linux/of_dma.h
+++ b/include/linux/of_dma.h
@@ -64,6 +64,21 @@ extern int of_dma_router_register(struct device_node *np,
struct dma_router *dma_router);
#define of_dma_router_free of_dma_controller_free
+static inline int
+devm_of_dma_router_register(struct device *dev, struct device_node *np,
+ void *(*of_dma_route_allocate)
+ (struct of_phandle_args *, struct of_dma *),
+ struct dma_router *dma_router)
+{
+ int ret;
+
+ ret = of_dma_router_register(np, of_dma_route_allocate, dma_router);
+ if (ret)
+ return ret;
+
+ return devm_add_action_or_reset(dev, __of_dma_controller_free, np);
I had to double check that of_dma_controller_free() also suits
of_dma_router_register(), and it is.
Reviewed-by: Vladimir Zapolskiy <vz@xxxxxxxxx>
--
Best wishes,
Vladimir