lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20260114-dma_common_config-v1-6-64feb836ff04@nxp.com>
Date: Wed, 14 Jan 2026 12:12:47 -0500
From: Frank Li <Frank.Li@....com>
To: Vinod Koul <vkoul@...nel.org>, Shawn Guo <shawnguo@...nel.org>, 
 Sascha Hauer <s.hauer@...gutronix.de>, 
 Pengutronix Kernel Team <kernel@...gutronix.de>, 
 Fabio Estevam <festevam@...il.com>
Cc: dmaengine@...r.kernel.org, linux-kernel@...r.kernel.org, 
 imx@...ts.linux.dev, linux-arm-kernel@...ts.infradead.org, 
 Frank Li <Frank.Li@....com>
Subject: [PATCH 6/6] dmaengine: fsl-edma: use common dma_slave_get_cfg()

Use common dma_slave_get_cfg() to simple code. No functional change.

Signed-off-by: Frank Li <Frank.Li@....com>
---
 drivers/dma/fsl-edma-common.c | 61 ++++++++++++++++++-------------------------
 1 file changed, 26 insertions(+), 35 deletions(-)

diff --git a/drivers/dma/fsl-edma-common.c b/drivers/dma/fsl-edma-common.c
index 33fc4fa8d1302d899ce550b0ce5d4325fa2e3916..c4ac63d9612ce9f1f5826a2186938a785ed529d1 100644
--- a/drivers/dma/fsl-edma-common.c
+++ b/drivers/dma/fsl-edma-common.c
@@ -291,30 +291,32 @@ static void fsl_edma_unprep_slave_dma(struct fsl_edma_chan *fsl_chan)
 	fsl_chan->dma_dir = DMA_NONE;
 }
 
+static enum dma_data_direction
+fsl_dma_dir_trans_to_data(enum dma_transfer_direction dir)
+{
+	if (dir == DMA_MEM_TO_DEV)
+		return DMA_FROM_DEVICE;
+
+	if (dir ==  DMA_DEV_TO_MEM)
+		return DMA_TO_DEVICE;
+
+	return DMA_NONE;
+}
+
 static bool fsl_edma_prep_slave_dma(struct fsl_edma_chan *fsl_chan,
 				    enum dma_transfer_direction dir)
 {
 	struct dma_slave_config *cfg = &fsl_chan->vchan.chan.config;
+	struct dma_slave_cfg *c = dma_slave_get_cfg(cfg, dir);
 	struct device *dev = fsl_chan->vchan.chan.device->dev;
 	enum dma_data_direction dma_dir;
 	phys_addr_t addr = 0;
 	u32 size = 0;
 
-	switch (dir) {
-	case DMA_MEM_TO_DEV:
-		dma_dir = DMA_FROM_DEVICE;
-		addr = cfg->dst_addr;
-		size = cfg->dst_maxburst;
-		break;
-	case DMA_DEV_TO_MEM:
-		dma_dir = DMA_TO_DEVICE;
-		addr = cfg->src_addr;
-		size = cfg->src_maxburst;
-		break;
-	default:
-		dma_dir = DMA_NONE;
-		break;
-	}
+	dma_dir = fsl_dma_dir_trans_to_data(dir);
+
+	addr = c->addr;
+	size = c->maxburst;
 
 	/* Already mapped for this config? */
 	if (fsl_chan->dma_dir == dma_dir)
@@ -484,6 +486,7 @@ void fsl_edma_fill_tcd(struct fsl_edma_chan *fsl_chan,
 		       bool disable_req, bool enable_sg)
 {
 	struct dma_slave_config *cfg = &fsl_chan->vchan.chan.config;
+	struct dma_slave_cfg *c = dma_slave_get_cfg(cfg, cfg->direction);
 	u32 burst = 0;
 	u16 csr = 0;
 
@@ -507,26 +510,14 @@ void fsl_edma_fill_tcd(struct fsl_edma_chan *fsl_chan,
 	 * If we don't have either of those, will use a major loop reading from addr
 	 * nbytes (29bits).
 	 */
-	if (cfg->direction == DMA_MEM_TO_DEV) {
-		if (fsl_chan->is_multi_fifo)
-			burst = cfg->dst_maxburst * 4;
-		if (cfg->dst_port_window_size)
-			burst = cfg->dst_port_window_size * cfg->dst_addr_width;
-		if (burst) {
-			nbytes |= EDMA_V3_TCD_NBYTES_MLOFF(-burst);
-			nbytes |= EDMA_V3_TCD_NBYTES_DMLOE;
-			nbytes &= ~EDMA_V3_TCD_NBYTES_SMLOE;
-		}
-	} else {
-		if (fsl_chan->is_multi_fifo)
-			burst = cfg->src_maxburst * 4;
-		if (cfg->src_port_window_size)
-			burst = cfg->src_port_window_size * cfg->src_addr_width;
-		if (burst) {
-			nbytes |= EDMA_V3_TCD_NBYTES_MLOFF(-burst);
-			nbytes |= EDMA_V3_TCD_NBYTES_SMLOE;
-			nbytes &= ~EDMA_V3_TCD_NBYTES_DMLOE;
-		}
+	if (fsl_chan->is_multi_fifo)
+		burst = c->maxburst * 4;
+	if (c->port_window_size)
+		burst = c->port_window_size * c->addr_width;
+	if (burst) {
+		nbytes |= EDMA_V3_TCD_NBYTES_MLOFF(-burst);
+		nbytes |= EDMA_V3_TCD_NBYTES_DMLOE;
+		nbytes &= ~EDMA_V3_TCD_NBYTES_SMLOE;
 	}
 
 	fsl_edma_set_tcd_to_le(fsl_chan, tcd, nbytes, nbytes);

-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ