sdhci_finish_data() has two paths which result in identical DMA cleanup.
One is when SDHCI_USE_ADMA is clear, and the other is just before when
SDHCI_USE_ADMA is set, and is performed within sdhci_adma_table_post().

Simplify the code by removing the 'else' and eliminating the duplicate
inside sdhci_adma_table_post().

Signed-off-by: Russell King <rmk+ker...@arm.linux.org.uk>
---
 drivers/mmc/host/sdhci.c | 29 +++++++----------------------
 1 file changed, 7 insertions(+), 22 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 90ad6fd8bb65..d315273d1184 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -549,19 +549,12 @@ static int sdhci_adma_table_pre(struct sdhci_host *host,
 static void sdhci_adma_table_post(struct sdhci_host *host,
        struct mmc_data *data)
 {
-       int direction;
-
        struct scatterlist *sg;
        int i, size;
        void *align;
        char *buffer;
        unsigned long flags;
 
-       if (data->flags & MMC_DATA_READ)
-               direction = DMA_FROM_DEVICE;
-       else
-               direction = DMA_TO_DEVICE;
-
        if (data->flags & MMC_DATA_READ) {
                bool has_unaligned = false;
 
@@ -574,7 +567,7 @@ static void sdhci_adma_table_post(struct sdhci_host *host,
 
                if (has_unaligned) {
                        dma_sync_sg_for_cpu(mmc_dev(host->mmc), data->sg,
-                               data->sg_len, direction);
+                                           data->sg_len, DMA_FROM_DEVICE);
 
                        align = host->align_buffer;
 
@@ -592,12 +585,6 @@ static void sdhci_adma_table_post(struct sdhci_host *host,
                        }
                }
        }
-
-       if (data->host_cookie == COOKIE_MAPPED) {
-               dma_unmap_sg(mmc_dev(host->mmc), data->sg,
-                       data->sg_len, direction);
-               data->host_cookie = COOKIE_UNMAPPED;
-       }
 }
 
 static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd)
@@ -908,14 +895,12 @@ static void sdhci_finish_data(struct sdhci_host *host)
        if (host->flags & SDHCI_REQ_USE_DMA) {
                if (host->flags & SDHCI_USE_ADMA)
                        sdhci_adma_table_post(host, data);
-               else {
-                       if (data->host_cookie == COOKIE_MAPPED) {
-                               dma_unmap_sg(mmc_dev(host->mmc),
-                                       data->sg, data->sg_len,
-                                       (data->flags & MMC_DATA_READ) ?
-                                       DMA_FROM_DEVICE : DMA_TO_DEVICE);
-                               data->host_cookie = COOKIE_UNMAPPED;
-                       }
+
+               if (data->host_cookie == COOKIE_MAPPED) {
+                       dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len,
+                                    (data->flags & MMC_DATA_READ) ?
+                                    DMA_FROM_DEVICE : DMA_TO_DEVICE);
+                       data->host_cookie = COOKIE_UNMAPPED;
                }
        }
 
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to