From patchwork Tue Jun 21 01:13:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 9189123 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 DAD066075F for ; Tue, 21 Jun 2016 01:13:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C32E327C4B for ; Tue, 21 Jun 2016 01:13:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B662327F17; Tue, 21 Jun 2016 01:13:34 +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 09EA927C4B for ; Tue, 21 Jun 2016 01:13:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752592AbcFUBNb (ORCPT ); Mon, 20 Jun 2016 21:13:31 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:45297 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754588AbcFUBNa (ORCPT ); Mon, 20 Jun 2016 21:13:30 -0400 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O93023WKKQFNY20@mailout3.samsung.com> for linux-mmc@vger.kernel.org; Tue, 21 Jun 2016 10:13:27 +0900 (KST) Received: from epcpsbgm1new.samsung.com ( [172.20.52.113]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 6D.DC.05161.7B498675; Tue, 21 Jun 2016 10:13:27 +0900 (KST) X-AuditID: cbfee68f-f79476d000001429-a5-576894b7dae7 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 8D.48.02101.7B498675; Tue, 21 Jun 2016 10:13:27 +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 <0O93009PCKQFTN40@mmp1.samsung.com>; Tue, 21 Jun 2016 10:13:27 +0900 (KST) From: Jaehoon Chung To: linux-mmc@vger.kernel.org Cc: ulf.hansson@linaro.org, adrian.hunter@intel.com, shawn.lin@rock-chips.com, wsa+renesas@sang-engineering.com, Jaehoon Chung Subject: [PATCH v2] mmc: host: use the defined function to check whether card is removable Date: Tue, 21 Jun 2016 10:13:26 +0900 Message-id: <1466471606-3909-1-git-send-email-jh80.chung@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrILMWRmVeSWpSXmKPExsWyRsSkUHf7lIxwg7lTLC1OPlnDZnHjVxur xZH//YwWd56sZ7U4vjbcou+cuwObx+I9L5k87lzbw+bxd9Z+Fo++LasYPZ4tXM/i8XmTXABb FJdNSmpOZllqkb5dAlfG969nmAp2aldsv/CdqYFxjkoXIyeHhICJxKKDZ9ghbDGJC/fWs3Ux cnEICaxglFh3ZwZzFyMHWNGWPUEQ8aWMEu9XPWCGcH4wSjx98IYVpJtNQEdi+7fjTCC2iICs xM8/F9hAbGaBmYwSHzbygtjCAjESfb/+gNWwCKhKzGjZxghi8wq4Smw/uYQZ4go5iZPHJrOC LJAQaGaXWNzcxQbRICDxbfIhFoiLZCU2HYCql5Q4uOIGywRGwQWMDKsYRVMLkguKk9KLjPWK E3OLS/PS9ZLzczcxAkP29L9n/TsY7x6wPsQow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622/9s5dmbP+mP0IxYg9t3IlRuf5haePinwtnC h/yuerfYnh5YyhJw4lNA2MG+OCWW4oxEQy3mouJEAM3iWZehAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected 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 In linux/mmc/host.h, mmc_card_is_removable() is already defined. It should be maintainted more easier than now. Signed-off-by: Jaehoon Chung Reviewed-by: Shawn Lin --- Changelog V2: - Added the missed host controller (sdhci-of-at91.c) drivers/mmc/host/dw_mmc.c | 3 +-- drivers/mmc/host/mxcmmc.c | 2 +- drivers/mmc/host/sdhci-bcm-kona.c | 6 +++--- drivers/mmc/host/sdhci-of-at91.c | 2 +- drivers/mmc/host/sdhci-st.c | 2 +- drivers/mmc/host/sdhci.c | 6 +++--- drivers/mmc/host/tmio_mmc_pio.c | 2 +- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 2cc6123..8012858 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -1451,8 +1451,7 @@ static int dw_mci_get_cd(struct mmc_host *mmc) int gpio_cd = mmc_gpio_get_cd(mmc); /* Use platform get_cd function, else try onboard card detect */ - if ((mmc->caps & MMC_CAP_NEEDS_POLL) || - (mmc->caps & MMC_CAP_NONREMOVABLE)) + if ((mmc->caps & MMC_CAP_NEEDS_POLL) || !mmc_card_is_removable(mmc)) present = 1; else if (gpio_cd >= 0) present = gpio_cd; diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c index 3d1ea5e..fb3ca82 100644 --- a/drivers/mmc/host/mxcmmc.c +++ b/drivers/mmc/host/mxcmmc.c @@ -1065,7 +1065,7 @@ static int mxcmci_probe(struct platform_device *pdev) if (pdata) dat3_card_detect = pdata->dat3_card_detect; - else if (!(mmc->caps & MMC_CAP_NONREMOVABLE) + else if (mmc_card_is_removable(mmc) && !of_property_read_bool(pdev->dev.of_node, "cd-gpios")) dat3_card_detect = true; diff --git a/drivers/mmc/host/sdhci-bcm-kona.c b/drivers/mmc/host/sdhci-bcm-kona.c index 00a8a40..1d64712 100644 --- a/drivers/mmc/host/sdhci-bcm-kona.c +++ b/drivers/mmc/host/sdhci-bcm-kona.c @@ -264,12 +264,12 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev) } dev_dbg(dev, "non-removable=%c\n", - (host->mmc->caps & MMC_CAP_NONREMOVABLE) ? 'Y' : 'N'); + mmc_card_is_removable(host->mmc) ? 'N' : 'Y'); dev_dbg(dev, "cd_gpio %c, wp_gpio %c\n", (mmc_gpio_get_cd(host->mmc) != -ENOSYS) ? 'Y' : 'N', (mmc_gpio_get_ro(host->mmc) != -ENOSYS) ? 'Y' : 'N'); - if (host->mmc->caps & MMC_CAP_NONREMOVABLE) + if (!mmc_card_is_removable(host->mmc)) host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION; dev_dbg(dev, "is_8bit=%c\n", @@ -288,7 +288,7 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev) } /* if device is eMMC, emulate card insert right here */ - if (host->mmc->caps & MMC_CAP_NONREMOVABLE) { + if (!mmc_card_is_removable(host->mmc)) { ret = sdhci_bcm_kona_sd_card_emulate(host, 1); if (ret) { dev_err(dev, diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c index d4cef71..a9b7fc0 100644 --- a/drivers/mmc/host/sdhci-of-at91.c +++ b/drivers/mmc/host/sdhci-of-at91.c @@ -288,7 +288,7 @@ static int sdhci_at91_probe(struct platform_device *pdev) * Disable SDHCI_QUIRK_BROKEN_CARD_DETECTION to be sure nobody tries * to enable polling via device tree with broken-cd property. */ - if (!(host->mmc->caps & MMC_CAP_NONREMOVABLE) && + if (mmc_card_is_removable(host->mmc) && mmc_gpio_get_cd(host->mmc) < 0) { host->mmc->caps |= MMC_CAP_NEEDS_POLL; host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION; diff --git a/drivers/mmc/host/sdhci-st.c b/drivers/mmc/host/sdhci-st.c index 320e1c2..c95ba83 100644 --- a/drivers/mmc/host/sdhci-st.c +++ b/drivers/mmc/host/sdhci-st.c @@ -183,7 +183,7 @@ static void st_mmcss_cconfig(struct device_node *np, struct sdhci_host *host) writel_relaxed(cconf2, host->ioaddr + ST_MMC_CCONFIG_REG_2); - if (mhost->caps & MMC_CAP_NONREMOVABLE) + if (!mmc_card_is_removable(mhost)) cconf3 |= ST_MMC_CCONFIG_EMMC_SLOT_TYPE; else /* CARD _D ET_CTRL */ diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 040af1b..b965461 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -117,7 +117,7 @@ static void sdhci_set_card_detection(struct sdhci_host *host, bool enable) u32 present; if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) || - (host->mmc->caps & MMC_CAP_NONREMOVABLE)) + !mmc_card_is_removable(host->mmc)) return; if (enable) { @@ -1617,7 +1617,7 @@ static int sdhci_get_cd(struct mmc_host *mmc) return 0; /* If nonremovable, assume that the card is always present. */ - if (host->mmc->caps & MMC_CAP_NONREMOVABLE) + if (!mmc_card_is_removable(host->mmc)) return 1; /* @@ -3089,7 +3089,7 @@ int sdhci_add_host(struct sdhci_host *host) mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED; if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) && - !(mmc->caps & MMC_CAP_NONREMOVABLE) && + mmc_card_is_removable(mmc) && mmc_gpio_get_cd(host->mmc) < 0) mmc->caps |= MMC_CAP_NEEDS_POLL; diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c index f44e2ab..92467ef 100644 --- a/drivers/mmc/host/tmio_mmc_pio.c +++ b/drivers/mmc/host/tmio_mmc_pio.c @@ -1086,7 +1086,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host, _host->native_hotplug = !(pdata->flags & TMIO_MMC_USE_GPIO_CD || mmc->caps & MMC_CAP_NEEDS_POLL || - mmc->caps & MMC_CAP_NONREMOVABLE || + !mmc_card_is_removable(mmc) || mmc->slot.cd_irq >= 0); if (tmio_mmc_clk_enable(_host) < 0) {