diff mbox series

[V2,7/7] mmc: bcm2835: Properly handle dmaengine_prep_slave_sg

Message ID 1541967839-2847-8-git-send-email-stefan.wahren@i2se.com (mailing list archive)
State New, archived
Headers show
Series mmc: Several fixes for bcm2835 driver | expand

Commit Message

Stefan Wahren Nov. 11, 2018, 8:23 p.m. UTC
In case dmaengine_prep_slave_sg fails we need to call dma_unmap_sg.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/mmc/host/bcm2835.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

Comments

Eric Anholt Nov. 28, 2018, 5:27 p.m. UTC | #1
Stefan Wahren <stefan.wahren@i2se.com> writes:

> In case dmaengine_prep_slave_sg fails we need to call dma_unmap_sg.
>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>

This series is:

Acked-by: Eric Anholt <eric@anholt.net>
Stefan Wahren Dec. 4, 2018, 6:20 p.m. UTC | #2
Hi Ulf,

> Eric Anholt <eric@anholt.net> hat am 28. November 2018 um 18:27 geschrieben:
> 
> 
> Stefan Wahren <stefan.wahren@i2se.com> writes:
> 
> > In case dmaengine_prep_slave_sg fails we need to call dma_unmap_sg.
> >
> > Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> 
> This series is:
> 
> Acked-by: Eric Anholt <eric@anholt.net>

should i resend with Eric's Ack?
diff mbox series

Patch

diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c
index c42bdaa..82e4b08 100644
--- a/drivers/mmc/host/bcm2835.c
+++ b/drivers/mmc/host/bcm2835.c
@@ -518,13 +518,16 @@  void bcm2835_prepare_dma(struct bcm2835_host *host, struct mmc_data *data)
 	desc = dmaengine_prep_slave_sg(dma_chan, data->sg, sg_len, dir_slave,
 				       DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
 
-	if (desc) {
-		desc->callback = bcm2835_dma_complete;
-		desc->callback_param = host;
-		host->dma_desc = desc;
-		host->dma_chan = dma_chan;
-		host->dma_dir = dir_data;
+	if (!desc) {
+		dma_unmap_sg(dma_chan->device->dev, data->sg, sg_len, dir_data);
+		return;
 	}
+
+	desc->callback = bcm2835_dma_complete;
+	desc->callback_param = host;
+	host->dma_desc = desc;
+	host->dma_chan = dma_chan;
+	host->dma_dir = dir_data;
 }
 
 static void bcm2835_start_dma(struct bcm2835_host *host)