Commit a4cc7eb4 authored by Jaehoon Chung's avatar Jaehoon Chung Committed by Ulf Hansson

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: default avatarJaehoon Chung <jh80.chung@samsung.com>
Tested-by: default avatarHeiko Stuebner <heiko@sntech.de>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent e13c3c08
...@@ -414,12 +414,13 @@ static void dw_mci_dma_cleanup(struct dw_mci *host) ...@@ -414,12 +414,13 @@ static void dw_mci_dma_cleanup(struct dw_mci *host)
{ {
struct mmc_data *data = host->data; struct mmc_data *data = host->data;
if (data) if (data && data->host_cookie == COOKIE_MAPPED) {
if (!data->host_cookie)
dma_unmap_sg(host->dev, dma_unmap_sg(host->dev,
data->sg, data->sg,
data->sg_len, data->sg_len,
dw_mci_get_dma_dir(data)); dw_mci_get_dma_dir(data));
data->host_cookie = COOKIE_UNMAPPED;
}
} }
static void dw_mci_idmac_reset(struct dw_mci *host) static 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,13 +851,13 @@ static const struct dw_mci_dma_ops dw_mci_edmac_ops = {
static int dw_mci_pre_dma_transfer(struct dw_mci *host, static int dw_mci_pre_dma_transfer(struct dw_mci *host,
struct mmc_data *data, struct mmc_data *data,
bool next) int cookie)
{ {
struct scatterlist *sg; struct scatterlist *sg;
unsigned int i, sg_len; unsigned int i, sg_len;
if (!next && data->host_cookie) if (data->host_cookie == COOKIE_PRE_MAPPED)
return data->host_cookie; return data->sg_len;
/* /*
* We don't do DMA on "complex" transfers, i.e. with * 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,8 +882,7 @@ static int dw_mci_pre_dma_transfer(struct dw_mci *host,
if (sg_len == 0) if (sg_len == 0)
return -EINVAL; return -EINVAL;
if (next) data->host_cookie = cookie;
data->host_cookie = sg_len;
return sg_len; return sg_len;
} }
...@@ -897,13 +897,12 @@ static void dw_mci_pre_req(struct mmc_host *mmc, ...@@ -897,13 +897,12 @@ static void dw_mci_pre_req(struct mmc_host *mmc,
if (!slot->host->use_dma || !data) if (!slot->host->use_dma || !data)
return; return;
if (data->host_cookie) { /* This data might be unmapped at this time */
data->host_cookie = 0; data->host_cookie = COOKIE_UNMAPPED;
return;
}
if (dw_mci_pre_dma_transfer(slot->host, mrq->data, 1) < 0) if (dw_mci_pre_dma_transfer(slot->host, mrq->data,
data->host_cookie = 0; COOKIE_PRE_MAPPED) < 0)
data->host_cookie = COOKIE_UNMAPPED;
} }
static void dw_mci_post_req(struct mmc_host *mmc, static void dw_mci_post_req(struct mmc_host *mmc,
...@@ -916,12 +915,12 @@ static void dw_mci_post_req(struct mmc_host *mmc, ...@@ -916,12 +915,12 @@ static void dw_mci_post_req(struct mmc_host *mmc,
if (!slot->host->use_dma || !data) if (!slot->host->use_dma || !data)
return; return;
if (data->host_cookie) if (data->host_cookie != COOKIE_UNMAPPED)
dma_unmap_sg(slot->host->dev, dma_unmap_sg(slot->host->dev,
data->sg, data->sg,
data->sg_len, data->sg_len,
dw_mci_get_dma_dir(data)); dw_mci_get_dma_dir(data));
data->host_cookie = 0; data->host_cookie = COOKIE_UNMAPPED;
} }
static void dw_mci_adjust_fifoth(struct dw_mci *host, struct mmc_data *data) static 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,7 +1026,7 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data)
if (!host->use_dma) if (!host->use_dma)
return -ENODEV; return -ENODEV;
sg_len = dw_mci_pre_dma_transfer(host, data, 0); sg_len = dw_mci_pre_dma_transfer(host, data, COOKIE_MAPPED);
if (sg_len < 0) { if (sg_len < 0) {
host->dma_ops->stop(host); host->dma_ops->stop(host);
return sg_len; return sg_len;
......
...@@ -39,6 +39,12 @@ enum { ...@@ -39,6 +39,12 @@ enum {
EVENT_DATA_ERROR, EVENT_DATA_ERROR,
}; };
enum dw_mci_cookie {
COOKIE_UNMAPPED,
COOKIE_PRE_MAPPED, /* mapped by pre_req() of dwmmc */
COOKIE_MAPPED, /* mapped by prepare_data() of dwmmc */
};
struct mmc_data; struct mmc_data;
enum { enum {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment