Skip to contentSkip to conversation

tty: serial: amba-pl011: use dmaengine accessor API functions

PATCH New [email protected] 2 participants 2 messages Nov 11

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tty: serial: amba-pl011: use dmaengine accessor API functions

From: Frank Li <[email protected]>

Use dmaengine_get_dma_device() and dmaengine_get_copy_align() accessors instead of directly accessing chan->device struct members. This follows the dmaengine API convention of using accessor helpers to decouple drivers from internal dmaengine structures.

---
 drivers/tty/serial/amba-pl011.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/tty/serial/amba-pl011.c +8 -6
index 1e04e6398c973..7acccb096ab57 100644
@@ -655,9 +655,10 @@ static int pl011_dma_tx_refill(struct uart_amba_port *uap)
 {
 	struct pl011_dmatx_data *dmatx = &uap->dmatx;
 	struct dma_chan *chan = dmatx->chan;
-	struct dma_device *dma_dev = chan->device;
+	struct device *dma_dev = dmaengine_get_dma_device(chan);
 	struct dma_async_tx_descriptor *desc;
 	struct tty_port *tport = &uap->port.state->port;
+	enum dmaengine_alignment copy_align;
 	unsigned int count;
 
 	/*
@@ -689,13 +690,14 @@ static int pl011_dma_tx_refill(struct uart_amba_port *uap)
 	 * requirements. Some DMA controllers (e.g., Tegra GPC DMA) require
 	 * word-aligned transfers. Unaligned bytes will be sent via PIO.
 	 */
-	if (chan->device->copy_align)
-		count = ALIGN_DOWN(count, 1 << chan->device->copy_align);
+	copy_align = dmaengine_get_copy_align(chan);
+	if (copy_align)
+		count = ALIGN_DOWN(count, 1 << copy_align);
 
 	dmatx->len = count;
-	dmatx->dma = dma_map_single(dma_dev->dev, dmatx->buf, count,
+	dmatx->dma = dma_map_single(dma_dev, dmatx->buf, count,
 				    DMA_TO_DEVICE);
-	if (dma_mapping_error(dma_dev->dev, dmatx->dma)) {
+	if (dma_mapping_error(dma_dev, dmatx->dma)) {
 		uap->dmatx.queued = false;
 		dev_dbg(uap->port.dev, "unable to map TX DMA\n");
 		return -EBUSY;
@@ -704,7 +706,7 @@ static int pl011_dma_tx_refill(struct uart_amba_port *uap)
 	desc = dmaengine_prep_slave_single(chan, dmatx->dma, dmatx->len, DMA_MEM_TO_DEV,
 					   DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
 	if (!desc) {
-		dma_unmap_single(dma_dev->dev, dmatx->dma, dmatx->len, DMA_TO_DEVICE);
+		dma_unmap_single(dma_dev, dmatx->dma, dmatx->len, DMA_TO_DEVICE);
 		uap->dmatx.queued = false;
 		/*
 		 * If DMA cannot be used right now, we complete this
Signature · 1 line
2.43.0
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines

From: Frank Li <[email protected]>

Use dmaengine_get_dma_device() and dmaengine_get_copy_align() accessors instead of directly accessing chan->device struct members. This follows the dmaengine API convention of using accessor helpers to decouple drivers from internal dmaengine structures.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1