Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] dmaengine: rename dma_chan::dev to dma_chan::chan_dev for clarity
@ 2026-09-04 21:49 Frank.Li
  2026-09-04 21:49 ` [PATCH v3 1/4] dmaengine: vchan: add vchan_chan_name() to get channel device name Frank.Li
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Frank.Li @ 2026-09-04 21:49 UTC (permalink / raw)
  To: Jacky Huang, Shan-Chun Hung, Vinod Koul, Frank Li, Paul Cercueil,
	Eugeniy Paltsev, Andy Shevchenko, Binbin Zhou, Patrice Chotard,
	Amélie Delaunay, Maxime Coquelin, Alexandre Torgue,
	Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Thierry Reding, Jonathan Hunter, Ludovic Desroches, Viresh Kumar,
	Keguang Zhang, Andreas Färber, Manivannan Sadhasivam,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Kelvin Cao, Logan Gunthorpe,
	Laxman Dewangan, Vignesh Raghavendra
  Cc: linux-arm-kernel, dmaengine, linux-kernel, linux-mips,
	linux-stm32, linux-trace-kernel, linux-tegra, linux-actions,
	linux-sunxi, imx, Frank Li

The current dma_chan structure contains both "device" and "dev". So

    chan->device->dev refers to the DMA engine device.
    chan->dev->device refers to the per-channel device instance.

Their similar naming makes the distinction unclear and increases reader
confusion.

Add union dma_chan::chan_dev to make its purpose explicit and clearly
identify it as the per-channel device. After all user switch to chan_dev,
union and dma_chan::dev will be removed.

Update the kernel-doc accordingly. Besides its sysfs usage, the per-channel
device is also used by some DMA engine drivers for IOMMU mapping and
therefore deserves a more accurate description.

1st patch add help vchan_chan_name()
2nd patch use existing helper dma_chan_name() to reduce rename difference.
3rd patch add (dmaengine|vchan)_chan_dev() helper
4th patch add union chan_dev for dma_chan::dev for clarity

Need following patch to clean other dma engineer driver, which is not
in drivers/dma

After complete all rename work, dma_chan::dev can be removed.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
Changes in v3:
- add new helper function dmaengine_chan_dev() and vchan_chan_dev() to
make clear.
- some reduntant error message will be addressed by new patches.
- Link to v2: https://patch.msgid.link/20260903-dma-chan_dev-rename-v2-0-0db305b6c716@nxp.com

Changes in v2:
- rebase to dmaengine/next
- add vchan_chan_name() help function for vchan case.
- Link to v1: https://patch.msgid.link/20260812-dma-chan_dev-rename-v1-0-a67131f7d5c2@nxp.com

---
Frank Li (4):
      dmaengine: vchan: add vchan_chan_name() to get channel device name
      dmaengine: use dma_chan_name() helper to get per-channel device name
      dmaengine: add (dmaengine|vchan)_chan_dev() helper
      dmaengine: add union chan_dev for dma_chan::dev for clarity

 drivers/dma/arm-dma350.c                       |   2 +-
 drivers/dma/at_hdmac.c                         |  81 ++++++-------
 drivers/dma/at_xdmac.c                         | 159 ++++++++++++-------------
 drivers/dma/dma-jz4780.c                       |  10 +-
 drivers/dma/dmaengine.c                        |  34 +++---
 drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c |  38 +++---
 drivers/dma/dw-axi-dmac/dw-axi-dmac.h          |  10 --
 drivers/dma/dw/core.c                          |  47 ++++----
 drivers/dma/ep93xx_dma.c                       |  37 +++---
 drivers/dma/idma64.c                           |   9 +-
 drivers/dma/loongson/loongson1-apb-dma.c       |  23 ++--
 drivers/dma/loongson/loongson2-apb-cmc-dma.c   |  17 +--
 drivers/dma/loongson/loongson2-apb-dma.c       |   9 +-
 drivers/dma/mmp_pdma.c                         |   2 +-
 drivers/dma/moxart-dma.c                       |  23 ++--
 drivers/dma/nbpfaxi.c                          |   2 +-
 drivers/dma/owl-dma.c                          |  21 ++--
 drivers/dma/pch_dma.c                          |  41 +++----
 drivers/dma/pxa_dma.c                          |  52 ++++----
 drivers/dma/st_fdma.c                          |   2 +-
 drivers/dma/ste_dma40.c                        |  15 +--
 drivers/dma/stm32/stm32-dma.c                  |  69 +++++------
 drivers/dma/stm32/stm32-dma3.c                 |  99 ++++++++-------
 drivers/dma/stm32/stm32-mdma.c                 |  95 +++++++--------
 drivers/dma/sun4i-dma.c                        |  17 +--
 drivers/dma/sun6i-dma.c                        |  31 ++---
 drivers/dma/switchtec_dma.c                    |  14 +--
 drivers/dma/tegra186-gpc-dma.c                 |   4 +-
 drivers/dma/tegra20-apb-dma.c                  |   2 +-
 drivers/dma/ti/k3-udma.c                       |   6 +-
 drivers/dma/timb_dma.c                         |  63 +++++-----
 drivers/dma/txx9dmac.c                         |  73 ++++++------
 drivers/dma/virt-dma.h                         |  16 +++
 include/linux/dmaengine.h                      |  23 +++-
 include/trace/events/tegra_apb_dma.h           |   6 +-
 35 files changed, 538 insertions(+), 614 deletions(-)
---
base-commit: 5c7962210474adbd9874227bc5096dbc11501d34
change-id: 20260812-dma-chan_dev-rename-66263ac5eac9

Best regards,
--  
Frank Li <Frank.Li@nxp.com>



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v3 1/4] dmaengine: vchan: add vchan_chan_name() to get channel device name
  2026-09-04 21:49 [PATCH v3 0/4] dmaengine: rename dma_chan::dev to dma_chan::chan_dev for clarity Frank.Li
@ 2026-09-04 21:49 ` Frank.Li
  2026-09-07  9:00   ` Amelie Delaunay
  2026-09-04 21:49 ` [PATCH v3 2/4] dmaengine: use dma_chan_name() helper to get per-channel " Frank.Li
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Frank.Li @ 2026-09-04 21:49 UTC (permalink / raw)
  To: Jacky Huang, Shan-Chun Hung, Vinod Koul, Frank Li, Paul Cercueil,
	Eugeniy Paltsev, Andy Shevchenko, Binbin Zhou, Patrice Chotard,
	Amélie Delaunay, Maxime Coquelin, Alexandre Torgue,
	Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Thierry Reding, Jonathan Hunter, Ludovic Desroches, Viresh Kumar,
	Keguang Zhang, Andreas Färber, Manivannan Sadhasivam,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Kelvin Cao, Logan Gunthorpe,
	Laxman Dewangan, Vignesh Raghavendra
  Cc: linux-arm-kernel, dmaengine, linux-kernel, linux-mips,
	linux-stm32, linux-trace-kernel, linux-tegra, linux-actions,
	linux-sunxi, imx, Frank Li

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

Introduce vchan_chan_name() to obtain the DMA channel device name.

Use a dedicated helper instead of directly accessing dma_chan::dev
so callers remain unaffected by an upcoming rename of the struct member.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/dma/arm-dma350.c                     |  2 +-
 drivers/dma/loongson/loongson2-apb-cmc-dma.c |  2 +-
 drivers/dma/stm32/stm32-dma.c                |  2 +-
 drivers/dma/stm32/stm32-dma3.c               |  4 ++--
 drivers/dma/virt-dma.h                       | 11 +++++++++++
 5 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/arm-dma350.c b/drivers/dma/arm-dma350.c
index 09403aca8bb06..52f5242ea3327 100644
--- a/drivers/dma/arm-dma350.c
+++ b/drivers/dma/arm-dma350.c
@@ -512,7 +512,7 @@ static int d350_alloc_chan_resources(struct dma_chan *chan)
 {
 	struct d350_chan *dch = to_d350_chan(chan);
 	int ret = request_irq(dch->irq, d350_irq, IRQF_SHARED,
-			      dev_name(&dch->vc.chan.dev->device), dch);
+			      vchan_chan_name(&dch->vc), dch);
 	if (!ret)
 		writel_relaxed(CH_INTREN_DONE | CH_INTREN_ERR, dch->base + CH_INTREN);
 
diff --git a/drivers/dma/loongson/loongson2-apb-cmc-dma.c b/drivers/dma/loongson/loongson2-apb-cmc-dma.c
index 1c9a542edc859..2f1c8c4fd0654 100644
--- a/drivers/dma/loongson/loongson2-apb-cmc-dma.c
+++ b/drivers/dma/loongson/loongson2-apb-cmc-dma.c
@@ -678,7 +678,7 @@ static int loongson2_cmc_dma_probe(struct platform_device *pdev)
 			return lchan->irq;
 
 		ret = devm_request_irq(dev, lchan->irq, loongson2_cmc_dma_chan_irq, IRQF_SHARED,
-				       dev_name(chan2dev(lchan)), lchan);
+				       vchan_chan_name(&lchan->vchan), lchan);
 		if (ret)
 			return ret;
 	}
diff --git a/drivers/dma/stm32/stm32-dma.c b/drivers/dma/stm32/stm32-dma.c
index d3ad78562a140..3e8151e2ad75a 100644
--- a/drivers/dma/stm32/stm32-dma.c
+++ b/drivers/dma/stm32/stm32-dma.c
@@ -1668,7 +1668,7 @@ static int stm32_dma_probe(struct platform_device *pdev)
 
 		ret = devm_request_irq(&pdev->dev, chan->irq,
 				       stm32_dma_chan_irq, 0,
-				       dev_name(chan2dev(chan)), chan);
+				       vchan_chan_name(&chan->vchan), chan);
 		if (ret) {
 			dev_err(&pdev->dev,
 				"request_irq failed with err %d channel %d\n",
diff --git a/drivers/dma/stm32/stm32-dma3.c b/drivers/dma/stm32/stm32-dma3.c
index 4724e7fa0008e..1ee1bd22703fb 100644
--- a/drivers/dma/stm32/stm32-dma3.c
+++ b/drivers/dma/stm32/stm32-dma3.c
@@ -1892,10 +1892,10 @@ static int stm32_dma3_probe(struct platform_device *pdev)
 		chan->irq = ret;
 
 		ret = devm_request_irq(&pdev->dev, chan->irq, stm32_dma3_chan_irq, 0,
-				       dev_name(chan2dev(chan)), chan);
+				       vchan_chan_name(&chan->vchan), chan);
 		if (ret) {
 			dev_err_probe(&pdev->dev, ret, "Failed to request channel %s IRQ\n",
-				      dev_name(chan2dev(chan)));
+				      vchan_chan_name(&chan->vchan));
 			goto err_clk_disable;
 		}
 	}
diff --git a/drivers/dma/virt-dma.h b/drivers/dma/virt-dma.h
index 59d9eabc8b674..dd023a3831209 100644
--- a/drivers/dma/virt-dma.h
+++ b/drivers/dma/virt-dma.h
@@ -209,6 +209,17 @@ static inline void vchan_free_chan_resources(struct virt_dma_chan *vc)
 	vchan_dma_desc_free_list(vc, &head);
 }
 
+/**
+ * vchan_chan_name - Return vchan DMA channel device name
+ * @vc: virtual channel
+ *
+ * Return: The name of the DMA channel device
+ */
+static inline const char *vchan_chan_name(struct virt_dma_chan *vc)
+{
+	return dma_chan_name(&vc->chan);
+}
+
 /**
  * vchan_synchronize() - synchronize callback execution to the current context
  * @vc: virtual channel to synchronize

-- 
2.43.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v3 2/4] dmaengine: use dma_chan_name() helper to get per-channel device name
  2026-09-04 21:49 [PATCH v3 0/4] dmaengine: rename dma_chan::dev to dma_chan::chan_dev for clarity Frank.Li
  2026-09-04 21:49 ` [PATCH v3 1/4] dmaengine: vchan: add vchan_chan_name() to get channel device name Frank.Li
@ 2026-09-04 21:49 ` Frank.Li
  2026-09-05  7:55   ` Andy Shevchenko
  2026-09-07  9:01   ` Amelie Delaunay
  2026-09-04 21:49 ` [PATCH v3 4/4] dmaengine: add union chan_dev for dma_chan::dev for clarity Frank.Li
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 11+ messages in thread
From: Frank.Li @ 2026-09-04 21:49 UTC (permalink / raw)
  To: Jacky Huang, Shan-Chun Hung, Vinod Koul, Frank Li, Paul Cercueil,
	Eugeniy Paltsev, Andy Shevchenko, Binbin Zhou, Patrice Chotard,
	Amélie Delaunay, Maxime Coquelin, Alexandre Torgue,
	Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Thierry Reding, Jonathan Hunter, Ludovic Desroches, Viresh Kumar,
	Keguang Zhang, Andreas Färber, Manivannan Sadhasivam,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Kelvin Cao, Logan Gunthorpe,
	Laxman Dewangan, Vignesh Raghavendra
  Cc: linux-arm-kernel, dmaengine, linux-kernel, linux-mips,
	linux-stm32, linux-trace-kernel, linux-tegra, linux-actions,
	linux-sunxi, imx, Frank Li

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

Use the existing dma_chan_name() helper to obtain the per-channel device
name instead of open-coding: dev_name(chan->dev->device) /
dev_name(chan2dev())

Simplify the code and improve consistency.

No functional change intended.

Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/dma/dma-jz4780.c                       | 2 +-
 drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 2 +-
 drivers/dma/idma64.c                           | 2 +-
 drivers/dma/loongson/loongson2-apb-dma.c       | 2 +-
 drivers/dma/mmp_pdma.c                         | 2 +-
 drivers/dma/st_fdma.c                          | 2 +-
 drivers/dma/stm32/stm32-dma3.c                 | 2 +-
 drivers/dma/stm32/stm32-mdma.c                 | 2 +-
 include/trace/events/tegra_apb_dma.h           | 6 +++---
 9 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/dma/dma-jz4780.c b/drivers/dma/dma-jz4780.c
index 6070dfdb7114c..194649811d02b 100644
--- a/drivers/dma/dma-jz4780.c
+++ b/drivers/dma/dma-jz4780.c
@@ -760,7 +760,7 @@ static int jz4780_dma_alloc_chan_resources(struct dma_chan *chan)
 {
 	struct jz4780_dma_chan *jzchan = to_jz4780_dma_chan(chan);
 
-	jzchan->desc_pool = dma_pool_create(dev_name(&chan->dev->device),
+	jzchan->desc_pool = dma_pool_create(dma_chan_name(chan),
 					    chan->device->dev,
 					    JZ_DMA_DESC_BLOCK_SIZE,
 					    PAGE_SIZE, 0);
diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
index 9c21a5479437d..7b50ba507cb02 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -531,7 +531,7 @@ static int dma_chan_alloc_chan_resources(struct dma_chan *dchan)
 	}
 
 	/* LLI address must be aligned to a 64-byte boundary */
-	chan->desc_pool = dma_pool_create(dev_name(chan2dev(chan)),
+	chan->desc_pool = dma_pool_create(dma_chan_name(dchan),
 					  chan->chip->dev,
 					  sizeof(struct axi_dma_lli),
 					  64, 0);
diff --git a/drivers/dma/idma64.c b/drivers/dma/idma64.c
index 5fcd1befc92da..6399fd5408be2 100644
--- a/drivers/dma/idma64.c
+++ b/drivers/dma/idma64.c
@@ -507,7 +507,7 @@ static int idma64_alloc_chan_resources(struct dma_chan *chan)
 	struct idma64_chan *idma64c = to_idma64_chan(chan);
 
 	/* Create a pool of consistent memory blocks for hardware descriptors */
-	idma64c->pool = dma_pool_create(dev_name(chan2dev(chan)),
+	idma64c->pool = dma_pool_create(dma_chan_name(chan),
 					chan->device->dev,
 					sizeof(struct idma64_lli), 8, 0);
 	if (!idma64c->pool) {
diff --git a/drivers/dma/loongson/loongson2-apb-dma.c b/drivers/dma/loongson/loongson2-apb-dma.c
index aceb069e71fca..7c3d7c3273955 100644
--- a/drivers/dma/loongson/loongson2-apb-dma.c
+++ b/drivers/dma/loongson/loongson2-apb-dma.c
@@ -282,7 +282,7 @@ static int ls2x_dma_alloc_chan_resources(struct dma_chan *chan)
 	struct ls2x_dma_chan *lchan = to_ldma_chan(chan);
 
 	/* Create a pool of consistent memory blocks for hardware descriptors */
-	lchan->pool = dma_pool_create(dev_name(chan2dev(chan)),
+	lchan->pool = dma_pool_create(dma_chan_name(chan),
 				      chan->device->dev, PAGE_SIZE,
 				      __alignof__(struct ls2x_dma_hw_desc), 0);
 	if (!lchan->pool) {
diff --git a/drivers/dma/mmp_pdma.c b/drivers/dma/mmp_pdma.c
index 386e85cd4882a..6b29e15b0616c 100644
--- a/drivers/dma/mmp_pdma.c
+++ b/drivers/dma/mmp_pdma.c
@@ -565,7 +565,7 @@ static int mmp_pdma_alloc_chan_resources(struct dma_chan *dchan)
 	if (chan->desc_pool)
 		return 1;
 
-	chan->desc_pool = dma_pool_create(dev_name(&dchan->dev->device),
+	chan->desc_pool = dma_pool_create(dma_chan_name(dchan),
 					  chan->dev,
 					  sizeof(struct mmp_pdma_desc_sw),
 					  __alignof__(struct mmp_pdma_desc_sw),
diff --git a/drivers/dma/st_fdma.c b/drivers/dma/st_fdma.c
index d9547017f3bd6..35dbff5f9f1ab 100644
--- a/drivers/dma/st_fdma.c
+++ b/drivers/dma/st_fdma.c
@@ -268,7 +268,7 @@ static int st_fdma_alloc_chan_res(struct dma_chan *chan)
 	struct st_fdma_chan *fchan = to_st_fdma_chan(chan);
 
 	/* Create the dma pool for descriptor allocation */
-	fchan->node_pool = dma_pool_create(dev_name(&chan->dev->device),
+	fchan->node_pool = dma_pool_create(dma_chan_name(chan),
 					    fchan->fdev->dev,
 					    sizeof(struct st_fdma_hw_node),
 					    __alignof__(struct st_fdma_hw_node),
diff --git a/drivers/dma/stm32/stm32-dma3.c b/drivers/dma/stm32/stm32-dma3.c
index 1ee1bd22703fb..6ee7a1435efb6 100644
--- a/drivers/dma/stm32/stm32-dma3.c
+++ b/drivers/dma/stm32/stm32-dma3.c
@@ -1126,7 +1126,7 @@ static int stm32_dma3_alloc_chan_resources(struct dma_chan *c)
 		goto err_put_sync;
 	}
 
-	chan->lli_pool = dmam_pool_create(dev_name(&c->dev->device), c->device->dev,
+	chan->lli_pool = dmam_pool_create(dma_chan_name(c), c->device->dev,
 					  sizeof(struct stm32_dma3_hwdesc),
 					  __alignof__(struct stm32_dma3_hwdesc), SZ_64K);
 	if (!chan->lli_pool) {
diff --git a/drivers/dma/stm32/stm32-mdma.c b/drivers/dma/stm32/stm32-mdma.c
index e3bbdc9ee36ed..c274638e919c2 100644
--- a/drivers/dma/stm32/stm32-mdma.c
+++ b/drivers/dma/stm32/stm32-mdma.c
@@ -1484,7 +1484,7 @@ static int stm32_mdma_alloc_chan_resources(struct dma_chan *c)
 	struct stm32_mdma_device *dmadev = stm32_mdma_get_dev(chan);
 	int ret;
 
-	chan->desc_pool = dmam_pool_create(dev_name(&c->dev->device),
+	chan->desc_pool = dmam_pool_create(dma_chan_name(c),
 					   c->device->dev,
 					   sizeof(struct stm32_mdma_hwdesc),
 					  __alignof__(struct stm32_mdma_hwdesc),
diff --git a/include/trace/events/tegra_apb_dma.h b/include/trace/events/tegra_apb_dma.h
index 6d9f5075baa3e..c38117c127ef3 100644
--- a/include/trace/events/tegra_apb_dma.h
+++ b/include/trace/events/tegra_apb_dma.h
@@ -11,7 +11,7 @@ TRACE_EVENT(tegra_dma_tx_status,
 	TP_PROTO(struct dma_chan *dc, dma_cookie_t cookie, struct dma_tx_state *state),
 	TP_ARGS(dc, cookie, state),
 	TP_STRUCT__entry(
-		__string(chan,	dev_name(&dc->dev->device))
+		__string(chan,	dma_chan_name(dc))
 		__field(dma_cookie_t, cookie)
 		__field(__u32,	residue)
 	),
@@ -28,7 +28,7 @@ TRACE_EVENT(tegra_dma_complete_cb,
 	TP_PROTO(struct dma_chan *dc, int count, void *ptr),
 	TP_ARGS(dc, count, ptr),
 	TP_STRUCT__entry(
-		__string(chan,	dev_name(&dc->dev->device))
+		__string(chan,	dma_chan_name(dc))
 		__field(int,	count)
 		__field(void *,	ptr)
 		),
@@ -45,7 +45,7 @@ TRACE_EVENT(tegra_dma_isr,
 	TP_PROTO(struct dma_chan *dc, int irq),
 	TP_ARGS(dc, irq),
 	TP_STRUCT__entry(
-		__string(chan,	dev_name(&dc->dev->device))
+		__string(chan,	dma_chan_name(dc))
 		__field(int,	irq)
 	),
 	TP_fast_assign(

-- 
2.43.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v3 4/4] dmaengine: add union chan_dev for dma_chan::dev for clarity
  2026-09-04 21:49 [PATCH v3 0/4] dmaengine: rename dma_chan::dev to dma_chan::chan_dev for clarity Frank.Li
  2026-09-04 21:49 ` [PATCH v3 1/4] dmaengine: vchan: add vchan_chan_name() to get channel device name Frank.Li
  2026-09-04 21:49 ` [PATCH v3 2/4] dmaengine: use dma_chan_name() helper to get per-channel " Frank.Li
@ 2026-09-04 21:49 ` Frank.Li
  2026-09-05  7:59   ` Andy Shevchenko
  2026-09-05  8:00 ` [PATCH v3 0/4] dmaengine: rename dma_chan::dev to dma_chan::chan_dev " Andy Shevchenko
       [not found] ` <20260904-dma-chan_dev-rename-v3-3-685601b0b788@nxp.com>
  4 siblings, 1 reply; 11+ messages in thread
From: Frank.Li @ 2026-09-04 21:49 UTC (permalink / raw)
  To: Jacky Huang, Shan-Chun Hung, Vinod Koul, Frank Li, Paul Cercueil,
	Eugeniy Paltsev, Andy Shevchenko, Binbin Zhou, Patrice Chotard,
	Amélie Delaunay, Maxime Coquelin, Alexandre Torgue,
	Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Thierry Reding, Jonathan Hunter, Ludovic Desroches, Viresh Kumar,
	Keguang Zhang, Andreas Färber, Manivannan Sadhasivam,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Kelvin Cao, Logan Gunthorpe,
	Laxman Dewangan, Vignesh Raghavendra
  Cc: linux-arm-kernel, dmaengine, linux-kernel, linux-mips,
	linux-stm32, linux-trace-kernel, linux-tegra, linux-actions,
	linux-sunxi, imx, Frank Li

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

The current dma_chan structure contains both "device" and "dev". So

chan->device->dev refers to the DMA engine device.
chan->dev->device refers to the per-channel device instance.

Their similar naming makes the distinction unclear and increases reader
confusion.

Add union dma_chan::chan_dev to make its purpose explicit and clearly
identify it as the per-channel device. After all user switch to chan_dev,
union and dma_chan::dev will be removed.

Update the kernel-doc accordingly. Besides its sysfs usage, the per-channel
device is also used by some DMA engine drivers for IOMMU mapping and
therefore deserves a more accurate description.

No functional change intended.

Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
there are other user use it outside drivers/dma/ directory.
---
 drivers/dma/dmaengine.c        | 14 +++++++-------
 drivers/dma/tegra186-gpc-dma.c |  2 +-
 drivers/dma/ti/k3-udma.c       |  4 ++--
 include/linux/dmaengine.h      | 18 +++++++++++++-----
 4 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index a7ac2729e4d9d..bb30a9aa54d3f 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -1083,8 +1083,8 @@ static int __dma_async_device_channel_register(struct dma_device *device,
 	chan->local = alloc_percpu(typeof(*chan->local));
 	if (!chan->local)
 		return -ENOMEM;
-	chan->dev = kzalloc_obj(*chan->dev);
-	if (!chan->dev) {
+	chan->chan_dev = kzalloc_obj(*chan->chan_dev);
+	if (!chan->chan_dev) {
 		rc = -ENOMEM;
 		goto err_free_local;
 	}
@@ -1103,8 +1103,8 @@ static int __dma_async_device_channel_register(struct dma_device *device,
 
 	dmaengine_chan_dev(chan)->class = &dma_devclass;
 	dmaengine_chan_dev(chan)->parent = device->dev;
-	chan->dev->chan = chan;
-	chan->dev->dev_id = device->dev_id;
+	chan->chan_dev->chan = chan;
+	chan->chan_dev->dev_id = device->dev_id;
 	spin_lock_init(&chan->lock);
 
 	if (!name)
@@ -1122,7 +1122,7 @@ static int __dma_async_device_channel_register(struct dma_device *device,
  err_out_ida:
 	ida_free(&device->chan_ida, chan->chan_id);
  err_free_dev:
-	kfree(chan->dev);
+	kfree(chan->chan_dev);
  err_free_local:
 	free_percpu(chan->local);
 	chan->local = NULL;
@@ -1155,7 +1155,7 @@ static void __dma_async_device_channel_unregister(struct dma_device *device,
 		  __func__, chan->client_count);
 	mutex_lock(&dma_list_mutex);
 	device->chancnt--;
-	chan->dev->chan = NULL;
+	chan->chan_dev->chan = NULL;
 	mutex_unlock(&dma_list_mutex);
 	ida_free(&device->chan_ida, chan->chan_id);
 	device_unregister(dmaengine_chan_dev(chan));
@@ -1290,7 +1290,7 @@ int dma_async_device_register(struct dma_device *device)
 		if (chan->local == NULL)
 			continue;
 		mutex_lock(&dma_list_mutex);
-		chan->dev->chan = NULL;
+		chan->chan_dev->chan = NULL;
 		mutex_unlock(&dma_list_mutex);
 		device_unregister(dmaengine_chan_dev(chan));
 		free_percpu(chan->local);
diff --git a/drivers/dma/tegra186-gpc-dma.c b/drivers/dma/tegra186-gpc-dma.c
index b3327aa35de40..e76c58f213d84 100644
--- a/drivers/dma/tegra186-gpc-dma.c
+++ b/drivers/dma/tegra186-gpc-dma.c
@@ -1554,7 +1554,7 @@ static int tegra_dma_probe(struct platform_device *pdev)
 				return dev_err_probe(chdev, -EINVAL,
 					   "Failed to get stream ID for channel %d\n", tdc->id);
 
-			chan->dev->chan_dma_dev = true;
+			chan->chan_dev->chan_dma_dev = true;
 		}
 
 		/* program stream-id for this channel */
diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
index 49e2d0014d5ed..78a67cb9d6e00 100644
--- a/drivers/dma/ti/k3-udma.c
+++ b/drivers/dma/ti/k3-udma.c
@@ -426,12 +426,12 @@ static void k3_configure_chan_coherency(struct dma_chan *chan, u32 asel)
 
 	if (asel == 0) {
 		/* No special handling for the channel */
-		chan->dev->chan_dma_dev = false;
+		chan->chan_dev->chan_dma_dev = false;
 
 		dev_clear_dma_coherent(chan_dev);
 		chan_dev->dma_parms = NULL;
 	} else if (asel == 14 || asel == 15) {
-		chan->dev->chan_dma_dev = true;
+		chan->chan_dev->chan_dma_dev = true;
 
 		dev_set_dma_coherent(chan_dev);
 		dma_coerce_mask_and_coherent(chan_dev, DMA_BIT_MASK(48));
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 33aa1bfc8fb84..206c5dab96cd7 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -325,7 +325,8 @@ struct dma_router {
  * @lock: protect between config and prepare transfer when driver have not
  *	  implemented callback device_prep_config_sg().
  * @chan_id: channel ID for sysfs
- * @dev: class device for sysfs
+ * @chan_dev: class channel device for sysfs, some device use it for per-channel
+ *            iommu mapping.
  * @name: backlink name for sysfs
  * @dbg_client_name: slave name for debugfs in format:
  *	dev_name(requester's dev):channel name, for example: "2b00000.mcasp:tx"
@@ -351,7 +352,14 @@ struct dma_chan {
 
 	/* sysfs */
 	int chan_id;
-	struct dma_chan_dev *dev;
+	union {
+		struct dma_chan_dev *chan_dev;
+		/*
+		 * please use chan_dev, dev will be removed after all user
+		   switch to chan_dev
+		*/
+		struct dma_chan_dev *dev;
+	};
 	const char *name;
 #ifdef CONFIG_DEBUG_FS
 	char *dbg_client_name;
@@ -532,7 +540,7 @@ struct dma_slave_caps {
 
 static inline const char *dma_chan_name(struct dma_chan *chan)
 {
-	return dev_name(&chan->dev->device);
+	return dev_name(&chan->chan_dev->device);
 }
 
 /**
@@ -1805,12 +1813,12 @@ dmaengine_get_direction_text(enum dma_transfer_direction dir)
 
 static inline struct device *dmaengine_chan_dev(struct dma_chan *chan)
 {
-	return &chan->dev->device;
+	return &chan->chan_dev->device;
 }
 
 static inline struct device *dmaengine_get_dma_device(struct dma_chan *chan)
 {
-	if (chan->dev->chan_dma_dev)
+	if (chan->chan_dev->chan_dma_dev)
 		return dmaengine_chan_dev(chan);
 
 	return chan->device->dev;

-- 
2.43.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 2/4] dmaengine: use dma_chan_name() helper to get per-channel device name
  2026-09-04 21:49 ` [PATCH v3 2/4] dmaengine: use dma_chan_name() helper to get per-channel " Frank.Li
@ 2026-09-05  7:55   ` Andy Shevchenko
  2026-09-07  9:01   ` Amelie Delaunay
  1 sibling, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2026-09-05  7:55 UTC (permalink / raw)
  To: Frank.Li
  Cc: Jacky Huang, Shan-Chun Hung, Vinod Koul, Frank Li, Paul Cercueil,
	Eugeniy Paltsev, Binbin Zhou, Patrice Chotard,
	Amélie Delaunay, Maxime Coquelin, Alexandre Torgue,
	Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Thierry Reding, Jonathan Hunter, Ludovic Desroches, Viresh Kumar,
	Keguang Zhang, Andreas Färber, Manivannan Sadhasivam,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Kelvin Cao, Logan Gunthorpe,
	Laxman Dewangan, Vignesh Raghavendra, linux-arm-kernel, dmaengine,
	linux-kernel, linux-mips, linux-stm32, linux-trace-kernel,
	linux-tegra, linux-actions, linux-sunxi, imx, Frank Li

On Fri, Sep 04, 2026 at 05:49:44PM -0400, Frank.Li@oss.nxp.com wrote:

> Use the existing dma_chan_name() helper to obtain the per-channel device
> name instead of open-coding: dev_name(chan->dev->device) /
> dev_name(chan2dev())
> 
> Simplify the code and improve consistency.
> 
> No functional change intended.

...

> @@ -507,7 +507,7 @@ static int idma64_alloc_chan_resources(struct dma_chan *chan)
>  	struct idma64_chan *idma64c = to_idma64_chan(chan);
>  
>  	/* Create a pool of consistent memory blocks for hardware descriptors */
> -	idma64c->pool = dma_pool_create(dev_name(chan2dev(chan)),
> +	idma64c->pool = dma_pool_create(dma_chan_name(chan),
>  					chan->device->dev,
>  					sizeof(struct idma64_lli), 8, 0);

For example here it may now be condensed to less LoC:

	idma64c->pool = dma_pool_create(dma_chan_name(chan), chan->device->dev,
					sizeof(struct idma64_lli), 8, 0);

Consider that in case you will need a new version (no need
to address it separately).

-- 
With Best Regards,
Andy Shevchenko




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 4/4] dmaengine: add union chan_dev for dma_chan::dev for clarity
  2026-09-04 21:49 ` [PATCH v3 4/4] dmaengine: add union chan_dev for dma_chan::dev for clarity Frank.Li
@ 2026-09-05  7:59   ` Andy Shevchenko
  0 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2026-09-05  7:59 UTC (permalink / raw)
  To: Frank.Li
  Cc: Jacky Huang, Shan-Chun Hung, Vinod Koul, Frank Li, Paul Cercueil,
	Eugeniy Paltsev, Binbin Zhou, Patrice Chotard,
	Amélie Delaunay, Maxime Coquelin, Alexandre Torgue,
	Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Thierry Reding, Jonathan Hunter, Ludovic Desroches, Viresh Kumar,
	Keguang Zhang, Andreas Färber, Manivannan Sadhasivam,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Kelvin Cao, Logan Gunthorpe,
	Laxman Dewangan, Vignesh Raghavendra, linux-arm-kernel, dmaengine,
	linux-kernel, linux-mips, linux-stm32, linux-trace-kernel,
	linux-tegra, linux-actions, linux-sunxi, imx, Frank Li

On Fri, Sep 04, 2026 at 05:49:46PM -0400, Frank.Li@oss.nxp.com wrote:

> The current dma_chan structure contains both "device" and "dev". So
> 
> chan->device->dev refers to the DMA engine device.
> chan->dev->device refers to the per-channel device instance.
> 
> Their similar naming makes the distinction unclear and increases reader
> confusion.
> 
> Add union dma_chan::chan_dev to make its purpose explicit and clearly
> identify it as the per-channel device. After all user switch to chan_dev,
> union and dma_chan::dev will be removed.
> 
> Update the kernel-doc accordingly. Besides its sysfs usage, the per-channel
> device is also used by some DMA engine drivers for IOMMU mapping and
> therefore deserves a more accurate description.
> 
> No functional change intended.

I was almost ready to give a tag for the entire series, but found a minor
issue here...

...

> +++ b/include/linux/dmaengine.h
> struct dma_router {

>   * @lock: protect between config and prepare transfer when driver have not
>   *	  implemented callback device_prep_config_sg().
>   * @chan_id: channel ID for sysfs
> - * @dev: class device for sysfs
> + * @chan_dev: class channel device for sysfs, some device use it for per-channel
> + *            iommu mapping.

IOMMU

>   * @name: backlink name for sysfs
>   * @dbg_client_name: slave name for debugfs in format:
>   *	dev_name(requester's dev):channel name, for example: "2b00000.mcasp:tx"

> struct dma_chan {

>  
>  	/* sysfs */
>  	int chan_id;
> -	struct dma_chan_dev *dev;
> +	union {
> +		struct dma_chan_dev *chan_dev;
> +		/*
> +		 * please use chan_dev, dev will be removed after all user
> +		   switch to chan_dev
> +		*/

Something went wrong with this comment style. It also need to respect English
grammar and punctuation as we do for multi-line comments.

> +		struct dma_chan_dev *dev;
> +	};
>  	const char *name;
>  #ifdef CONFIG_DEBUG_FS
>  	char *dbg_client_name;

-- 
With Best Regards,
Andy Shevchenko




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 0/4] dmaengine: rename dma_chan::dev to dma_chan::chan_dev for clarity
  2026-09-04 21:49 [PATCH v3 0/4] dmaengine: rename dma_chan::dev to dma_chan::chan_dev for clarity Frank.Li
                   ` (2 preceding siblings ...)
  2026-09-04 21:49 ` [PATCH v3 4/4] dmaengine: add union chan_dev for dma_chan::dev for clarity Frank.Li
@ 2026-09-05  8:00 ` Andy Shevchenko
       [not found] ` <20260904-dma-chan_dev-rename-v3-3-685601b0b788@nxp.com>
  4 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2026-09-05  8:00 UTC (permalink / raw)
  To: Frank.Li
  Cc: Jacky Huang, Shan-Chun Hung, Vinod Koul, Frank Li, Paul Cercueil,
	Eugeniy Paltsev, Binbin Zhou, Patrice Chotard,
	Amélie Delaunay, Maxime Coquelin, Alexandre Torgue,
	Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Thierry Reding, Jonathan Hunter, Ludovic Desroches, Viresh Kumar,
	Keguang Zhang, Andreas Färber, Manivannan Sadhasivam,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Kelvin Cao, Logan Gunthorpe,
	Laxman Dewangan, Vignesh Raghavendra, linux-arm-kernel, dmaengine,
	linux-kernel, linux-mips, linux-stm32, linux-trace-kernel,
	linux-tegra, linux-actions, linux-sunxi, imx, Frank Li

On Fri, Sep 04, 2026 at 05:49:42PM -0400, Frank.Li@oss.nxp.com wrote:
> The current dma_chan structure contains both "device" and "dev". So
> 
>     chan->device->dev refers to the DMA engine device.
>     chan->dev->device refers to the per-channel device instance.
> 
> Their similar naming makes the distinction unclear and increases reader
> confusion.
> 
> Add union dma_chan::chan_dev to make its purpose explicit and clearly
> identify it as the per-channel device. After all user switch to chan_dev,
> union and dma_chan::dev will be removed.
> 
> Update the kernel-doc accordingly. Besides its sysfs usage, the per-channel
> device is also used by some DMA engine drivers for IOMMU mapping and
> therefore deserves a more accurate description.
> 
> 1st patch add help vchan_chan_name()
> 2nd patch use existing helper dma_chan_name() to reduce rename difference.
> 3rd patch add (dmaengine|vchan)_chan_dev() helper
> 4th patch add union chan_dev for dma_chan::dev for clarity
> 
> Need following patch to clean other dma engineer driver, which is not
> in drivers/dma
> 
> After complete all rename work, dma_chan::dev can be removed.

Nice work!
I have one comment against patch 4/4, after addressing that feel free to add
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
to the entire series.

-- 
With Best Regards,
Andy Shevchenko




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 3/4] dmaengine: add (dmaengine|vchan)_chan_dev() helper
       [not found] ` <20260904-dma-chan_dev-rename-v3-3-685601b0b788@nxp.com>
@ 2026-09-07  8:55   ` Amelie Delaunay
  2026-09-09 12:39     ` Vinod Koul
  0 siblings, 1 reply; 11+ messages in thread
From: Amelie Delaunay @ 2026-09-07  8:55 UTC (permalink / raw)
  To: Frank.Li, Jacky Huang, Shan-Chun Hung, Vinod Koul, Frank Li,
	Paul Cercueil, Eugeniy Paltsev, Andy Shevchenko, Binbin Zhou,
	Patrice Chotard, Maxime Coquelin, Alexandre Torgue,
	Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Thierry Reding, Jonathan Hunter, Ludovic Desroches, Viresh Kumar,
	Keguang Zhang, Andreas Färber, Manivannan Sadhasivam,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Kelvin Cao, Logan Gunthorpe,
	Laxman Dewangan, Vignesh Raghavendra
  Cc: linux-arm-kernel, dmaengine, linux-kernel, linux-mips,
	linux-stm32, linux-trace-kernel, linux-tegra, linux-actions,
	linux-sunxi, imx, Frank Li

Hi Frank,

On 9/4/26 23:49, Frank.Li@oss.nxp.com wrote:
[...]

I don't think removing chan2dev() function from the STM32 DMA drivers is 
an improvement, since the parameter is a `stm32` chan, not a `dma_chan`. 
chan2dev() was meant to expose the channel device behind the `stm32` 
wrapper and keep logging concise.

> diff --git a/drivers/dma/stm32/stm32-dma.c b/drivers/dma/stm32/stm32-dma.c
> index 3e8151e2ad75a..4688cebaf7f7a 100644
> --- a/drivers/dma/stm32/stm32-dma.c
> +++ b/drivers/dma/stm32/stm32-dma.c
> @@ -248,11 +248,6 @@ static struct stm32_dma_desc *to_stm32_dma_desc(struct virt_dma_desc *vdesc)
>   	return container_of(vdesc, struct stm32_dma_desc, vdesc);
>   }
>   
> -static struct device *chan2dev(struct stm32_dma_chan *chan)
> -{
> -	return &chan->vchan.chan.dev->device;
> -}
> -

I would rather keep it as:

static struct device *chan2dev(struct stm32_dma_chan *chan)
{
	return vchan_chan_dev(&chan->vchan);
}

and then drop all further updates.

>   static u32 stm32_dma_read(struct stm32_dma_device *dmadev, u32 reg)
>   {
>   	return readl_relaxed(dmadev->base + reg);
> @@ -274,7 +269,7 @@ static int stm32_dma_get_width(struct stm32_dma_chan *chan,
>   	case DMA_SLAVE_BUSWIDTH_4_BYTES:
>   		return STM32_DMA_WORD;
>   	default:
> -		dev_err(chan2dev(chan), "Dma bus width not supported\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "Dma bus width not supported\n");
>   		return -EINVAL;
>   	}
>   }
> @@ -374,7 +369,7 @@ static int stm32_dma_get_burst(struct stm32_dma_chan *chan, u32 maxburst)
>   	case 16:
>   		return STM32_DMA_BURST_INCR16;
>   	default:
> -		dev_err(chan2dev(chan), "Dma burst size not supported\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "Dma burst size not supported\n");
>   		return -EINVAL;
>   	}
>   }
> @@ -487,7 +482,7 @@ static void stm32_dma_stop(struct stm32_dma_chan *chan)
>   	/* Clear interrupt status if it is there */
>   	status = stm32_dma_irq_status(chan);
>   	if (status) {
> -		dev_dbg(chan2dev(chan), "%s(): clearing interrupt: 0x%08x\n",
> +		dev_dbg(vchan_chan_dev(&chan->vchan), "%s(): clearing interrupt: 0x%08x\n",
>   			__func__, status);
>   		stm32_dma_irq_clear(chan, status);
>   	}
> @@ -536,12 +531,12 @@ static void stm32_dma_dump_reg(struct stm32_dma_chan *chan)
>   	u32 sm1ar = stm32_dma_read(dmadev, STM32_DMA_SM1AR(chan->id));
>   	u32 sfcr = stm32_dma_read(dmadev, STM32_DMA_SFCR(chan->id));
>   
> -	dev_dbg(chan2dev(chan), "SCR:   0x%08x\n", scr);
> -	dev_dbg(chan2dev(chan), "NDTR:  0x%08x\n", ndtr);
> -	dev_dbg(chan2dev(chan), "SPAR:  0x%08x\n", spar);
> -	dev_dbg(chan2dev(chan), "SM0AR: 0x%08x\n", sm0ar);
> -	dev_dbg(chan2dev(chan), "SM1AR: 0x%08x\n", sm1ar);
> -	dev_dbg(chan2dev(chan), "SFCR:  0x%08x\n", sfcr);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "SCR:   0x%08x\n", scr);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "NDTR:  0x%08x\n", ndtr);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "SPAR:  0x%08x\n", spar);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "SM0AR: 0x%08x\n", sm0ar);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "SM1AR: 0x%08x\n", sm1ar);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "SFCR:  0x%08x\n", sfcr);
>   }
>   
>   static void stm32_dma_sg_inc(struct stm32_dma_chan *chan)
> @@ -613,7 +608,7 @@ static void stm32_dma_start_transfer(struct stm32_dma_chan *chan)
>   	reg->dma_scr |= STM32_DMA_SCR_EN;
>   	stm32_dma_write(dmadev, STM32_DMA_SCR(chan->id), reg->dma_scr);
>   
> -	dev_dbg(chan2dev(chan), "vchan %p: started\n", &chan->vchan);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "vchan %p: started\n", &chan->vchan);
>   }
>   
>   static void stm32_dma_configure_next_sg(struct stm32_dma_chan *chan)
> @@ -630,12 +625,12 @@ static void stm32_dma_configure_next_sg(struct stm32_dma_chan *chan)
>   	if (dma_scr & STM32_DMA_SCR_CT) {
>   		dma_sm0ar = sg_req->chan_reg.dma_sm0ar;
>   		stm32_dma_write(dmadev, STM32_DMA_SM0AR(id), dma_sm0ar);
> -		dev_dbg(chan2dev(chan), "CT=1 <=> SM0AR: 0x%08x\n",
> +		dev_dbg(vchan_chan_dev(&chan->vchan), "CT=1 <=> SM0AR: 0x%08x\n",
>   			stm32_dma_read(dmadev, STM32_DMA_SM0AR(id)));
>   	} else {
>   		dma_sm1ar = sg_req->chan_reg.dma_sm1ar;
>   		stm32_dma_write(dmadev, STM32_DMA_SM1AR(id), dma_sm1ar);
> -		dev_dbg(chan2dev(chan), "CT=0 <=> SM1AR: 0x%08x\n",
> +		dev_dbg(vchan_chan_dev(&chan->vchan), "CT=0 <=> SM1AR: 0x%08x\n",
>   			stm32_dma_read(dmadev, STM32_DMA_SM1AR(id)));
>   	}
>   }
> @@ -676,7 +671,7 @@ static void stm32_dma_handle_chan_paused(struct stm32_dma_chan *chan)
>   
>   	chan->status = DMA_PAUSED;
>   
> -	dev_dbg(chan2dev(chan), "vchan %p: paused\n", &chan->vchan);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "vchan %p: paused\n", &chan->vchan);
>   }
>   
>   static void stm32_dma_post_resume_reconfigure(struct stm32_dma_chan *chan)
> @@ -728,7 +723,7 @@ static void stm32_dma_post_resume_reconfigure(struct stm32_dma_chan *chan)
>   	dma_scr |= STM32_DMA_SCR_EN;
>   	stm32_dma_write(dmadev, STM32_DMA_SCR(chan->id), dma_scr);
>   
> -	dev_dbg(chan2dev(chan), "vchan %p: reconfigured after pause/resume\n", &chan->vchan);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "vchan %p: reconfigured after pause/resume\n", &chan->vchan);
>   }
>   
>   static void stm32_dma_handle_chan_done(struct stm32_dma_chan *chan, u32 scr)
> @@ -775,16 +770,16 @@ static irqreturn_t stm32_dma_chan_irq(int irq, void *devid)
>   		if (sfcr & STM32_DMA_SFCR_FEIE) {
>   			if (!(scr & STM32_DMA_SCR_EN) &&
>   			    !(status & STM32_DMA_TCI))
> -				dev_err(chan2dev(chan), "FIFO Error\n");
> +				dev_err(vchan_chan_dev(&chan->vchan), "FIFO Error\n");
>   			else
> -				dev_dbg(chan2dev(chan), "FIFO over/underrun\n");
> +				dev_dbg(vchan_chan_dev(&chan->vchan), "FIFO over/underrun\n");
>   		}
>   	}
>   	if (status & STM32_DMA_DMEI) {
>   		stm32_dma_irq_clear(chan, STM32_DMA_DMEI);
>   		status &= ~STM32_DMA_DMEI;
>   		if (sfcr & STM32_DMA_SCR_DMEIE)
> -			dev_dbg(chan2dev(chan), "Direct mode overrun\n");
> +			dev_dbg(vchan_chan_dev(&chan->vchan), "Direct mode overrun\n");
>   	}
>   
>   	if (status & STM32_DMA_TCI) {
> @@ -803,9 +798,9 @@ static irqreturn_t stm32_dma_chan_irq(int irq, void *devid)
>   
>   	if (status) {
>   		stm32_dma_irq_clear(chan, status);
> -		dev_err(chan2dev(chan), "DMA error: status=0x%08x\n", status);
> +		dev_err(vchan_chan_dev(&chan->vchan), "DMA error: status=0x%08x\n", status);
>   		if (!(scr & STM32_DMA_SCR_EN))
> -			dev_err(chan2dev(chan), "chan disabled by HW\n");
> +			dev_err(vchan_chan_dev(&chan->vchan), "chan disabled by HW\n");
>   	}
>   
>   	spin_unlock(&chan->vchan.lock);
> @@ -820,7 +815,7 @@ static void stm32_dma_issue_pending(struct dma_chan *c)
>   
>   	spin_lock_irqsave(&chan->vchan.lock, flags);
>   	if (vchan_issue_pending(&chan->vchan) && !chan->desc && !chan->busy) {
> -		dev_dbg(chan2dev(chan), "vchan %p: issued\n", &chan->vchan);
> +		dev_dbg(vchan_chan_dev(&chan->vchan), "vchan %p: issued\n", &chan->vchan);
>   		stm32_dma_start_transfer(chan);
>   
>   	}
> @@ -922,7 +917,7 @@ static int stm32_dma_resume(struct dma_chan *c)
>   
>   	spin_unlock_irqrestore(&chan->vchan.lock, flags);
>   
> -	dev_dbg(chan2dev(chan), "vchan %p: resumed\n", &chan->vchan);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "vchan %p: resumed\n", &chan->vchan);
>   
>   	return 0;
>   }
> @@ -1059,7 +1054,7 @@ static int stm32_dma_set_xfer_param(struct stm32_dma_chan *chan,
>   		break;
>   
>   	default:
> -		dev_err(chan2dev(chan), "Dma direction is not supported\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "Dma direction is not supported\n");
>   		return -EINVAL;
>   	}
>   
> @@ -1092,12 +1087,12 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_slave_sg(
>   	int i, ret;
>   
>   	if (!chan->config_init) {
> -		dev_err(chan2dev(chan), "dma channel is not configured\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "dma channel is not configured\n");
>   		return NULL;
>   	}
>   
>   	if (sg_len < 1) {
> -		dev_err(chan2dev(chan), "Invalid segment length %d\n", sg_len);
> +		dev_err(vchan_chan_dev(&chan->vchan), "Invalid segment length %d\n", sg_len);
>   		return NULL;
>   	}
>   
> @@ -1129,7 +1124,7 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_slave_sg(
>   
>   		nb_data_items = desc->sg_req[i].len / buswidth;
>   		if (nb_data_items > STM32_DMA_ALIGNED_MAX_DATA_ITEMS) {
> -			dev_err(chan2dev(chan), "nb items not supported\n");
> +			dev_err(vchan_chan_dev(&chan->vchan), "nb items not supported\n");
>   			goto err;
>   		}
>   
> @@ -1164,17 +1159,17 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_dma_cyclic(
>   	int i, ret;
>   
>   	if (!buf_len || !period_len) {
> -		dev_err(chan2dev(chan), "Invalid buffer/period len\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "Invalid buffer/period len\n");
>   		return NULL;
>   	}
>   
>   	if (!chan->config_init) {
> -		dev_err(chan2dev(chan), "dma channel is not configured\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "dma channel is not configured\n");
>   		return NULL;
>   	}
>   
>   	if (buf_len % period_len) {
> -		dev_err(chan2dev(chan), "buf_len not multiple of period_len\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "buf_len not multiple of period_len\n");
>   		return NULL;
>   	}
>   
> @@ -1185,7 +1180,7 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_dma_cyclic(
>   	 * terminating the DMA.
>   	 */
>   	if (chan->busy) {
> -		dev_err(chan2dev(chan), "Request not allowed when dma busy\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "Request not allowed when dma busy\n");
>   		return NULL;
>   	}
>   
> @@ -1196,7 +1191,7 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_dma_cyclic(
>   
>   	nb_data_items = period_len / buswidth;
>   	if (nb_data_items > STM32_DMA_ALIGNED_MAX_DATA_ITEMS) {
> -		dev_err(chan2dev(chan), "number of items not supported\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "number of items not supported\n");
>   		return NULL;
>   	}
>   
> @@ -1478,7 +1473,7 @@ static void stm32_dma_free_chan_resources(struct dma_chan *c)
>   	struct stm32_dma_device *dmadev = stm32_dma_get_dev(chan);
>   	unsigned long flags;
>   
> -	dev_dbg(chan2dev(chan), "Freeing channel %d\n", chan->id);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "Freeing channel %d\n", chan->id);
>   
>   	if (chan->busy) {
>   		spin_lock_irqsave(&chan->vchan.lock, flags);
> diff --git a/drivers/dma/stm32/stm32-dma3.c b/drivers/dma/stm32/stm32-dma3.c
> index 6ee7a1435efb6..4fe226541efa4 100644
> --- a/drivers/dma/stm32/stm32-dma3.c
> +++ b/drivers/dma/stm32/stm32-dma3.c
> @@ -328,11 +328,6 @@ static inline struct stm32_dma3_swdesc *to_stm32_dma3_swdesc(struct virt_dma_des
>   	return container_of(vdesc, struct stm32_dma3_swdesc, vdesc);
>   }
>   
> -static struct device *chan2dev(struct stm32_dma3_chan *chan)
> -{
> -	return &chan->vchan.chan.dev->device;
> -}
> -

ditto here:
static struct device *chan2dev(struct stm32_dma3_chan *chan)
{
	return vchan_chan_dev(&chan->vchan);
}

and below, keep chan2dev() instead

>   static struct device *ddata2dev(struct stm32_dma3_ddata *ddata)
>   {
>   	return ddata->dma_dev.dev;
> @@ -341,7 +336,7 @@ static struct device *ddata2dev(struct stm32_dma3_ddata *ddata)
>   static void stm32_dma3_chan_dump_reg(struct stm32_dma3_chan *chan)
>   {
>   	struct stm32_dma3_ddata *ddata = to_stm32_dma3_ddata(chan);
> -	struct device *dev = chan2dev(chan);
> +	struct device *dev = vchan_chan_dev(&chan->vchan);
>   	u32 id = chan->id, offset;
>   
>   	offset = STM32_DMA3_SECCFGR;
> @@ -381,21 +376,21 @@ static void stm32_dma3_chan_dump_hwdesc(struct stm32_dma3_chan *chan,
>   	for (i = 0; i < swdesc->lli_size; i++) {
>   		hwdesc = swdesc->lli[i].hwdesc;
>   		if (i)
> -			dev_dbg(chan2dev(chan), "V\n");
> -		dev_dbg(chan2dev(chan), "[%d]@%pad\n", i, &swdesc->lli[i].hwdesc_addr);
> -		dev_dbg(chan2dev(chan), "| C%dTR1: %08x\n", chan->id, hwdesc->ctr1);
> -		dev_dbg(chan2dev(chan), "| C%dTR2: %08x\n", chan->id, hwdesc->ctr2);
> -		dev_dbg(chan2dev(chan), "| C%dBR1: %08x\n", chan->id, hwdesc->cbr1);
> -		dev_dbg(chan2dev(chan), "| C%dSAR: %08x\n", chan->id, hwdesc->csar);
> -		dev_dbg(chan2dev(chan), "| C%dDAR: %08x\n", chan->id, hwdesc->cdar);
> -		dev_dbg(chan2dev(chan), "| C%dLLR: %08x\n", chan->id, hwdesc->cllr);
> +			dev_dbg(vchan_chan_dev(&chan->vchan), "V\n");
> +		dev_dbg(vchan_chan_dev(&chan->vchan), "[%d]@%pad\n", i, &swdesc->lli[i].hwdesc_addr);
> +		dev_dbg(vchan_chan_dev(&chan->vchan), "| C%dTR1: %08x\n", chan->id, hwdesc->ctr1);
> +		dev_dbg(vchan_chan_dev(&chan->vchan), "| C%dTR2: %08x\n", chan->id, hwdesc->ctr2);
> +		dev_dbg(vchan_chan_dev(&chan->vchan), "| C%dBR1: %08x\n", chan->id, hwdesc->cbr1);
> +		dev_dbg(vchan_chan_dev(&chan->vchan), "| C%dSAR: %08x\n", chan->id, hwdesc->csar);
> +		dev_dbg(vchan_chan_dev(&chan->vchan), "| C%dDAR: %08x\n", chan->id, hwdesc->cdar);
> +		dev_dbg(vchan_chan_dev(&chan->vchan), "| C%dLLR: %08x\n", chan->id, hwdesc->cllr);
>   	}
>   
>   	if (swdesc->cyclic) {
> -		dev_dbg(chan2dev(chan), "|\n");
> -		dev_dbg(chan2dev(chan), "-->[0]@%pad\n", &swdesc->lli[0].hwdesc_addr);
> +		dev_dbg(vchan_chan_dev(&chan->vchan), "|\n");
> +		dev_dbg(vchan_chan_dev(&chan->vchan), "-->[0]@%pad\n", &swdesc->lli[0].hwdesc_addr);
>   	} else {
> -		dev_dbg(chan2dev(chan), "X\n");
> +		dev_dbg(vchan_chan_dev(&chan->vchan), "X\n");
>   	}
>   }
>   
> @@ -411,7 +406,7 @@ static struct stm32_dma3_swdesc *stm32_dma3_chan_desc_alloc(struct stm32_dma3_ch
>   	 * addressed, so abort the allocation.
>   	 */
>   	if ((count * 32) > CLLR_LA) {
> -		dev_err(chan2dev(chan), "Transfer is too big (> %luB)\n", STM32_DMA3_MAX_SEG_SIZE);
> +		dev_err(vchan_chan_dev(&chan->vchan), "Transfer is too big (> %luB)\n", STM32_DMA3_MAX_SEG_SIZE);
>   		return NULL;
>   	}
>   
> @@ -438,7 +433,7 @@ static struct stm32_dma3_swdesc *stm32_dma3_chan_desc_alloc(struct stm32_dma3_ch
>   	return swdesc;
>   
>   err_pool_free:
> -	dev_err(chan2dev(chan), "Failed to alloc descriptors\n");
> +	dev_err(vchan_chan_dev(&chan->vchan), "Failed to alloc descriptors\n");
>   	while (--i >= 0)
>   		dma_pool_free(chan->lli_pool, swdesc->lli[i].hwdesc, swdesc->lli[i].hwdesc_addr);
>   	kfree(swdesc);
> @@ -468,7 +463,7 @@ static void stm32_dma3_chan_vdesc_free(struct virt_dma_desc *vdesc)
>   static void stm32_dma3_check_user_setting(struct stm32_dma3_chan *chan)
>   {
>   	struct stm32_dma3_ddata *ddata = to_stm32_dma3_ddata(chan);
> -	struct device *dev = chan2dev(chan);
> +	struct device *dev = vchan_chan_dev(&chan->vchan);
>   	u32 ctr1 = readl_relaxed(ddata->base + STM32_DMA3_CTR1(chan->id));
>   	u32 cbr1 = readl_relaxed(ddata->base + STM32_DMA3_CBR1(chan->id));
>   	u32 csar = readl_relaxed(ddata->base + STM32_DMA3_CSAR(chan->id));
> @@ -579,7 +574,7 @@ static int stm32_dma3_chan_prep_hw(struct stm32_dma3_chan *chan, enum dma_transf
>   	u32 sap = FIELD_GET(STM32_DMA3_DT_SAP, tr_conf), sap_max_dw;
>   	u32 dap = FIELD_GET(STM32_DMA3_DT_DAP, tr_conf), dap_max_dw;
>   
> -	dev_dbg(chan2dev(chan), "%s from %pad to %pad\n",
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "%s from %pad to %pad\n",
>   		dmaengine_get_direction_text(dir), &src_addr, &dst_addr);
>   
>   	sdw = chan->dma_config.src_addr_width ? : get_chan_max_dw(sap, chan->max_burst);
> @@ -589,12 +584,12 @@ static int stm32_dma3_chan_prep_hw(struct stm32_dma3_chan *chan, enum dma_transf
>   
>   	/* Following conditions would raise User Setting Error interrupt */
>   	if (!(dma_device.src_addr_widths & BIT(sdw)) || !(dma_device.dst_addr_widths & BIT(ddw))) {
> -		dev_err(chan2dev(chan), "Bus width (src=%u, dst=%u) not supported\n", sdw, ddw);
> +		dev_err(vchan_chan_dev(&chan->vchan), "Bus width (src=%u, dst=%u) not supported\n", sdw, ddw);
>   		return -EINVAL;
>   	}
>   
>   	if (ddata->ports_max_dw[1] == DW_INVALID && (sap || dap)) {
> -		dev_err(chan2dev(chan), "Only one master port, port 1 is not supported\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "Only one master port, port 1 is not supported\n");
>   		return -EINVAL;
>   	}
>   
> @@ -602,7 +597,7 @@ static int stm32_dma3_chan_prep_hw(struct stm32_dma3_chan *chan, enum dma_transf
>   	dap_max_dw = ddata->ports_max_dw[dap];
>   	if ((port_is_ahb(sap_max_dw) && sdw == DMA_SLAVE_BUSWIDTH_8_BYTES) ||
>   	    (port_is_ahb(dap_max_dw) && ddw == DMA_SLAVE_BUSWIDTH_8_BYTES)) {
> -		dev_err(chan2dev(chan),
> +		dev_err(vchan_chan_dev(&chan->vchan),
>   			"8 bytes buswidth (src=%u, dst=%u) not supported on port (sap=%u, dap=%u\n",
>   			sdw, ddw, sap, dap);
>   		return -EINVAL;
> @@ -659,7 +654,7 @@ static int stm32_dma3_chan_prep_hw(struct stm32_dma3_chan *chan, enum dma_transf
>   			_ctr1 |= FIELD_PREP(CTR1_PAM, CTR1_PAM_PACK_UNPACK);
>   			/* Should never reach this case as ddw is clamped down */
>   			if (len & (ddw - 1)) {
> -				dev_err(chan2dev(chan),
> +				dev_err(vchan_chan_dev(&chan->vchan),
>   					"Packing mode is enabled and len is not multiple of ddw");
>   				return -EINVAL;
>   			}
> @@ -695,7 +690,7 @@ static int stm32_dma3_chan_prep_hw(struct stm32_dma3_chan *chan, enum dma_transf
>   			_ctr1 |= FIELD_PREP(CTR1_PAM, CTR1_PAM_PACK_UNPACK);
>   			/* Should never reach this case as ddw is clamped down */
>   			if (len & (ddw - 1)) {
> -				dev_err(chan2dev(chan),
> +				dev_err(vchan_chan_dev(&chan->vchan),
>   					"Packing mode is enabled and len is not multiple of ddw\n");
>   				return -EINVAL;
>   			}
> @@ -740,7 +735,7 @@ static int stm32_dma3_chan_prep_hw(struct stm32_dma3_chan *chan, enum dma_transf
>   			_ctr1 |= FIELD_PREP(CTR1_PAM, CTR1_PAM_PACK_UNPACK);
>   			/* Should never reach this case as ddw is clamped down */
>   			if (len & (ddw - 1)) {
> -				dev_err(chan2dev(chan),
> +				dev_err(vchan_chan_dev(&chan->vchan),
>   					"Packing mode is enabled and len is not multiple of ddw");
>   				return -EINVAL;
>   			}
> @@ -752,7 +747,7 @@ static int stm32_dma3_chan_prep_hw(struct stm32_dma3_chan *chan, enum dma_transf
>   		break;
>   
>   	default:
> -		dev_err(chan2dev(chan), "Direction %s not supported\n",
> +		dev_err(vchan_chan_dev(&chan->vchan), "Direction %s not supported\n",
>   			dmaengine_get_direction_text(dir));
>   		return -EINVAL;
>   	}
> @@ -761,7 +756,7 @@ static int stm32_dma3_chan_prep_hw(struct stm32_dma3_chan *chan, enum dma_transf
>   	*ctr1 = _ctr1;
>   	*ctr2 = _ctr2;
>   
> -	dev_dbg(chan2dev(chan), "%s: sdw=%u bytes sbl=%u beats ddw=%u bytes dbl=%u beats\n",
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "%s: sdw=%u bytes sbl=%u beats ddw=%u bytes dbl=%u beats\n",
>   		__func__, sdw, sbl_max, ddw, dbl_max);
>   
>   	return 0;
> @@ -807,7 +802,7 @@ static void stm32_dma3_chan_start(struct stm32_dma3_chan *chan)
>   
>   	chan->dma_status = DMA_IN_PROGRESS;
>   
> -	dev_dbg(chan2dev(chan), "vchan %p: started\n", &chan->vchan);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "vchan %p: started\n", &chan->vchan);
>   }
>   
>   static int stm32_dma3_chan_suspend(struct stm32_dma3_chan *chan, bool susp)
> @@ -871,7 +866,7 @@ static void stm32_dma3_chan_set_residue(struct stm32_dma3_chan *chan,
>   					struct dma_tx_state *txstate)
>   {
>   	struct stm32_dma3_ddata *ddata = to_stm32_dma3_ddata(chan);
> -	struct device *dev = chan2dev(chan);
> +	struct device *dev = vchan_chan_dev(&chan->vchan);
>   	struct stm32_dma3_hwdesc *hwdesc;
>   	u32 residue, curr_lli, csr, cdar, cbr1, cllr, bndt, fifol;
>   	bool pack_unpack;
> @@ -921,7 +916,7 @@ static void stm32_dma3_chan_set_residue(struct stm32_dma3_chan *chan,
>   	/* Get current hwdesc and cumulate residue of pending hwdesc BNDT */
>   	ret = stm32_dma3_chan_get_curr_hwdesc(swdesc, cllr, &residue);
>   	if (ret < 0) {
> -		dev_err(chan2dev(chan), "Can't get residue: current hwdesc not found\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "Can't get residue: current hwdesc not found\n");
>   		return;
>   	}
>   	curr_lli = ret;
> @@ -957,7 +952,7 @@ static void stm32_dma3_chan_set_residue(struct stm32_dma3_chan *chan,
>   
>   skip_fifol_update:
>   	if (fifol) {
> -		dev_dbg(chan2dev(chan), "%u byte(s) in the FIFO\n", fifol);
> +		dev_dbg(vchan_chan_dev(&chan->vchan), "%u byte(s) in the FIFO\n", fifol);
>   		dma_set_in_flight_bytes(txstate, fifol);
>   		/*
>   		 * Residue is already accurate for DMA_MEM_TO_DEV as BNDT reflects data read from
> @@ -987,7 +982,7 @@ static int stm32_dma3_chan_stop(struct stm32_dma3_chan *chan)
>   		/* Suspend the channel */
>   		ret = stm32_dma3_chan_suspend(chan, true);
>   		if (ret)
> -			dev_warn(chan2dev(chan), "%s: timeout, data might be lost\n", __func__);
> +			dev_warn(vchan_chan_dev(&chan->vchan), "%s: timeout, data might be lost\n", __func__);
>   	}
>   
>   	/*
> @@ -1034,7 +1029,7 @@ static irqreturn_t stm32_dma3_chan_irq(int irq, void *devid)
>   	}
>   
>   	if (csr & CSR_USEF && ccr & CCR_USEIE) {
> -		dev_err(chan2dev(chan), "User setting error\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "User setting error\n");
>   		chan->dma_status = DMA_ERROR;
>   		/* CCR.EN automatically cleared by HW */
>   		stm32_dma3_check_user_setting(chan);
> @@ -1042,14 +1037,14 @@ static irqreturn_t stm32_dma3_chan_irq(int irq, void *devid)
>   	}
>   
>   	if (csr & CSR_ULEF && ccr & CCR_ULEIE) {
> -		dev_err(chan2dev(chan), "Update link transfer error\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "Update link transfer error\n");
>   		chan->dma_status = DMA_ERROR;
>   		/* CCR.EN automatically cleared by HW */
>   		stm32_dma3_chan_reset(chan);
>   	}
>   
>   	if (csr & CSR_DTEF && ccr & CCR_DTEIE) {
> -		dev_err(chan2dev(chan), "Data transfer error\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "Data transfer error\n");
>   		chan->dma_status = DMA_ERROR;
>   		/* CCR.EN automatically cleared by HW */
>   		stm32_dma3_chan_reset(chan);
> @@ -1087,13 +1082,13 @@ static int stm32_dma3_get_chan_sem(struct stm32_dma3_chan *chan)
>   		goto bad_cid;
>   
>   	chan->semaphore_taken = true;
> -	dev_dbg(chan2dev(chan), "under CID1 control (semcr=0x%08x)\n", csemcr);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "under CID1 control (semcr=0x%08x)\n", csemcr);
>   
>   	return 0;
>   
>   bad_cid:
>   	chan->semaphore_taken = false;
> -	dev_err(chan2dev(chan), "not under CID1 control (in-use by CID%d)\n", ccid);
> +	dev_err(vchan_chan_dev(&chan->vchan), "not under CID1 control (in-use by CID%d)\n", ccid);
>   
>   	return -EACCES;
>   }
> @@ -1105,7 +1100,7 @@ static void stm32_dma3_put_chan_sem(struct stm32_dma3_chan *chan)
>   	if (chan->semaphore_taken) {
>   		writel_relaxed(0, ddata->base + STM32_DMA3_CSEMCR(chan->id));
>   		chan->semaphore_taken = false;
> -		dev_dbg(chan2dev(chan), "no more under CID1 control\n");
> +		dev_dbg(vchan_chan_dev(&chan->vchan), "no more under CID1 control\n");
>   	}
>   }
>   
> @@ -1130,7 +1125,7 @@ static int stm32_dma3_alloc_chan_resources(struct dma_chan *c)
>   					  sizeof(struct stm32_dma3_hwdesc),
>   					  __alignof__(struct stm32_dma3_hwdesc), SZ_64K);
>   	if (!chan->lli_pool) {
> -		dev_err(chan2dev(chan), "Failed to create LLI pool\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "Failed to create LLI pool\n");
>   		ret = -ENOMEM;
>   		goto err_put_sync;
>   	}
> @@ -1366,7 +1361,7 @@ static struct dma_async_tx_descriptor *stm32_dma3_prep_slave_sg(struct dma_chan
>   	}
>   
>   	if (count != sg_len && chan->tcem != CTR2_TCEM_CHANNEL)
> -		dev_warn(chan2dev(chan), "Linked-list refactored, %d items instead of %d\n",
> +		dev_warn(vchan_chan_dev(&chan->vchan), "Linked-list refactored, %d items instead of %d\n",
>   			 count, sg_len);
>   
>   	/* Enable Error interrupts */
> @@ -1401,12 +1396,12 @@ static struct dma_async_tx_descriptor *stm32_dma3_prep_dma_cyclic(struct dma_cha
>   		return NULL;
>   
>   	if (!buf_len || !period_len || period_len > STM32_DMA3_MAX_BLOCK_SIZE) {
> -		dev_err(chan2dev(chan), "Invalid buffer/period length\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "Invalid buffer/period length\n");
>   		return NULL;
>   	}
>   
>   	if (buf_len % period_len) {
> -		dev_err(chan2dev(chan), "Buffer length not multiple of period length\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "Buffer length not multiple of period length\n");
>   		return NULL;
>   	}
>   
> @@ -1428,7 +1423,7 @@ static struct dma_async_tx_descriptor *stm32_dma3_prep_dma_cyclic(struct dma_cha
>   		ret = stm32_dma3_chan_prep_hw(chan, DMA_DEV_TO_MEM, &swdesc->ccr, &ctr1, &ctr2,
>   					      src, dst, period_len);
>   	} else {
> -		dev_err(chan2dev(chan), "Invalid direction\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "Invalid direction\n");
>   		ret = -EINVAL;
>   	}
>   
> @@ -1502,7 +1497,7 @@ static int stm32_dma3_pause(struct dma_chan *c)
>   
>   	chan->dma_status = DMA_PAUSED;
>   
> -	dev_dbg(chan2dev(chan), "vchan %p: paused\n", &chan->vchan);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "vchan %p: paused\n", &chan->vchan);
>   
>   	return 0;
>   }
> @@ -1515,7 +1510,7 @@ static int stm32_dma3_resume(struct dma_chan *c)
>   
>   	chan->dma_status = DMA_IN_PROGRESS;
>   
> -	dev_dbg(chan2dev(chan), "vchan %p: resumed\n", &chan->vchan);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "vchan %p: resumed\n", &chan->vchan);
>   
>   	return 0;
>   }
> @@ -1540,7 +1535,7 @@ static int stm32_dma3_terminate_all(struct dma_chan *c)
>   	spin_unlock_irqrestore(&chan->vchan.lock, flags);
>   	vchan_dma_desc_free_list(&chan->vchan, &head);
>   
> -	dev_dbg(chan2dev(chan), "vchan %p: terminated\n", &chan->vchan);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "vchan %p: terminated\n", &chan->vchan);
>   
>   	return 0;
>   }
> @@ -1593,7 +1588,7 @@ static void stm32_dma3_issue_pending(struct dma_chan *c)
>   	spin_lock_irqsave(&chan->vchan.lock, flags);
>   
>   	if (vchan_issue_pending(&chan->vchan) && !chan->swdesc) {
> -		dev_dbg(chan2dev(chan), "vchan %p: issued\n", &chan->vchan);
> +		dev_dbg(vchan_chan_dev(&chan->vchan), "vchan %p: issued\n", &chan->vchan);
>   		stm32_dma3_chan_start(chan);
>   	}
>   
> diff --git a/drivers/dma/stm32/stm32-mdma.c b/drivers/dma/stm32/stm32-mdma.c
> index c274638e919c2..e125921bf9533 100644
> --- a/drivers/dma/stm32/stm32-mdma.c
> +++ b/drivers/dma/stm32/stm32-mdma.c
> @@ -276,11 +276,6 @@ static struct stm32_mdma_desc *to_stm32_mdma_desc(struct virt_dma_desc *vdesc)
>   	return container_of(vdesc, struct stm32_mdma_desc, vdesc);
>   }
>   
> -static struct device *chan2dev(struct stm32_mdma_chan *chan)
> -{
> -	return &chan->vchan.chan.dev->device;
> -}
> -


ditto here:
static struct device *chan2dev(struct stm32_mdma_chan *chan)
{
	return vchan_chan_dev(&chan->vchan);
}

and below, keep chan2dev() instead.

>   static struct device *mdma2dev(struct stm32_mdma_device *mdma_dev)
>   {
>   	return mdma_dev->ddev.dev;
> @@ -334,7 +329,7 @@ static struct stm32_mdma_desc *stm32_mdma_alloc_desc(
>   	return desc;
>   
>   err:
> -	dev_err(chan2dev(chan), "Failed to allocate descriptor\n");
> +	dev_err(vchan_chan_dev(&chan->vchan), "Failed to allocate descriptor\n");
>   	while (--i >= 0)
>   		dma_pool_free(chan->desc_pool, desc->node[i].hwdesc,
>   			      desc->node[i].hwdesc_phys);
> @@ -364,7 +359,7 @@ static int stm32_mdma_get_width(struct stm32_mdma_chan *chan,
>   	case DMA_SLAVE_BUSWIDTH_8_BYTES:
>   		return ffs(width) - 1;
>   	default:
> -		dev_err(chan2dev(chan), "Dma bus width %i not supported\n",
> +		dev_err(vchan_chan_dev(&chan->vchan), "Dma bus width %i not supported\n",
>   			width);
>   		return -EINVAL;
>   	}
> @@ -422,7 +417,7 @@ static int stm32_mdma_disable_chan(struct stm32_mdma_chan *chan)
>   				dmadev->base + STM32_MDMA_CISR(id), cisr,
>   				(cisr & STM32_MDMA_CISR_CTCIF), 10, 1000);
>   		if (ret) {
> -			dev_err(chan2dev(chan), "%s: timeout!\n", __func__);
> +			dev_err(vchan_chan_dev(&chan->vchan), "%s: timeout!\n", __func__);
>   			return -EBUSY;
>   		}
>   	}
> @@ -444,7 +439,7 @@ static void stm32_mdma_stop(struct stm32_mdma_chan *chan)
>   	/* Clear interrupt status if it is there */
>   	status = stm32_mdma_read(dmadev, STM32_MDMA_CISR(chan->id));
>   	if (status) {
> -		dev_dbg(chan2dev(chan), "%s(): clearing interrupt: 0x%08x\n",
> +		dev_dbg(vchan_chan_dev(&chan->vchan), "%s(): clearing interrupt: 0x%08x\n",
>   			__func__, status);
>   		stm32_mdma_set_bits(dmadev, STM32_MDMA_CIFCR(chan->id), status);
>   	}
> @@ -513,7 +508,7 @@ static int stm32_mdma_set_xfer_param(struct stm32_mdma_chan *chan,
>   	/* Check burst size constraints */
>   	if (src_maxburst * src_addr_width > STM32_MDMA_MAX_BURST ||
>   	    dst_maxburst * dst_addr_width > STM32_MDMA_MAX_BURST) {
> -		dev_err(chan2dev(chan),
> +		dev_err(vchan_chan_dev(&chan->vchan),
>   			"burst size * bus width higher than %d bytes\n",
>   			STM32_MDMA_MAX_BURST);
>   		return -EINVAL;
> @@ -521,7 +516,7 @@ static int stm32_mdma_set_xfer_param(struct stm32_mdma_chan *chan,
>   
>   	if ((!is_power_of_2(src_maxburst) && src_maxburst > 0) ||
>   	    (!is_power_of_2(dst_maxburst) && dst_maxburst > 0)) {
> -		dev_err(chan2dev(chan), "burst size must be a power of 2\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "burst size must be a power of 2\n");
>   		return -EINVAL;
>   	}
>   
> @@ -658,7 +653,7 @@ static int stm32_mdma_set_xfer_param(struct stm32_mdma_chan *chan,
>   		break;
>   
>   	default:
> -		dev_err(chan2dev(chan), "Dma direction is not supported\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "Dma direction is not supported\n");
>   		return -EINVAL;
>   	}
>   
> @@ -672,16 +667,16 @@ static int stm32_mdma_set_xfer_param(struct stm32_mdma_chan *chan,
>   static void stm32_mdma_dump_hwdesc(struct stm32_mdma_chan *chan,
>   				   struct stm32_mdma_desc_node *node)
>   {
> -	dev_dbg(chan2dev(chan), "hwdesc:  %pad\n", &node->hwdesc_phys);
> -	dev_dbg(chan2dev(chan), "CTCR:    0x%08x\n", node->hwdesc->ctcr);
> -	dev_dbg(chan2dev(chan), "CBNDTR:  0x%08x\n", node->hwdesc->cbndtr);
> -	dev_dbg(chan2dev(chan), "CSAR:    0x%08x\n", node->hwdesc->csar);
> -	dev_dbg(chan2dev(chan), "CDAR:    0x%08x\n", node->hwdesc->cdar);
> -	dev_dbg(chan2dev(chan), "CBRUR:   0x%08x\n", node->hwdesc->cbrur);
> -	dev_dbg(chan2dev(chan), "CLAR:    0x%08x\n", node->hwdesc->clar);
> -	dev_dbg(chan2dev(chan), "CTBR:    0x%08x\n", node->hwdesc->ctbr);
> -	dev_dbg(chan2dev(chan), "CMAR:    0x%08x\n", node->hwdesc->cmar);
> -	dev_dbg(chan2dev(chan), "CMDR:    0x%08x\n\n", node->hwdesc->cmdr);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "hwdesc:  %pad\n", &node->hwdesc_phys);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "CTCR:    0x%08x\n", node->hwdesc->ctcr);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "CBNDTR:  0x%08x\n", node->hwdesc->cbndtr);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "CSAR:    0x%08x\n", node->hwdesc->csar);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "CDAR:    0x%08x\n", node->hwdesc->cdar);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "CBRUR:   0x%08x\n", node->hwdesc->cbrur);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "CLAR:    0x%08x\n", node->hwdesc->clar);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "CTBR:    0x%08x\n", node->hwdesc->ctbr);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "CMAR:    0x%08x\n", node->hwdesc->cmar);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "CMDR:    0x%08x\n\n", node->hwdesc->cmdr);
>   }
>   
>   static void stm32_mdma_setup_hwdesc(struct stm32_mdma_chan *chan,
> @@ -739,7 +734,7 @@ static int stm32_mdma_setup_xfer(struct stm32_mdma_chan *chan,
>   
>   	for_each_sg(sgl, sg, sg_len, i) {
>   		if (sg_dma_len(sg) > STM32_MDMA_MAX_BLOCK_LEN) {
> -			dev_err(chan2dev(chan), "Invalid block len\n");
> +			dev_err(vchan_chan_dev(&chan->vchan), "Invalid block len\n");
>   			return -EINVAL;
>   		}
>   
> @@ -797,7 +792,7 @@ stm32_mdma_prep_slave_sg(struct dma_chan *c, struct scatterlist *sgl,
>   	 * for allowing another request.
>   	 */
>   	if (chan->desc && chan->desc->cyclic) {
> -		dev_err(chan2dev(chan),
> +		dev_err(vchan_chan_dev(&chan->vchan),
>   			"Request not allowed when dma in cyclic mode\n");
>   		return NULL;
>   	}
> @@ -858,18 +853,18 @@ stm32_mdma_prep_dma_cyclic(struct dma_chan *c, dma_addr_t buf_addr,
>   	 * for allowing another request.
>   	 */
>   	if (chan->desc && chan->desc->cyclic) {
> -		dev_err(chan2dev(chan),
> +		dev_err(vchan_chan_dev(&chan->vchan),
>   			"Request not allowed when dma in cyclic mode\n");
>   		return NULL;
>   	}
>   
>   	if (!buf_len || !period_len || period_len > STM32_MDMA_MAX_BLOCK_LEN) {
> -		dev_err(chan2dev(chan), "Invalid buffer/period len\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "Invalid buffer/period len\n");
>   		return NULL;
>   	}
>   
>   	if (buf_len % period_len) {
> -		dev_err(chan2dev(chan), "buf_len not multiple of period_len\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "buf_len not multiple of period_len\n");
>   		return NULL;
>   	}
>   
> @@ -954,7 +949,7 @@ stm32_mdma_prep_dma_memcpy(struct dma_chan *c, dma_addr_t dest, dma_addr_t src,
>   	 * to allow another request
>   	 */
>   	if (chan->desc && chan->desc->cyclic) {
> -		dev_err(chan2dev(chan),
> +		dev_err(vchan_chan_dev(&chan->vchan),
>   			"Request not allowed when dma in cyclic mode\n");
>   		return NULL;
>   	}
> @@ -1116,25 +1111,25 @@ static void stm32_mdma_dump_reg(struct stm32_mdma_chan *chan)
>   {
>   	struct stm32_mdma_device *dmadev = stm32_mdma_get_dev(chan);
>   
> -	dev_dbg(chan2dev(chan), "CCR:     0x%08x\n",
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "CCR:     0x%08x\n",
>   		stm32_mdma_read(dmadev, STM32_MDMA_CCR(chan->id)));
> -	dev_dbg(chan2dev(chan), "CTCR:    0x%08x\n",
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "CTCR:    0x%08x\n",
>   		stm32_mdma_read(dmadev, STM32_MDMA_CTCR(chan->id)));
> -	dev_dbg(chan2dev(chan), "CBNDTR:  0x%08x\n",
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "CBNDTR:  0x%08x\n",
>   		stm32_mdma_read(dmadev, STM32_MDMA_CBNDTR(chan->id)));
> -	dev_dbg(chan2dev(chan), "CSAR:    0x%08x\n",
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "CSAR:    0x%08x\n",
>   		stm32_mdma_read(dmadev, STM32_MDMA_CSAR(chan->id)));
> -	dev_dbg(chan2dev(chan), "CDAR:    0x%08x\n",
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "CDAR:    0x%08x\n",
>   		stm32_mdma_read(dmadev, STM32_MDMA_CDAR(chan->id)));
> -	dev_dbg(chan2dev(chan), "CBRUR:   0x%08x\n",
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "CBRUR:   0x%08x\n",
>   		stm32_mdma_read(dmadev, STM32_MDMA_CBRUR(chan->id)));
> -	dev_dbg(chan2dev(chan), "CLAR:    0x%08x\n",
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "CLAR:    0x%08x\n",
>   		stm32_mdma_read(dmadev, STM32_MDMA_CLAR(chan->id)));
> -	dev_dbg(chan2dev(chan), "CTBR:    0x%08x\n",
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "CTBR:    0x%08x\n",
>   		stm32_mdma_read(dmadev, STM32_MDMA_CTBR(chan->id)));
> -	dev_dbg(chan2dev(chan), "CMAR:    0x%08x\n",
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "CMAR:    0x%08x\n",
>   		stm32_mdma_read(dmadev, STM32_MDMA_CMAR(chan->id)));
> -	dev_dbg(chan2dev(chan), "CMDR:    0x%08x\n",
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "CMDR:    0x%08x\n",
>   		stm32_mdma_read(dmadev, STM32_MDMA_CMDR(chan->id)));
>   }
>   
> @@ -1187,7 +1182,7 @@ static void stm32_mdma_start_transfer(struct stm32_mdma_chan *chan)
>   
>   	chan->busy = true;
>   
> -	dev_dbg(chan2dev(chan), "vchan %p: started\n", &chan->vchan);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "vchan %p: started\n", &chan->vchan);
>   }
>   
>   static void stm32_mdma_issue_pending(struct dma_chan *c)
> @@ -1200,7 +1195,7 @@ static void stm32_mdma_issue_pending(struct dma_chan *c)
>   	if (!vchan_issue_pending(&chan->vchan))
>   		goto end;
>   
> -	dev_dbg(chan2dev(chan), "vchan %p: issued\n", &chan->vchan);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "vchan %p: issued\n", &chan->vchan);
>   
>   	if (!chan->desc && !chan->busy)
>   		stm32_mdma_start_transfer(chan);
> @@ -1220,7 +1215,7 @@ static int stm32_mdma_pause(struct dma_chan *c)
>   	spin_unlock_irqrestore(&chan->vchan.lock, flags);
>   
>   	if (!ret)
> -		dev_dbg(chan2dev(chan), "vchan %p: pause\n", &chan->vchan);
> +		dev_dbg(vchan_chan_dev(&chan->vchan), "vchan %p: pause\n", &chan->vchan);
>   
>   	return ret;
>   }
> @@ -1261,7 +1256,7 @@ static int stm32_mdma_resume(struct dma_chan *c)
>   
>   	spin_unlock_irqrestore(&chan->vchan.lock, flags);
>   
> -	dev_dbg(chan2dev(chan), "vchan %p: resume\n", &chan->vchan);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "vchan %p: resume\n", &chan->vchan);
>   
>   	return 0;
>   }
> @@ -1422,10 +1417,10 @@ static irqreturn_t stm32_mdma_irq_handler(int irq, void *devid)
>   	if (!(status & ien)) {
>   		spin_unlock(&chan->vchan.lock);
>   		if (chan->busy)
> -			dev_warn(chan2dev(chan),
> +			dev_warn(vchan_chan_dev(&chan->vchan),
>   				 "spurious it (status=0x%04x, ien=0x%04x)\n", status, ien);
>   		else
> -			dev_dbg(chan2dev(chan),
> +			dev_dbg(vchan_chan_dev(&chan->vchan),
>   				"spurious it (status=0x%04x, ien=0x%04x)\n", status, ien);
>   		return IRQ_NONE;
>   	}
> @@ -1433,7 +1428,7 @@ static irqreturn_t stm32_mdma_irq_handler(int irq, void *devid)
>   	reg = STM32_MDMA_CIFCR(id);
>   
>   	if (status & STM32_MDMA_CISR_TEIF) {
> -		dev_err(chan2dev(chan), "Transfer Err: stat=0x%08x\n",
> +		dev_err(vchan_chan_dev(&chan->vchan), "Transfer Err: stat=0x%08x\n",
>   			readl_relaxed(dmadev->base + STM32_MDMA_CESR(id)));
>   		stm32_mdma_set_bits(dmadev, reg, STM32_MDMA_CIFCR_CTEIF);
>   		status &= ~STM32_MDMA_CISR_TEIF;
> @@ -1468,9 +1463,9 @@ static irqreturn_t stm32_mdma_irq_handler(int irq, void *devid)
>   
>   	if (status) {
>   		stm32_mdma_set_bits(dmadev, reg, status);
> -		dev_err(chan2dev(chan), "DMA error: status=0x%08x\n", status);
> +		dev_err(vchan_chan_dev(&chan->vchan), "DMA error: status=0x%08x\n", status);
>   		if (!(ccr & STM32_MDMA_CCR_EN))
> -			dev_err(chan2dev(chan), "chan disabled by HW\n");
> +			dev_err(vchan_chan_dev(&chan->vchan), "chan disabled by HW\n");
>   	}
>   
>   	spin_unlock(&chan->vchan.lock);
> @@ -1490,7 +1485,7 @@ static int stm32_mdma_alloc_chan_resources(struct dma_chan *c)
>   					  __alignof__(struct stm32_mdma_hwdesc),
>   					   0);
>   	if (!chan->desc_pool) {
> -		dev_err(chan2dev(chan), "failed to allocate descriptor pool\n");
> +		dev_err(vchan_chan_dev(&chan->vchan), "failed to allocate descriptor pool\n");
>   		return -ENOMEM;
>   	}
>   
> @@ -1511,7 +1506,7 @@ static void stm32_mdma_free_chan_resources(struct dma_chan *c)
>   	struct stm32_mdma_device *dmadev = stm32_mdma_get_dev(chan);
>   	unsigned long flags;
>   
> -	dev_dbg(chan2dev(chan), "Freeing channel %d\n", chan->id);
> +	dev_dbg(vchan_chan_dev(&chan->vchan), "Freeing channel %d\n", chan->id);
>   
>   	if (chan->busy) {
>   		spin_lock_irqsave(&chan->vchan.lock, flags);

Regards,
Amelie


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 1/4] dmaengine: vchan: add vchan_chan_name() to get channel device name
  2026-09-04 21:49 ` [PATCH v3 1/4] dmaengine: vchan: add vchan_chan_name() to get channel device name Frank.Li
@ 2026-09-07  9:00   ` Amelie Delaunay
  0 siblings, 0 replies; 11+ messages in thread
From: Amelie Delaunay @ 2026-09-07  9:00 UTC (permalink / raw)
  To: Frank.Li, Jacky Huang, Shan-Chun Hung, Vinod Koul, Frank Li,
	Paul Cercueil, Eugeniy Paltsev, Andy Shevchenko, Binbin Zhou,
	Patrice Chotard, Maxime Coquelin, Alexandre Torgue,
	Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Thierry Reding, Jonathan Hunter, Ludovic Desroches, Viresh Kumar,
	Keguang Zhang, Andreas Färber, Manivannan Sadhasivam,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Kelvin Cao, Logan Gunthorpe,
	Laxman Dewangan, Vignesh Raghavendra
  Cc: linux-arm-kernel, dmaengine, linux-kernel, linux-mips,
	linux-stm32, linux-trace-kernel, linux-tegra, linux-actions,
	linux-sunxi, imx, Frank Li



On 9/4/26 23:49, Frank.Li@oss.nxp.com wrote:
> From: Frank Li<Frank.Li@nxp.com>
> 
> Introduce vchan_chan_name() to obtain the DMA channel device name.
> 
> Use a dedicated helper instead of directly accessing dma_chan::dev
> so callers remain unaffected by an upcoming rename of the struct member.
> 
> Signed-off-by: Frank Li<Frank.Li@nxp.com>

Reviewed-by: Amelie Delaunay <amelie.delaunay@foss.st.com> # For STM32

> ---
>   drivers/dma/arm-dma350.c                     |  2 +-
>   drivers/dma/loongson/loongson2-apb-cmc-dma.c |  2 +-
>   drivers/dma/stm32/stm32-dma.c                |  2 +-
>   drivers/dma/stm32/stm32-dma3.c               |  4 ++--
>   drivers/dma/virt-dma.h                       | 11 +++++++++++
>   5 files changed, 16 insertions(+), 5 deletions(-)



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 2/4] dmaengine: use dma_chan_name() helper to get per-channel device name
  2026-09-04 21:49 ` [PATCH v3 2/4] dmaengine: use dma_chan_name() helper to get per-channel " Frank.Li
  2026-09-05  7:55   ` Andy Shevchenko
@ 2026-09-07  9:01   ` Amelie Delaunay
  1 sibling, 0 replies; 11+ messages in thread
From: Amelie Delaunay @ 2026-09-07  9:01 UTC (permalink / raw)
  To: Frank.Li, Jacky Huang, Shan-Chun Hung, Vinod Koul, Frank Li,
	Paul Cercueil, Eugeniy Paltsev, Andy Shevchenko, Binbin Zhou,
	Patrice Chotard, Maxime Coquelin, Alexandre Torgue,
	Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Thierry Reding, Jonathan Hunter, Ludovic Desroches, Viresh Kumar,
	Keguang Zhang, Andreas Färber, Manivannan Sadhasivam,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Kelvin Cao, Logan Gunthorpe,
	Laxman Dewangan, Vignesh Raghavendra
  Cc: linux-arm-kernel, dmaengine, linux-kernel, linux-mips,
	linux-stm32, linux-trace-kernel, linux-tegra, linux-actions,
	linux-sunxi, imx, Frank Li



On 9/4/26 23:49, Frank.Li@oss.nxp.com wrote:
> From: Frank Li<Frank.Li@nxp.com>
> 
> Use the existing dma_chan_name() helper to obtain the per-channel device
> name instead of open-coding: dev_name(chan->dev->device) /
> dev_name(chan2dev())
> 
> Simplify the code and improve consistency.
> 
> No functional change intended.
> 
> Reviewed-by: Logan Gunthorpe<logang@deltatee.com>
> Signed-off-by: Frank Li<Frank.Li@nxp.com>

Reviewed-by: Amelie Delaunay <amelie.delaunay@foss.st.com> # For STM32

> ---
>   drivers/dma/dma-jz4780.c                       | 2 +-
>   drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 2 +-
>   drivers/dma/idma64.c                           | 2 +-
>   drivers/dma/loongson/loongson2-apb-dma.c       | 2 +-
>   drivers/dma/mmp_pdma.c                         | 2 +-
>   drivers/dma/st_fdma.c                          | 2 +-
>   drivers/dma/stm32/stm32-dma3.c                 | 2 +-
>   drivers/dma/stm32/stm32-mdma.c                 | 2 +-
>   include/trace/events/tegra_apb_dma.h           | 6 +++---
>   9 files changed, 11 insertions(+), 11 deletions(-)



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 3/4] dmaengine: add (dmaengine|vchan)_chan_dev() helper
  2026-09-07  8:55   ` [PATCH v3 3/4] dmaengine: add (dmaengine|vchan)_chan_dev() helper Amelie Delaunay
@ 2026-09-09 12:39     ` Vinod Koul
  0 siblings, 0 replies; 11+ messages in thread
From: Vinod Koul @ 2026-09-09 12:39 UTC (permalink / raw)
  To: Amelie Delaunay
  Cc: Frank.Li, Jacky Huang, Shan-Chun Hung, Frank Li, Paul Cercueil,
	Eugeniy Paltsev, Andy Shevchenko, Binbin Zhou, Patrice Chotard,
	Maxime Coquelin, Alexandre Torgue, Steven Rostedt,
	Masami Hiramatsu, Mathieu Desnoyers, Thierry Reding,
	Jonathan Hunter, Ludovic Desroches, Viresh Kumar, Keguang Zhang,
	Andreas Färber, Manivannan Sadhasivam, Daniel Mack,
	Haojian Zhuang, Robert Jarzmik, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, Kelvin Cao, Logan Gunthorpe, Laxman Dewangan,
	Vignesh Raghavendra, linux-arm-kernel, dmaengine, linux-kernel,
	linux-mips, linux-stm32, linux-trace-kernel, linux-tegra,
	linux-actions, linux-sunxi, imx, Frank Li

On 07-09-26, 10:55, Amelie Delaunay wrote:
> Hi Frank,
> 
> On 9/4/26 23:49, Frank.Li@oss.nxp.com wrote:
> [...]
> 
> I don't think removing chan2dev() function from the STM32 DMA drivers is an
> improvement, since the parameter is a `stm32` chan, not a `dma_chan`.
> chan2dev() was meant to expose the channel device behind the `stm32` wrapper
> and keep logging concise.
> 
> > diff --git a/drivers/dma/stm32/stm32-dma.c b/drivers/dma/stm32/stm32-dma.c
> > index 3e8151e2ad75a..4688cebaf7f7a 100644
> > --- a/drivers/dma/stm32/stm32-dma.c
> > +++ b/drivers/dma/stm32/stm32-dma.c
> > @@ -248,11 +248,6 @@ static struct stm32_dma_desc *to_stm32_dma_desc(struct virt_dma_desc *vdesc)
> >   	return container_of(vdesc, struct stm32_dma_desc, vdesc);
> >   }
> > -static struct device *chan2dev(struct stm32_dma_chan *chan)
> > -{
> > -	return &chan->vchan.chan.dev->device;
> > -}
> > -
> 
> I would rather keep it as:
> 
> static struct device *chan2dev(struct stm32_dma_chan *chan)
> {
> 	return vchan_chan_dev(&chan->vchan);
> }
> 
> and then drop all further updates.

I would say better to use a common macro than keep one for yours

-- 
~Vinod


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-09-09 12:40 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04 21:49 [PATCH v3 0/4] dmaengine: rename dma_chan::dev to dma_chan::chan_dev for clarity Frank.Li
2026-09-04 21:49 ` [PATCH v3 1/4] dmaengine: vchan: add vchan_chan_name() to get channel device name Frank.Li
2026-09-07  9:00   ` Amelie Delaunay
2026-09-04 21:49 ` [PATCH v3 2/4] dmaengine: use dma_chan_name() helper to get per-channel " Frank.Li
2026-09-05  7:55   ` Andy Shevchenko
2026-09-07  9:01   ` Amelie Delaunay
2026-09-04 21:49 ` [PATCH v3 4/4] dmaengine: add union chan_dev for dma_chan::dev for clarity Frank.Li
2026-09-05  7:59   ` Andy Shevchenko
2026-09-05  8:00 ` [PATCH v3 0/4] dmaengine: rename dma_chan::dev to dma_chan::chan_dev " Andy Shevchenko
     [not found] ` <20260904-dma-chan_dev-rename-v3-3-685601b0b788@nxp.com>
2026-09-07  8:55   ` [PATCH v3 3/4] dmaengine: add (dmaengine|vchan)_chan_dev() helper Amelie Delaunay
2026-09-09 12:39     ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox