mmc: atmel-mci: conform to DMA-API
authorLinus Walleij <linus.walleij@linaro.org>
Thu, 10 Feb 2011 15:08:16 +0000 (16:08 +0100)
committerChris Ball <cjb@laptop.org>
Tue, 15 Mar 2011 17:49:05 +0000 (13:49 -0400)
Fixes the following:
- It is perfectly legal for the dma_map_sg() to return fewer
  entries than were passed in.
- Supply the returned numer of (possibly coalesced) entries to
  the device_pre_slave_sg() function.
- Use the proper original sg_len when unmapping the sglist
  in the error path.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
drivers/mmc/host/atmel-mci.c

index 045bdbbe3720a3ad200763be003650931c740225..df5a135423709973587aa004e86036ca85b1252a 100644 (file)
@@ -687,10 +687,9 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)
 
        sglen = dma_map_sg(chan->device->dev, data->sg,
                           data->sg_len, direction);
-       if (sglen != data->sg_len)
-               goto unmap_exit;
+
        desc = chan->device->device_prep_slave_sg(chan,
-                       data->sg, data->sg_len, direction,
+                       data->sg, sglen, direction,
                        DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
        if (!desc)
                goto unmap_exit;
@@ -701,7 +700,7 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)
 
        return 0;
 unmap_exit:
-       dma_unmap_sg(chan->device->dev, data->sg, sglen, direction);
+       dma_unmap_sg(chan->device->dev, data->sg, data->sg_len, direction);
        return -ENOMEM;
 }