diff mbox series

[1/3] dmaengine: altera-msgdma: Correctly handle descriptor callbacks

Message ID 20211025075428.2094-1-lars@metafoo.de (mailing list archive)
State Accepted
Commit a34da7ef9a8c2b89ddb84689562f3d2b48a4e588
Headers show
Series [1/3] dmaengine: altera-msgdma: Correctly handle descriptor callbacks | expand

Commit Message

Lars-Peter Clausen Oct. 25, 2021, 7:54 a.m. UTC
DMA clients can provide one of two types of callbacks. For this reason
dmaengine drivers should not directly invoke `callback`, but always use
dmaengine_desc_callback_invoke(). This makes sure that both types of
callbacks are handled correctly.

The altera-msgdma driver currently doesn't do this and only handles the
`callback` type callback. If the client used the `callback_result` type
callback it will not be called.

Fix this by switching to `dmaengine_desc_callback_valid()` and
`dmaengine_desc_callback_invoke()`.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/dma/altera-msgdma.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Comments

Vinod Koul Oct. 28, 2021, 5:24 p.m. UTC | #1
On 25-10-21, 09:54, Lars-Peter Clausen wrote:
> DMA clients can provide one of two types of callbacks. For this reason
> dmaengine drivers should not directly invoke `callback`, but always use
> dmaengine_desc_callback_invoke(). This makes sure that both types of
> callbacks are handled correctly.
> 
> The altera-msgdma driver currently doesn't do this and only handles the
> `callback` type callback. If the client used the `callback_result` type
> callback it will not be called.
> 
> Fix this by switching to `dmaengine_desc_callback_valid()` and
> `dmaengine_desc_callback_invoke()`.

Applied all, thanks
diff mbox series

Patch

diff --git a/drivers/dma/altera-msgdma.c b/drivers/dma/altera-msgdma.c
index 5a2c7573b692..f5b885d69cd3 100644
--- a/drivers/dma/altera-msgdma.c
+++ b/drivers/dma/altera-msgdma.c
@@ -585,16 +585,14 @@  static void msgdma_chan_desc_cleanup(struct msgdma_device *mdev)
 	struct msgdma_sw_desc *desc, *next;
 
 	list_for_each_entry_safe(desc, next, &mdev->done_list, node) {
-		dma_async_tx_callback callback;
-		void *callback_param;
+		struct dmaengine_desc_callback cb;
 
 		list_del(&desc->node);
 
-		callback = desc->async_tx.callback;
-		callback_param = desc->async_tx.callback_param;
-		if (callback) {
+		dmaengine_desc_get_callback(&desc->async_tx, &cb);
+		if (dmaengine_desc_callback_valid(&cb)) {
 			spin_unlock(&mdev->lock);
-			callback(callback_param);
+			dmaengine_desc_callback_invoke(&cb, NULL);
 			spin_lock(&mdev->lock);
 		}