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: 9410377 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 4013E60573 for ; Thu, 3 Nov 2016 06:23:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31DCC288D9 for ; Thu, 3 Nov 2016 06:23:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2501E2A4D3; Thu, 3 Nov 2016 06:23:32 +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=unavailable 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 B5631288D9 for ; Thu, 3 Nov 2016 06:23:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754257AbcKCGVz (ORCPT ); Thu, 3 Nov 2016 02:21:55 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:32999 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754186AbcKCGVx (ORCPT ); Thu, 3 Nov 2016 02:21:53 -0400 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 Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, ulf.hansson@linaro.org, robh+dt@kernel.org, krzk@kernel.org, heiko@sntech.de, shawn.lin@rock-chips.com, Jaehoon Chung 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 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@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 --- 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;