* [PATCH 1/1] dmaengine: add dmaengine_get_provider_device() API
@ 2026-10-02 20:23 Frank.Li
0 siblings, 0 replies; only message in thread
From: Frank.Li @ 2026-10-02 20:23 UTC (permalink / raw)
To: Vinod Koul, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, open list:DMA GENERIC OFFLOAD ENGINE SUBSYSTEM,
open list:ARM/FREESCALE IMX / MXC / LAYERSCAPE ARM ARCHIT...,
moderated list:ARM/FREESCALE IMX / MXC / LAYERSCAPE ARM ARCHIT...,
open list
Cc: imx, Frank Li
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-02 20:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-02 20:23 [PATCH 1/1] dmaengine: add dmaengine_get_provider_device() API Frank.Li
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®