From patchwork Thu Jan 16 12:48:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 23271 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f71.google.com (mail-yh0-f71.google.com [209.85.213.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E9CE0202FA for ; Thu, 16 Jan 2014 12:52:34 +0000 (UTC) Received: by mail-yh0-f71.google.com with SMTP id f10sf5302739yha.10 for ; Thu, 16 Jan 2014 04:52:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=ggR/12qlnFdZnkLX+MDRNoizis7X9y1tJBkNChNSU9s=; b=O18+beDmzLG45YLrertErZPPmbsSMcnK9mh6emYYeNnGsvcVY0P1fCwSb3BGmpKcDj H839Q4zzdDv9zbH+zhj1XECrwvhcv4Cj1SdPkAXjpZynjKTJ1BIeaxGrCSDvTdZDev5f st50aOL79X1OoD+lNJxrm3wZVmWoaRYYBQkuy1I12BlVyZc+EQuP2V4tC5GcaLj8DsFh zc2GJRf7ZKcFIofaHa6tKj2ryhG4kGtpiZgDKMLsr3oS5Tm9SK56Wkcjm+C5NhM4CjfA lkdT6Zl5TgivIS6Gy4YT2TUBhW3+LeX/PxSfTZutE5Jx/k9/lslalKUJWjyCVUGQg5Hd rUzA== X-Gm-Message-State: ALoCoQnsBWWOQbfD6rcd5J8k8uZtk5ceBzAdl7WCW5QUl/l3/EzqE6B11Jg92Q4ot1ZEyvt0Yby1 X-Received: by 10.58.206.47 with SMTP id ll15mr3474129vec.28.1389876754155; Thu, 16 Jan 2014 04:52:34 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.132.231 with SMTP id ox7ls934759qeb.49.gmail; Thu, 16 Jan 2014 04:52:34 -0800 (PST) X-Received: by 10.52.230.35 with SMTP id sv3mr2013185vdc.27.1389876754081; Thu, 16 Jan 2014 04:52:34 -0800 (PST) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id w6si3323020vcz.83.2014.01.16.04.52.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 16 Jan 2014 04:52:34 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id hu8so977774vcb.1 for ; Thu, 16 Jan 2014 04:52:34 -0800 (PST) X-Received: by 10.58.4.138 with SMTP id k10mr6806074vek.8.1389876754007; Thu, 16 Jan 2014 04:52:34 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp344459ved; Thu, 16 Jan 2014 04:52:33 -0800 (PST) X-Received: by 10.66.121.68 with SMTP id li4mr9836260pab.33.1389876752710; Thu, 16 Jan 2014 04:52:32 -0800 (PST) Received: from mail-pb0-f51.google.com (mail-pb0-f51.google.com [209.85.160.51]) by mx.google.com with ESMTPS id eb3si7001859pbd.137.2014.01.16.04.52.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 16 Jan 2014 04:52:32 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.51 is neither permitted nor denied by best guess record for domain of zhangfei.gao@linaro.org) client-ip=209.85.160.51; Received: by mail-pb0-f51.google.com with SMTP id rp16so2608497pbb.24 for ; Thu, 16 Jan 2014 04:52:32 -0800 (PST) X-Received: by 10.68.137.195 with SMTP id qk3mr5845344pbb.9.1389876752267; Thu, 16 Jan 2014 04:52:32 -0800 (PST) Received: from localhost.localdomain ([124.73.90.72]) by mx.google.com with ESMTPSA id by1sm15026015pbd.25.2014.01.16.04.51.20 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 16 Jan 2014 04:52:31 -0800 (PST) From: Zhangfei Gao To: Russell King - ARM Linux , Kevin Hilman , Sachin Kamat , Chris Ball , Arnd Bergmann , Mike Turquette , Jaehoon Chung , Seungwon Jeon Cc: linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, patches@linaro.org, Zhangfei Gao Subject: [PATCH] mmc: dw_mmc: fix dw_mci_get_cd Date: Thu, 16 Jan 2014 20:48:47 +0800 Message-Id: <1389876527-13498-1-git-send-email-zhangfei.gao@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1389839502-13046-1-git-send-email-zhangfei.gao@linaro.org> References: <1389839502-13046-1-git-send-email-zhangfei.gao@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: zhangfei.gao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Introduced from commit bf626e5550f24aec24975a0e85ad8e572ca76a6b CDETECT is ignored since negated return value of mmc_gpio_get_cd(mmc) can not be checked by IS_ERR_VALUE. Add spin_lock_bh(&host->lock) for atomic accessing DW_MMC_CARD_PRESENT, otherwise sd detect may occasionally fail. Signed-off-by: Zhangfei Gao Reported-by: Kevin Hilman Reviewed-by: Sachin Kamat Tested-by: Sachin Kamat --- drivers/mmc/host/dw_mmc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index a776f24f4311..55cd110a49c4 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -1033,7 +1033,8 @@ static int dw_mci_get_cd(struct mmc_host *mmc) int present; struct dw_mci_slot *slot = mmc_priv(mmc); struct dw_mci_board *brd = slot->host->pdata; - int gpio_cd = !mmc_gpio_get_cd(mmc); + struct dw_mci *host = slot->host; + int gpio_cd = mmc_gpio_get_cd(mmc); /* Use platform get_cd function, else try onboard card detect */ if (brd->quirks & DW_MCI_QUIRK_BROKEN_CARD_DETECTION) @@ -1041,11 +1042,12 @@ static int dw_mci_get_cd(struct mmc_host *mmc) else if (brd->get_cd) present = !brd->get_cd(slot->id); else if (!IS_ERR_VALUE(gpio_cd)) - present = !!gpio_cd; + present = gpio_cd; else present = (mci_readl(slot->host, CDETECT) & (1 << slot->id)) == 0 ? 1 : 0; + spin_lock_bh(&host->lock); if (present) { set_bit(DW_MMC_CARD_PRESENT, &slot->flags); dev_dbg(&mmc->class_dev, "card is present\n"); @@ -1053,6 +1055,7 @@ static int dw_mci_get_cd(struct mmc_host *mmc) clear_bit(DW_MMC_CARD_PRESENT, &slot->flags); dev_dbg(&mmc->class_dev, "card is not present\n"); } + spin_unlock_bh(&host->lock); return present; } @@ -2081,7 +2084,7 @@ static int dw_mci_of_get_wp_gpio(struct device *dev, u8 slot) return gpio; } -/* find the cd gpio for a given slot; or -1 if none specified */ +/* find the cd gpio for a given slot */ static void dw_mci_of_get_cd_gpio(struct device *dev, u8 slot, struct mmc_host *mmc) { @@ -2411,6 +2414,9 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) if (of_find_property(np, "caps2-mmc-hs200-1_2v", NULL)) pdata->caps2 |= MMC_CAP2_HS200_1_2V_SDR; + if (of_get_property(np, "cd-inverted", NULL)) + pdata->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; + return pdata; }