summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaehoon Chung <jh80.chung@samsung.com>2016-11-17 02:40:38 -0500
committerUlf Hansson <ulf.hansson@linaro.org>2016-11-29 03:05:09 -0500
commita4cc7eb4416fda59f18e744925ba3a347f7ecac5 (patch)
tree5f35b8d91c46c3e4ede09de5839a7c6c37b0d4f0
parente13c3c081845b51e8ba71a90e91c52679cfdbf89 (diff)
mmc: dw_mmc: use the cookie's enum values for post/pre_req()
This patch removed the meaningless value. Instead, use the cookie's enum values for executing correctly. Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com> Tested-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/host/dw_mmc.c39
-rw-r--r--include/linux/mmc/dw_mmc.h6
2 files changed, 25 insertions, 20 deletions
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 0b220e5a8169..65546b6df840 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -414,12 +414,13 @@ static void dw_mci_dma_cleanup(struct dw_mci *host)
414{ 414{
415 struct mmc_data *data = host->data; 415 struct mmc_data *data = host->data;
416 416
417 if (data) 417 if (data && data->host_cookie == COOKIE_MAPPED) {
418 if (!data->host_cookie) 418 dma_unmap_sg(host->dev,
419 dma_unmap_sg(host->dev, 419 data->sg,
420 data->sg, 420 data->sg_len,
421 data->sg_len, 421 dw_mci_get_dma_dir(data));
422 dw_mci_get_dma_dir(data)); 422 data->host_cookie = COOKIE_UNMAPPED;
423 }
423} 424}
424 425
425static void dw_mci_idmac_reset(struct dw_mci *host) 426static void dw_mci_idmac_reset(struct dw_mci *host)
@@ -850,13 +851,13 @@ static const struct dw_mci_dma_ops dw_mci_edmac_ops = {
850 851
851static int dw_mci_pre_dma_transfer(struct dw_mci *host, 852static int dw_mci_pre_dma_transfer(struct dw_mci *host,
852 struct mmc_data *data, 853 struct mmc_data *data,
853 bool next) 854 int cookie)
854{ 855{
855 struct scatterlist *sg; 856 struct scatterlist *sg;
856 unsigned int i, sg_len; 857 unsigned int i, sg_len;
857 858
858 if (!next && data->host_cookie) 859 if (data->host_cookie == COOKIE_PRE_MAPPED)
859 return data->host_cookie; 860 return data->sg_len;
860 861
861 /* 862 /*
862 * We don't do DMA on "complex" transfers, i.e. with 863 * We don't do DMA on "complex" transfers, i.e. with
@@ -881,8 +882,7 @@ static int dw_mci_pre_dma_transfer(struct dw_mci *host,
881 if (sg_len == 0) 882 if (sg_len == 0)
882 return -EINVAL; 883 return -EINVAL;
883 884
884 if (next) 885 data->host_cookie = cookie;
885 data->host_cookie = sg_len;
886 886
887 return sg_len; 887 return sg_len;
888} 888}
@@ -897,13 +897,12 @@ static void dw_mci_pre_req(struct mmc_host *mmc,
897 if (!slot->host->use_dma || !data) 897 if (!slot->host->use_dma || !data)
898 return; 898 return;
899 899
900 if (data->host_cookie) { 900 /* This data might be unmapped at this time */
901 data->host_cookie = 0; 901 data->host_cookie = COOKIE_UNMAPPED;
902 return;
903 }
904 902
905 if (dw_mci_pre_dma_transfer(slot->host, mrq->data, 1) < 0) 903 if (dw_mci_pre_dma_transfer(slot->host, mrq->data,
906 data->host_cookie = 0; 904 COOKIE_PRE_MAPPED) < 0)
905 data->host_cookie = COOKIE_UNMAPPED;
907} 906}
908 907
909static void dw_mci_post_req(struct mmc_host *mmc, 908static void dw_mci_post_req(struct mmc_host *mmc,
@@ -916,12 +915,12 @@ static void dw_mci_post_req(struct mmc_host *mmc,
916 if (!slot->host->use_dma || !data) 915 if (!slot->host->use_dma || !data)
917 return; 916 return;
918 917
919 if (data->host_cookie) 918 if (data->host_cookie != COOKIE_UNMAPPED)
920 dma_unmap_sg(slot->host->dev, 919 dma_unmap_sg(slot->host->dev,
921 data->sg, 920 data->sg,
922 data->sg_len, 921 data->sg_len,
923 dw_mci_get_dma_dir(data)); 922 dw_mci_get_dma_dir(data));
924 data->host_cookie = 0; 923 data->host_cookie = COOKIE_UNMAPPED;
925} 924}
926 925
927static void dw_mci_adjust_fifoth(struct dw_mci *host, struct mmc_data *data) 926static void dw_mci_adjust_fifoth(struct dw_mci *host, struct mmc_data *data)
@@ -1027,7 +1026,7 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data)
1027 if (!host->use_dma) 1026 if (!host->use_dma)
1028 return -ENODEV; 1027 return -ENODEV;
1029 1028
1030 sg_len = dw_mci_pre_dma_transfer(host, data, 0); 1029 sg_len = dw_mci_pre_dma_transfer(host, data, COOKIE_MAPPED);
1031 if (sg_len < 0) { 1030 if (sg_len < 0) {
1032 host->dma_ops->stop(host); 1031 host->dma_ops->stop(host);
1033 return sg_len; 1032 return sg_len;
diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h
index f5af2bd35e7f..15db6f83f53f 100644
--- a/include/linux/mmc/dw_mmc.h
+++ b/include/linux/mmc/dw_mmc.h
@@ -39,6 +39,12 @@ enum {
39 EVENT_DATA_ERROR, 39 EVENT_DATA_ERROR,
40}; 40};
41 41
42enum dw_mci_cookie {
43 COOKIE_UNMAPPED,
44 COOKIE_PRE_MAPPED, /* mapped by pre_req() of dwmmc */
45 COOKIE_MAPPED, /* mapped by prepare_data() of dwmmc */
46};
47
42struct mmc_data; 48struct mmc_data;
43 49
44enum { 50enum {