From: Frank Li Generalize dmaengine_prep_rio_sg() by renaming it to dmaengine_prep_slave_sg_context() and changing the context parameter type from 'struct rio_dma_ext *' to 'void *', making it suitable for any DMA engine user that needs to pass context to device_prep_slave_sg(). Remove the CONFIG_RAPIDIO_DMA_ENGINE guard so the helper is unconditionally available. Update drivers/rapidio/rio.c to use the new API. No functional change. Prepare to make struct dma_device private to the DMA engine. Signed-off-by: Frank Li --- Need go through DMA engineer tree to avoid build break. --- drivers/rapidio/rio.c | 15 ++++++++------- include/linux/dmaengine.h | 9 +++------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c index f45e58b0971f5..9bba811f75da7 100644 --- a/drivers/rapidio/rio.c +++ b/drivers/rapidio/rio.c @@ -1804,20 +1804,21 @@ struct dma_async_tx_descriptor *rio_dma_prep_xfer(struct dma_chan *dchan, u16 destid, struct rio_dma_data *data, enum dma_transfer_direction direction, unsigned long flags) { + struct dma_async_tx_descriptor *tx; struct rio_dma_ext rio_ext; - if (!dchan->device->device_prep_slave_sg) { - pr_err("%s: prep_rio_sg == NULL\n", __func__); - return NULL; - } - rio_ext.destid = destid; rio_ext.rio_addr_u = data->rio_addr_u; rio_ext.rio_addr = data->rio_addr; rio_ext.wr_type = data->wr_type; - return dmaengine_prep_rio_sg(dchan, data->sg, data->sg_len, - direction, flags, &rio_ext); + tx = dmaengine_prep_slave_sg_context(dchan, data->sg, data->sg_len, + direction, flags, &rio_ext); + + if (!tx) + pr_err("%s: prep_rio_sg == NULL\n", __func__); + + return tx; } EXPORT_SYMBOL_GPL(rio_dma_prep_xfer); diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index 9452bb2c04af7..d0906bcdabd6c 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -1070,20 +1070,17 @@ dmaengine_prep_config_single_safe(struct dma_chan *chan, dma_addr_t buf, return dmaengine_prep_config_sg_safe(chan, &sg, 1, dir, flags, config); } -#ifdef CONFIG_RAPIDIO_DMA_ENGINE -struct rio_dma_ext; -static inline struct dma_async_tx_descriptor *dmaengine_prep_rio_sg( +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, - struct rio_dma_ext *rio_ext) + void *context) { if (!chan || !chan->device || !chan->device->device_prep_slave_sg) return NULL; return chan->device->device_prep_slave_sg(chan, sgl, sg_len, - dir, flags, rio_ext); + dir, flags, context); } -#endif static inline struct dma_async_tx_descriptor *dmaengine_prep_dma_cyclic( struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len, -- 2.43.0 From: Frank Li Replace the direct call to dma_dev->device_prep_slave_sg() with the dmaengine_prep_slave_sg_context() helper, which handles NULL checks and passes the context pointer cleanly. No functional change. Prepare to make struct dma_device private to the DMA engine. Signed-off-by: Frank Li --- Suggest go through DMA engine tree. this is only one of 3 user, which use context at prep sg. --- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 7e83c4b5f1931..55d1b39caf7ed 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -1006,9 +1006,10 @@ axienet_start_xmit_dmaengine(struct sk_buff *skb, struct net_device *ndev) app_metadata[0] |= 2; /* Tx Full Checksum Offload Enabled */ } - dma_tx_desc = dma_dev->device_prep_slave_sg(lp->tx_chan, skbuf_dma->sgl, - sg_len, DMA_MEM_TO_DEV, - DMA_PREP_INTERRUPT, (void *)app_metadata); + dma_tx_desc = dmaengine_prep_slave_sg_context(lp->tx_chan, skbuf_dma->sgl, + sg_len, DMA_MEM_TO_DEV, + DMA_PREP_INTERRUPT, + (void *)app_metadata); if (!dma_tx_desc) goto xmit_error_unmap_sg; -- 2.43.0 From: Frank Li Replace direct calls to chan->device->device_prep_slave_sg() with the dmaengine_prep_slave_sg_context() helper in both sprd-pcm-dma.c and sprd-pcm-compress.c. No functional change. Prepare to make struct dma_device private to the DMA engine. Signed-off-by: Frank Li --- Last user use prep_sg with context argument. Suggest go through DMA Engine tree directly. --- sound/soc/sprd/sprd-pcm-compress.c | 6 +++--- sound/soc/sprd/sprd-pcm-dma.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/soc/sprd/sprd-pcm-compress.c b/sound/soc/sprd/sprd-pcm-compress.c index a810c9c8a0b5b..228cb8741c438 100644 --- a/sound/soc/sprd/sprd-pcm-compress.c +++ b/sound/soc/sprd/sprd-pcm-compress.c @@ -236,9 +236,9 @@ static int sprd_platform_compr_dma_config(struct snd_soc_component *component, * We configure the DMA request mode, interrupt mode, channel * mode and channel trigger mode by the flags. */ - dma->desc = dma->chan->device->device_prep_slave_sg(dma->chan, sg, - sg_num, dir, - flags, &link); + dma->desc = dmaengine_prep_slave_sg_context(dma->chan, sg, + sg_num, dir, + flags, &link); if (!dma->desc) { dev_err(dev, "failed to prepare slave sg\n"); ret = -ENOMEM; diff --git a/sound/soc/sprd/sprd-pcm-dma.c b/sound/soc/sprd/sprd-pcm-dma.c index 968901ae4c335..bb72cb272d4b3 100644 --- a/sound/soc/sprd/sprd-pcm-dma.c +++ b/sound/soc/sprd/sprd-pcm-dma.c @@ -277,9 +277,9 @@ static int sprd_pcm_hw_params(struct snd_soc_component *component, */ flags = SPRD_DMA_FLAGS(SPRD_DMA_CHN_MODE_NONE, SPRD_DMA_NO_TRG, SPRD_DMA_FRAG_REQ, SPRD_DMA_TRANS_INT); - data->desc = chan->device->device_prep_slave_sg(chan, sg, - sg_num, dir, - flags, &link); + data->desc = dmaengine_prep_slave_sg_context(chan, sg, + sg_num, dir, + flags, &link); if (!data->desc) { dev_err(component->dev, "failed to prepare slave sg\n"); ret = -ENOMEM; -- 2.43.0