aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2016-01-26 08:40:11 -0500
committerUlf Hansson <ulf.hansson@linaro.org>2016-02-29 05:03:19 -0500
commitf55c98f7466c2e52125d6ffd69295c0158ac609a (patch)
tree825201d7a1d8237ed42d3830a713249946da7d3e /drivers/mmc
parent47fa961340d2181ebf1165b7651dcbb1b1029163 (diff)
mmc: sdhci: factor out common DMA cleanup in sdhci_finish_data()
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>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/host/sdhci.c29
1 files changed, 7 insertions, 22 deletions
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index b28aa0f0276b..54ab050bc47b 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -552,19 +552,12 @@ static int sdhci_adma_table_pre(struct sdhci_host *host,
552static void sdhci_adma_table_post(struct sdhci_host *host, 552static void sdhci_adma_table_post(struct sdhci_host *host,
553 struct mmc_data *data) 553 struct mmc_data *data)
554{ 554{
555 int direction;
556
557 struct scatterlist *sg; 555 struct scatterlist *sg;
558 int i, size; 556 int i, size;
559 void *align; 557 void *align;
560 char *buffer; 558 char *buffer;
561 unsigned long flags; 559 unsigned long flags;
562 560
563 if (data->flags & MMC_DATA_READ)
564 direction = DMA_FROM_DEVICE;
565 else
566 direction = DMA_TO_DEVICE;
567
568 if (data->flags & MMC_DATA_READ) { 561 if (data->flags & MMC_DATA_READ) {
569 bool has_unaligned = false; 562 bool has_unaligned = false;
570 563
@@ -577,7 +570,7 @@ static void sdhci_adma_table_post(struct sdhci_host *host,
577 570
578 if (has_unaligned) { 571 if (has_unaligned) {
579 dma_sync_sg_for_cpu(mmc_dev(host->mmc), data->sg, 572 dma_sync_sg_for_cpu(mmc_dev(host->mmc), data->sg,
580 data->sg_len, direction); 573 data->sg_len, DMA_FROM_DEVICE);
581 574
582 align = host->align_buffer; 575 align = host->align_buffer;
583 576
@@ -595,12 +588,6 @@ static void sdhci_adma_table_post(struct sdhci_host *host,
595 } 588 }
596 } 589 }
597 } 590 }
598
599 if (data->host_cookie == COOKIE_MAPPED) {
600 dma_unmap_sg(mmc_dev(host->mmc), data->sg,
601 data->sg_len, direction);
602 data->host_cookie = COOKIE_UNMAPPED;
603 }
604} 591}
605 592
606static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd) 593static 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)
920 if (host->flags & SDHCI_REQ_USE_DMA) { 907 if (host->flags & SDHCI_REQ_USE_DMA) {
921 if (host->flags & SDHCI_USE_ADMA) 908 if (host->flags & SDHCI_USE_ADMA)
922 sdhci_adma_table_post(host, data); 909 sdhci_adma_table_post(host, data);
923 else { 910
924 if (data->host_cookie == COOKIE_MAPPED) { 911 if (data->host_cookie == COOKIE_MAPPED) {
925 dma_unmap_sg(mmc_dev(host->mmc), 912 dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len,
926 data->sg, data->sg_len, 913 (data->flags & MMC_DATA_READ) ?
927 (data->flags & MMC_DATA_READ) ? 914 DMA_FROM_DEVICE : DMA_TO_DEVICE);
928 DMA_FROM_DEVICE : DMA_TO_DEVICE); 915 data->host_cookie = COOKIE_UNMAPPED;
929 data->host_cookie = COOKIE_UNMAPPED;
930 }
931 } 916 }
932 } 917 }
933 918