mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] i2c: use dmaengine_get_dma_device() instead of chan->device->dev
@ 2026-11-03 21:26 Frank.Li
  0 siblings, 0 replies; only message in thread
From: Frank.Li @ 2026-11-03 21:26 UTC (permalink / raw)
  To: Wolfram Sang, Andi Shyti, Geert Uytterhoeven, Magnus Damm,
	Sumit Semwal, Christian König, Philipp Stanner,
	open list:RENESAS R-CAR I2C DRIVERS,
	open list:I2C SUBSYSTEM HOST DRIVERS, open list,
	open list:DMA BUFFER SHARING
	FRAMEWORK:Keyword:bdma_(?:buf|fence|resv)b,
	open list:DMA BUFFER SHARING
	FRAMEWORK:Keyword:bdma_(?:buf|fence|resv)b,
	moderated list:DMA BUFFER SHARING
	FRAMEWORK:Keyword:bdma_(?:buf|fence|resv)b
  Cc: imx, vkoul, Frank Li

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

Replace direct dma_chan::device::dev access with the proper
dmaengine_get_dma_device() for consumer API.

chan->device->dev is not always the device used for DMA mapping.  Some DMA
engines support per-channel IOMMU mappings, so different channels may use
different DMA devices.  dmaengine_get_dma_device() returns the correct
device for each channel.

This also prepares for making the DMA engine provider data structures
private.  DMA consumers should not access DMA engine internals directly.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/i2c/busses/i2c-rcar.c      | 6 +++---
 drivers/i2c/busses/i2c-sh_mobile.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 755064804cb21..86b1df3a56c4d 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -455,7 +455,7 @@ static void rcar_i2c_cleanup_dma(struct rcar_i2c_priv *priv, bool terminate)
 	if (terminate)
 		dmaengine_terminate_sync(chan);
 
-	dma_unmap_single(chan->device->dev, sg_dma_address(&priv->sg),
+	dma_unmap_single(dmaengine_get_dma_device(chan), sg_dma_address(&priv->sg),
 			 sg_dma_len(&priv->sg), priv->dma_direction);
 
 	/* Gen3+ can only do one RXDMA per transfer and we just completed it */
@@ -511,8 +511,8 @@ static bool rcar_i2c_dma(struct rcar_i2c_priv *priv)
 		len = priv->msg->len - 1;
 	}
 
-	dma_addr = dma_map_single(chan->device->dev, buf, len, dir);
-	if (dma_mapping_error(chan->device->dev, dma_addr)) {
+	dma_addr = dma_map_single(dmaengine_get_dma_device(chan), buf, len, dir);
+	if (dma_mapping_error(dmaengine_get_dma_device(chan), dma_addr)) {
 		dev_dbg(dev, "dma map failed, using PIO\n");
 		return false;
 	}
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index 3a55f803e4f15..023813c2f7809 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -452,7 +452,7 @@ static void sh_mobile_i2c_cleanup_dma(struct sh_mobile_i2c_data *pd, bool termin
 	if (terminate)
 		dmaengine_terminate_sync(chan);
 
-	dma_unmap_single(chan->device->dev, sg_dma_address(&pd->sg),
+	dma_unmap_single(dmaengine_get_dma_device(chan), sg_dma_address(&pd->sg),
 			 pd->msg->len, pd->dma_direction);
 
 	pd->dma_direction = DMA_NONE;
@@ -526,8 +526,8 @@ static void sh_mobile_i2c_xfer_dma(struct sh_mobile_i2c_data *pd)
 	if (IS_ERR(chan))
 		return;
 
-	dma_addr = dma_map_single(chan->device->dev, pd->dma_buf, pd->msg->len, dir);
-	if (dma_mapping_error(chan->device->dev, dma_addr)) {
+	dma_addr = dma_map_single(dmaengine_get_dma_device(chan), pd->dma_buf, pd->msg->len, dir);
+	if (dma_mapping_error(dmaengine_get_dma_device(chan), dma_addr)) {
 		dev_dbg(pd->dev, "dma map failed, using PIO\n");
 		return;
 	}
-- 
2.43.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-03 21:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 21:26 [PATCH 1/1] i2c: use dmaengine_get_dma_device() instead of chan->device->dev 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®