Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: Frank Li <Frank.Li@nxp.com>
To: Rob Herring <robh@kernel.org>,
	Saravana Kannan <saravanak@google.com>,
	 Vinod Koul <vkoul@kernel.org>, Shawn Guo <shawnguo@kernel.org>,
	 Sascha Hauer <s.hauer@pengutronix.de>,
	 Pengutronix Kernel Team <kernel@pengutronix.de>,
	 Fabio Estevam <festevam@gmail.com>
Cc: dmaengine@vger.kernel.org, devicetree@vger.kernel.org,
	 linux-kernel@vger.kernel.org, imx@lists.linux.dev,
	 linux-arm-kernel@lists.infradead.org,
	Shawn Guo <shawn.guo@freescale.com>,  Frank Li <Frank.Li@nxp.com>
Subject: [PATCH 01/13] dmaengine: of_dma: Add devm_of_dma_controller_register()
Date: Wed, 14 Jan 2026 17:33:13 -0500	[thread overview]
Message-ID: <20260114-mxsdma-module-v1-1-9b2a9eaa4226@nxp.com> (raw)
In-Reply-To: <20260114-mxsdma-module-v1-0-9b2a9eaa4226@nxp.com>

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>
---
 include/linux/of_dma.h | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/include/linux/of_dma.h b/include/linux/of_dma.h
index fd706cdf255c61c82ce30ef9a2c44930bef34bc8..c630b23fdd1313168e2362415093f106d6a66c46 100644
--- a/include/linux/of_dma.h
+++ b/include/linux/of_dma.h
@@ -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
+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 *),

-- 
2.34.1


  reply	other threads:[~2026-01-14 22:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-14 22:33 [PATCH 00/13] dmaegnine: freescale-dmas: small improvement Frank Li
2026-01-14 22:33 ` Frank Li [this message]
2026-01-15  8:44   ` [PATCH 01/13] dmaengine: of_dma: Add devm_of_dma_controller_register() Daniel Baluta
2026-01-15 10:45   ` kernel test robot
2026-01-15 11:29   ` kernel test robot
2026-01-14 22:33 ` [PATCH 02/13] dmaengine: mxs-dma: Use local dev variable in probe() Frank Li
2026-01-14 23:27   ` Fabio Estevam
2026-01-15 14:35     ` Frank Li
2026-01-14 22:33 ` [PATCH 03/13] dmaengine: mxs-dma: Fix missing return value from of_dma_controller_register() Frank Li
2026-01-15  8:45   ` Daniel Baluta
2026-01-14 22:33 ` [PATCH 04/13] dmaengine: mxs-dma: Use dev_err_probe() simple code Frank Li
2026-01-14 22:33 ` [PATCH 05/13] dmaengine: mxs-dma: Use managed API devm_of_dma_controller_register() Frank Li
2026-01-14 22:33 ` [PATCH 06/13] dmaengine: mxs-dma: Add module license and description Frank Li
2026-01-14 22:33 ` [PATCH 07/13] dmaengine: mxs-dma: Turn MXS_DMA as tristate Frank Li
2026-01-14 22:33 ` [PATCH 08/13] dmaengine: fsl-edma: Use managed API dmaenginem_async_device_register() Frank Li
2026-01-14 22:33 ` [PATCH 09/13] dmaengine: fsl-edma: Use dev_err_probe() to simplify code Frank Li
2026-01-14 22:33 ` [PATCH 10/13] dmaengine: imx-sdma: Use devm_clk_get_prepared() " Frank Li
2026-01-14 22:33 ` [PATCH 11/13] dmaengine: imx-sdma: Use managed API " Frank Li
2026-01-14 22:33 ` [PATCH 12/13] dmaengine: imx-sdma: Use dev_err_probe() " Frank Li
2026-01-14 22:33 ` [PATCH 13/13] dmaengine: fsl-qdma: " Frank Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260114-mxsdma-module-v1-1-9b2a9eaa4226@nxp.com \
    --to=frank.li@nxp.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=saravanak@google.com \
    --cc=shawn.guo@freescale.com \
    --cc=shawnguo@kernel.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox