Re: [PATCH v3 4/4] dmaengine: add union chan_dev for dma_chan::dev for clarity

From
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date
2026-09-05 07:59:49
Also in
dmaengine, imx, linux-mips, linux-sunxi, linux-tegra, linux-trace-kernel, lkml
Reply to
unknown sender, 2026-09-04
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...

...
quoted hunk ↗ jump to hunk
+++ b/include/linux/dmaengine.h
struct dma_router {
quoted hunk ↗ jump to hunk
  * @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 {
quoted hunk ↗ jump to hunk
 
 	/* 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.
quoted hunk ↗ jump to hunk
+		struct dma_chan_dev *dev;
+	};
 	const char *name;
 #ifdef CONFIG_DEBUG_FS
 	char *dbg_client_name;
-- 
With Best Regards,
Andy Shevchenko


Thread (9 messages) 9 messages, 3 authors, last reply 2026-09-07
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help