mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frank.Li@oss.nxp.com
To: Vinod Koul <vkoul@kernel.org>, Frank Li <Frank.Li@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	dmaengine@vger.kernel.org (open list:DMA GENERIC OFFLOAD ENGINE
	SUBSYSTEM),
	imx@lists.linux.dev (open list:ARM/FREESCALE IMX / MXC /
	LAYERSCAPE ARM ARCHIT...),
	linux-arm-kernel@lists.infradead.org (moderated
	list:ARM/FREESCALE IMX / MXC / LAYERSCAPE ARM ARCHIT...),
	linux-kernel@vger.kernel.org (open list)
Cc: imx@lists.linux.dev, Frank Li <Frank.Li@nxp.com>
Subject: [PATCH 1/1] dmaengine: add dmaengine_get_provider_device() API
Date: Fri,  2 Oct 2026 16:23:40 -0400	[thread overview]
Message-ID: <20261002202341.253152-1-Frank.Li@oss.nxp.com> (raw)

From: Frank Li <Frank.Li@nxp.com>

Add dmaengine_get_provider_device() API and kernel doc for
dmaengine_get_dma_device() to describe the difference.

dmaengine_get_dma_device() is used for DMA mapping because some DMA
engines provide per-channel iommu mapping.

dmaengine_get_provider_device() is used to find a DMA engine channel
by a filter function.

In most cases they return the same value, but they have different
semantic meanings.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
Prepare make dma_device private after all driver change to use new
APIs.
---
 include/linux/dma/imx-dma.h |  6 ++++--
 include/linux/dmaengine.h   | 21 ++++++++++++++++++++-
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/include/linux/dma/imx-dma.h b/include/linux/dma/imx-dma.h
index 16e491f63883c..7c678316b7578 100644
--- a/include/linux/dma/imx-dma.h
+++ b/include/linux/dma/imx-dma.h
@@ -59,8 +59,10 @@ struct imx_dma_data {
 
 static inline int imx_dma_is_general_purpose(struct dma_chan *chan)
 {
-	return !strcmp(chan->device->dev->driver->name, "imx-sdma") ||
-		!strcmp(chan->device->dev->driver->name, "imx-dma");
+	struct device *dev = dmaengine_get_provider_device(chan);
+
+	return !strcmp(dev->driver->name, "imx-sdma") ||
+		!strcmp(dev->driver->name, "imx-dma");
 }
 
 /**
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 1b57bc4a7e72a..f9918a42473f5 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -1807,12 +1807,31 @@ static inline struct device *dmaengine_chan_dev(struct dma_chan *chan)
 	return &chan->chan_dev->device;
 }
 
+/*
+ * dmaengine_get_provider_device() - Get DMA engine provider device. Typical
+ *				     use is to find a DMA channel by filter.
+ * @chan: DMA channel
+ *
+ * Return: Pointer to the DMA engine provider device.
+ */
+static inline struct device *dmaengine_get_provider_device(struct dma_chan *chan)
+{
+	return chan->device->dev;
+}
+
+/*
+ * dmaengine_get_dma_device() - Get DMA device used for DMA mapping. Some
+ *				DMA engines provide per-channel iommu mapping.
+ * @chan: DMA channel
+ *
+ * Return: Pointer to the device used for DMA mapping.
+ */
 static inline struct device *dmaengine_get_dma_device(struct dma_chan *chan)
 {
 	if (chan->chan_dev->chan_dma_dev)
 		return dmaengine_chan_dev(chan);
 
-	return chan->device->dev;
+	return dmaengine_get_provider_device(chan);
 }
 
 #endif /* DMAENGINE_H */
-- 
2.43.0


                 reply	other threads:[~2026-10-02 20:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261002202341.253152-1-Frank.Li@oss.nxp.com \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.Li@kernel.org \
    --cc=Frank.Li@nxp.com \
    --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=s.hauer@pengutronix.de \
    --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

all inboxes | Powered by JetHome®