From patchwork Thu Nov 3 06:21: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: 9410437 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 E263F60573 for ; Thu, 3 Nov 2016 06:26:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3EF72A53A for ; Thu, 3 Nov 2016 06:26:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C85782A55B; Thu, 3 Nov 2016 06:26:54 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D48BC2A53A for ; Thu, 3 Nov 2016 06:26:53 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c2BSR-0005n9-Tl; Thu, 03 Nov 2016 06:25:03 +0000 Received: from mailout2.samsung.com ([203.254.224.25]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c2BPm-0003FB-Lh; Thu, 03 Nov 2016 06:22:20 +0000 Received: from epcpsbgm1new.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OG101AYWYZOI240@mailout2.samsung.com>; Thu, 03 Nov 2016 15:21:50 +0900 (KST) X-AuditID: cbfee61a-f79916d0000062de-d4-581ad77e353d Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id DA.8B.25310.E77DA185; Thu, 3 Nov 2016 15:21:50 +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 <0OG100J7YZ02LAA0@mmp1.samsung.com>; Thu, 03 Nov 2016 15:21:50 +0900 (KST) From: Jaehoon Chung To: linux-mmc@vger.kernel.org Subject: [PATCH 07/13] mmc: dw_mmc: use the cookie's enum values for post/pre_req() Date: Thu, 03 Nov 2016 15:21:29 +0900 Message-id: <20161103062135.10697-8-jh80.chung@samsung.com> X-Mailer: git-send-email 2.10.1 In-reply-to: <20161103062135.10697-1-jh80.chung@samsung.com> References: <20161103062135.10697-1-jh80.chung@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeLIzCtJLcpLzFFi42I5/e+xgG7ddakIg6vTlS3mHznHavH/0WtW ixu/2lgtzp/fwG6x6fE1VovLu+awWRz5389o8enBf2aLGef3MVm07j3CbnHnyXpWi+Nrwx14 PDat6mTzuHNtD5vH5iX1Hn9n7Wfx6NuyitFj+7V5zB6fN8kFsEe52WSkJqakFimk5iXnp2Tm pdsqhYa46VooKeQl5qbaKkXo+oYEKSmUJeaUAnlGBmjAwTnAPVhJ3y7BLWPlgntMBW0SFXtf t7I1MHYKdzFyckgImEicnXeLEcIWk7hwbz1bFyMXh5DAUkaJqwcXsEA4Pxglfq9vZgWpYhPQ kdj+7TgTiC0iICvx888FsA5mgYNMEv8n7WYBSQgLhEq8/3eIDcRmEVCVODvnGFicV8Ba4tSq GewQ6+QlLlw9BRbnFLCRmHgEYoEQUM2twyuZJjDyLmBkWMUokVqQXFCclJ5rmJdarlecmFtc mpeul5yfu4kRHBnPpHYwHtzlfohRgINRiYf3g4pUhBBrYllxZe4hRgkOZiUR3l1XgEK8KYmV ValF+fFFpTmpxYcYTYEOm8gsJZqcD4zavJJ4QxNzE3NjAwtzS0sTIyVx3sbZz8KFBNITS1Kz U1MLUotg+pg4OKUaGCuO/1k+10d+T9a6w+eUHd5dK5ync6D566L1606tyJy/MSnu6W7nlnOn pvr1unW7Rc5pT3n46teXDKPeTw3z2L9ovQ2UEHbgiHj591+w9YFNejobm0rnPTJ6fja8rOj9 hFnCFhvaH8W4BmumzfspIj/nrHHxk3Vd4eq7OZ91TS7isnnMs9CktlaJpTgj0VCLuag4EQDv LYpwogIAAA== X-MTR: 20000000000000000@CPGS X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161102_232219_040967_9595114A X-CRM114-Status: GOOD ( 14.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, ulf.hansson@linaro.org, linux-samsung-soc@vger.kernel.org, heiko@sntech.de, shawn.lin@rock-chips.com, linux-kernel@vger.kernel.org, krzk@kernel.org, Jaehoon Chung , linux-rockchip@lists.infradead.org, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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 --- 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 16df93b..df151c8 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;