[PATCH 1/2] dmaengine: add dmaengine_prep_slave_sg_context() to wrap prep_slave_sg
From: Frank . Li
Date: Thu Sep 17 2026 - 20:15:54 EST
From: Frank Li <Frank.Li@xxxxxxx>
Most DMA engine providers and consumers do not use the context argument
of prep_slave_sg(). A few do, however:
Consumers:
sound/soc/sprd/sprd-pcm-compress.c
Providers:
drivers/dma/sprd-dma.c - sprd_dma_prep_slave_sg() casts context to
struct sprd_dma_linklist * to set up a linked list descriptor chain.
drivers/dma/ti/k3-udma.c - udma_prep_slave_sg() passes context down
to internal sub-functions for normal, PKTDMA, and BCDMA variants.
drivers/dma/xilinx/xilinx_dma.c - xilinx_dma_prep_slave_sg() and
xilinx_mcdma_prep_slave_sg() both cast context to u32 *app_w to
write APP words into DMA descriptors.
Add dmaengine_prep_slave_sg_context() as a wrapper so consumers do not
need to access the DMA engine callback pointer directly. This is a
preparatory step toward making DMA engine provider internals private.
Make it as deprecated.
Signed-off-by: Frank Li <Frank.Li@xxxxxxx>
---
include/linux/dmaengine.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index c3a49a33307c6..b4589cad6d742 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -1084,6 +1084,19 @@ dmaengine_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
return dmaengine_prep_config_sg(chan, sgl, sg_len, dir, flags, NULL);
}
+/* Depercated, don't use it except sound/soc/sprd/ */
+static inline struct dma_async_tx_descriptor *
+dmaengine_prep_slave_sg_context(struct dma_chan *chan, struct scatterlist *sgl,
+ unsigned int sg_len, enum dma_transfer_direction dir,
+ unsigned long flags, void *context)
+{
+ if (!chan->device->device_prep_slave_sg)
+ return NULL;
+
+ return chan->device->device_prep_slave_sg(chan, sgl, sg_len, dir,
+ flags, context);
+}
+
/**
* dmaengine_prep_config_sg_safe - prepare a scatter-gather DMA transfer
* with atomic slave configuration update
--
2.43.0