Re: [PATCH v2 1/1] spi: use dmaengine_desc_set_callback()

From: Andy Shevchenko

Date: Wed Nov 04 2026 - 12:07:53 EST


On Wed, Nov 04, 2026 at 10:22:45AM -0500, Frank.Li@xxxxxxxxxxx wrote:
>
> Replace open-coded assignments to callback and callback_param fields
> of struct dma_async_tx_descriptor with calls to the
> dmaengine_desc_set_callback() helper across SPI bus drivers.
>
> No functional change intended. Prepare make to struct
> dma_async_tx_descriptor private to the DMA engine.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> # dw, pxa2xx, topcliff-pch

(Note, you forgot to add the list of the drivers to the Rb trailers of other reviewers)

> drivers/spi/spi-dw-dma.c | 6 ++----
> drivers/spi/spi-pxa2xx-dma.c | 3 +--
> drivers/spi/spi-topcliff-pch.c | 6 ++----

> --- a/drivers/spi/spi-dw-dma.c
> +++ b/drivers/spi/spi-dw-dma.c
> @@ -397,8 +397,7 @@ static int dw_spi_dma_submit_tx(struct dw_spi *dws, struct scatterlist *sgl,
> if (!txdesc)
> return -ENOMEM;
>
> - txdesc->callback = dw_spi_dma_tx_done;
> - txdesc->callback_param = dws;
> + dmaengine_desc_set_callback(txdesc, dw_spi_dma_tx_done, NULL, dws);
>
> cookie = dmaengine_submit(txdesc);
> ret = dma_submit_error(cookie);
> @@ -498,8 +497,7 @@ static int dw_spi_dma_submit_rx(struct dw_spi *dws, struct scatterlist *sgl,
> if (!rxdesc)
> return -ENOMEM;
>
> - rxdesc->callback = dw_spi_dma_rx_done;
> - rxdesc->callback_param = dws;
> + dmaengine_desc_set_callback(rxdesc, dw_spi_dma_rx_done, NULL, dws);
>
> cookie = dmaengine_submit(rxdesc);
> ret = dma_submit_error(cookie);

> --- a/drivers/spi/spi-pxa2xx-dma.c
> +++ b/drivers/spi/spi-pxa2xx-dma.c
> @@ -154,8 +154,7 @@ int pxa2xx_spi_dma_prepare(struct driver_data *drv_data,
> }
>
> /* We are ready when RX completes */
> - rx_desc->callback = pxa2xx_spi_dma_callback;
> - rx_desc->callback_param = drv_data;
> + dmaengine_desc_set_callback(rx_desc, pxa2xx_spi_dma_callback, NULL, drv_data);
>
> dmaengine_submit(rx_desc);
> dmaengine_submit(tx_desc);

> --- a/drivers/spi/spi-topcliff-pch.c
> +++ b/drivers/spi/spi-topcliff-pch.c
> @@ -1022,8 +1022,7 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw)
> return;
> }
> dma_sync_sg_for_device(&data->host->dev, sg, num, DMA_FROM_DEVICE);
> - desc_rx->callback = pch_dma_rx_complete;
> - desc_rx->callback_param = data;
> + dmaengine_desc_set_callback(desc_rx, pch_dma_rx_complete, NULL, data);
> dma->nent = num;
> dma->desc_rx = desc_rx;
>
> @@ -1084,8 +1083,7 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw)
> return;
> }
> dma_sync_sg_for_device(&data->host->dev, sg, num, DMA_TO_DEVICE);
> - desc_tx->callback = NULL;
> - desc_tx->callback_param = data;
> + dmaengine_desc_set_callback(desc_tx, NULL, NULL, data);

Yeah, data can be replaced by NULL as has been already mentioned.

> dma->nent = num;
> dma->desc_tx = desc_tx;
>

--
With Best Regards,
Andy Shevchenko