mmc: sdhci: factor out common DMA cleanup in sdhci_finish_data()
authorRussell King <rmk+kernel@arm.linux.org.uk>
Tue, 26 Jan 2016 13:40:11 +0000 (13:40 +0000)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 29 Feb 2016 10:03:19 +0000 (11:03 +0100)
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+kernel@arm.linux.org.uk>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Tested-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/sdhci.c

index b28aa0f0276b4163b9a45f5d453d5cd9e37f84c8..54ab050bc47bcf4a41905e2e0febed35389a41b1 100644 (file)
@@ -552,19 +552,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;
 
@@ -577,7 +570,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;
 
@@ -595,12 +588,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)
@@ -920,14 +907,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;
                }
        }