dmaengine: of_dma: Add devm_of_dma_controller_register()

Add a managed API, devm_of_dma_controller_register(), to simplify DMA
engine controller registration by automatically handling resource
cleanup.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260225-mxsdma-module-v3-1-8f798b13baa6@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
master
Frank Li 2026-02-25 16:41:37 -05:00 committed by Vinod Koul
parent 65ca1121f7
commit 3a005126c9
1 changed files with 29 additions and 0 deletions

View File

@ -38,6 +38,26 @@ extern int of_dma_controller_register(struct device_node *np,
void *data);
extern void of_dma_controller_free(struct device_node *np);
static void __of_dma_controller_free(void *np)
{
of_dma_controller_free(np);
}
static inline int
devm_of_dma_controller_register(struct device *dev, struct device_node *np,
struct dma_chan *(*of_dma_xlate)
(struct of_phandle_args *, struct of_dma *),
void *data)
{
int ret;
ret = of_dma_controller_register(np, of_dma_xlate, data);
if (ret)
return ret;
return devm_add_action_or_reset(dev, __of_dma_controller_free, np);
}
extern int of_dma_router_register(struct device_node *np,
void *(*of_dma_route_allocate)
(struct of_phandle_args *, struct of_dma *),
@ -64,6 +84,15 @@ static inline void of_dma_controller_free(struct device_node *np)
{
}
static inline int
devm_of_dma_controller_register(struct device *dev, struct device_node *np,
struct dma_chan *(*of_dma_xlate)
(struct of_phandle_args *, struct of_dma *),
void *data)
{
return -ENODEV;
}
static inline int of_dma_router_register(struct device_node *np,
void *(*of_dma_route_allocate)
(struct of_phandle_args *, struct of_dma *),