From patchwork Tue Nov 15 10:12:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 9429287 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 588956047D for ; Tue, 15 Nov 2016 10:13:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 438F22878B for ; Tue, 15 Nov 2016 10:13:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 364EF28793; Tue, 15 Nov 2016 10:13:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDBD228735 for ; Tue, 15 Nov 2016 10:13:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941563AbcKOKMz (ORCPT ); Tue, 15 Nov 2016 05:12:55 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:60899 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S941613AbcKOKMs (ORCPT ); Tue, 15 Nov 2016 05:12:48 -0500 Received: from epcpsbgm1new.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OGO00AFZHOSER70@mailout1.samsung.com>; Tue, 15 Nov 2016 19:12:35 +0900 (KST) X-AuditID: cbfee61a-f79916d0000062de-b7-582adf9365ed Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 96.CF.25310.39FDA285; Tue, 15 Nov 2016 19:12:35 +0900 (KST) Received: from localhost.localdomain ([10.113.62.216]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OGO004CZHOYWN60@mmp1.samsung.com>; Tue, 15 Nov 2016 19:12:34 +0900 (KST) From: Jaehoon Chung To: linux-mmc@vger.kernel.org Cc: devicetree@vger.kernel.org, ulf.hansson@linaro.org, heiko@sntech.de, shawn.lin@rock-chips.com, robh+dt@kernel.org, Jaehoon Chung Subject: [PATCHv2 07/10] mmc: dw_mmc: use the cookie's enum values for post/pre_req() Date: Tue, 15 Nov 2016 19:12:29 +0900 Message-id: <20161115101232.3854-8-jh80.chung@samsung.com> X-Mailer: git-send-email 2.10.1 In-reply-to: <20161115101232.3854-1-jh80.chung@samsung.com> References: <20161115101232.3854-1-jh80.chung@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrILMWRmVeSWpSXmKPExsVy+t9jAd3J97UiDO7eF7KYf+Qcq8X/R69Z LW78amO1OPK/n9Gide8Rdos7T9azWhxfG+7A7rFpVSebx51re9g8/s7az+LRt2UVo8f2a/OY PT5vkgtgi3KzyUhNTEktUkjNS85PycxLt1UKDXHTtVBSyEvMTbVVitD1DQlSUihLzCkF8owM 0ICDc4B7sJK+XYJbxvwZe5kKNktUPNnZzNzAuFG4i5GTQ0LARGLpv38sELaYxIV769m6GLk4 hASWMkqcv/WAGcL5wSgx5+MDNpAqNgEdie3fjjOB2CICshI//1wAizMLLGSUePkiEcQWFgiX mDl9BzOIzSKgKjH9xE5GEJtXwErizMr/zBDb5CUuXD0FtplTwFri+LODYDVCQDW/nvUwTmDk XcDIsIpRIrUguaA4KT3XMC+1XK84Mbe4NC9dLzk/dxMjOLifSe1gPLjL/RCjAAejEg9voLdW hBBrYllxZe4hRgkOZiURXvNrQCHelMTKqtSi/Pii0pzU4kOMpkCHTWSWEk3OB0ZeXkm8oYm5 ibmxgYW5paWJkZI4b+PsZ+FCAumJJanZqakFqUUwfUwcnFINjI6OW/V217/MWe916MSRf9Wz rQN3J4XM3zCPd7+Y9UzGtpRp4acuJEj2q853slF1+PfV0/vib+60hhDF1z9zvCpv3FPcoH9N 6n+EDmeG7e+9kcbBp/8fPvRQybhEhptT1XvJKa55+37rJF9ZMod/C//bqIB3v5+rzX+0wfS3 6v6DzUb13+0L1ZVYijMSDbWYi4oTAW0suomEAgAA X-MTR: 20000000000000000@CPGS Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch removed the meaningless value. Instead, use the cookie's enum values for executing correctly. Signed-off-by: Jaehoon Chung Tested-by: Heiko Stuebner --- drivers/mmc/host/dw_mmc.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 12e1107..e912de6 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) { struct mmc_data *data = host->data; - if (data) - if (!data->host_cookie) - dma_unmap_sg(host->dev, - data->sg, - data->sg_len, - dw_mci_get_dma_dir(data)); + if (data && data->host_cookie == COOKIE_MAPPED) { + dma_unmap_sg(host->dev, + data->sg, + data->sg_len, + dw_mci_get_dma_dir(data)); + data->host_cookie = COOKIE_UNMAPPED; + } } 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 = { static int dw_mci_pre_dma_transfer(struct dw_mci *host, struct mmc_data *data, - bool next) + int cookie) { struct scatterlist *sg; unsigned int i, sg_len; - if (!next && data->host_cookie) - return data->host_cookie; + if (data->host_cookie == COOKIE_PRE_MAPPED) + return data->sg_len; /* * 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, if (sg_len == 0) return -EINVAL; - if (next) - data->host_cookie = sg_len; + data->host_cookie = cookie; return sg_len; } @@ -897,13 +897,12 @@ static void dw_mci_pre_req(struct mmc_host *mmc, if (!slot->host->use_dma || !data) return; - if (data->host_cookie) { - data->host_cookie = 0; - return; - } + /* This data might be unmapped at this time */ + data->host_cookie = COOKIE_UNMAPPED; - if (dw_mci_pre_dma_transfer(slot->host, mrq->data, 1) < 0) - data->host_cookie = 0; + if (dw_mci_pre_dma_transfer(slot->host, mrq->data, + COOKIE_PRE_MAPPED) < 0) + data->host_cookie = COOKIE_UNMAPPED; } 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) return; - if (data->host_cookie) + if (data->host_cookie != COOKIE_UNMAPPED) dma_unmap_sg(slot->host->dev, data->sg, data->sg_len, 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) @@ -1027,7 +1026,7 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data) if (!host->use_dma) 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) { host->dma_ops->stop(host); return sg_len;