* [PATCH v3 1/7] dmaengine: of: Add managed DMA router registration
[not found] <20261204121630.1720746-1-202300460064@mail.sdu.edu.cn>
@ 2026-12-04 12:16 ` Tian Xuechen
2026-12-04 17:54 ` Frank Li
0 siblings, 1 reply; 2+ messages in thread
From: Tian Xuechen @ 2026-12-04 12:16 UTC (permalink / raw)
To: vkoul; +Cc: Frank.Li, dmaengine, robh, saravanak, devicetree
Add devm_of_dma_router_register() to unregister an OF DMA router
when its device is detached. Reuse the controller release action
because controllers and routers share the same registry.
Install the release action before publishing the router so allocating
the action cannot fail after publication. If router registration
fails, remove the unused action.
Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
---
include/linux/of_dma.h | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/include/linux/of_dma.h b/include/linux/of_dma.h
index 16b08234d..df200c0cb 100644
--- a/include/linux/of_dma.h
+++ b/include/linux/of_dma.h
@@ -64,6 +64,25 @@ 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 = devm_add_action(dev, __of_dma_controller_free, np);
+ if (ret)
+ return ret;
+
+ ret = of_dma_router_register(np, of_dma_route_allocate, dma_router);
+ if (ret)
+ devm_remove_action(dev, __of_dma_controller_free, np);
+
+ return ret;
+}
+
extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
const char *name);
extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
@@ -103,6 +122,15 @@ static inline int of_dma_router_register(struct device_node *np,
#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)
+{
+ return -ENODEV;
+}
+
static inline struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
const char *name)
{
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3 1/7] dmaengine: of: Add managed DMA router registration
2026-12-04 12:16 ` [PATCH v3 1/7] dmaengine: of: Add managed DMA router registration Tian Xuechen
@ 2026-12-04 17:54 ` Frank Li
0 siblings, 0 replies; 2+ messages in thread
From: Frank Li @ 2026-12-04 17:54 UTC (permalink / raw)
To: Tian Xuechen; +Cc: vkoul, Frank.Li, dmaengine, robh, saravanak, devicetree
On Fri, Dec 04, 2026 at 08:16:24PM +0800, Tian Xuechen wrote:
> Add devm_of_dma_router_register() to unregister an OF DMA router
> when its device is detached. Reuse the controller release action
> because controllers and routers share the same registry.
>
> Install the release action before publishing the router so allocating
> the action cannot fail after publication. If router registration
> fails, remove the unused action.
>
> Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn>
> ---
I remember I reviewed this patch. Did you missed my review tags.
And also missed Vladimir Zapolskiy's review tags.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> include/linux/of_dma.h | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/include/linux/of_dma.h b/include/linux/of_dma.h
> index 16b08234d..df200c0cb 100644
> --- a/include/linux/of_dma.h
> +++ b/include/linux/of_dma.h
> @@ -64,6 +64,25 @@ 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 = devm_add_action(dev, __of_dma_controller_free, np);
> + if (ret)
> + return ret;
> +
> + ret = of_dma_router_register(np, of_dma_route_allocate, dma_router);
> + if (ret)
> + devm_remove_action(dev, __of_dma_controller_free, np);
> +
> + return ret;
> +}
> +
> extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
> const char *name);
> extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
> @@ -103,6 +122,15 @@ static inline int of_dma_router_register(struct device_node *np,
>
> #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)
> +{
> + return -ENODEV;
> +}
> +
> static inline struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
> const char *name)
> {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-04 17:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20261204121630.1720746-1-202300460064@mail.sdu.edu.cn>
2026-12-04 12:16 ` [PATCH v3 1/7] dmaengine: of: Add managed DMA router registration Tian Xuechen
2026-12-04 17:54 ` Frank Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox