From patchwork Wed Jan 15 07:15:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 23221 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4B3D5206A0 for ; Wed, 15 Jan 2014 07:16:53 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id h16sf946230oag.8 for ; Tue, 14 Jan 2014 23:16:52 -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=/EewXP9t9s7zGiMG8gGIoyqE8oHvPdDCe6zWnBX1NNE=; b=kbWa5IFrO7EzXe3N5dP/BHR4FWrF2RdNkd9QyF9m3XqJtSnFzXPLtlkZLHm2JTMgRo EqJcedjendentj5DXZhPkIzkLD9NZwXVUqPAonN/R9YlvRSGIc6yg25IfzMmsCAPONVb P+pokQwftuytNaWytlEIMZHkA1YERrOUMok0/ZFYlT3ZJMev6LspTml/7WlIFoz6zv7Z zak6ALj0T7wWfI9PwKCDeLnclAXxp87oupL37JTL0r7H1w4uKjt1bEX+on2iQkLKhkPq SVNaDj4P1uzytoPG73uKPO5lerPi4PnOAl/rbsv4QHxrRfOO0HU82gbo2hDNOCfAjUL3 z2Ug== X-Gm-Message-State: ALoCoQnFSF3hiXCo0NgXegTyEWexWfbr4zthk0u4RN9j6EOjyuidln9HqyX54+IH5QYUx/P75d6+ X-Received: by 10.182.34.169 with SMTP id a9mr50803obj.49.1389770212157; Tue, 14 Jan 2014 23:16:52 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.118.233 with SMTP id kp9ls478818qeb.4.gmail; Tue, 14 Jan 2014 23:16:52 -0800 (PST) X-Received: by 10.58.205.170 with SMTP id lh10mr605961vec.18.1389770212063; Tue, 14 Jan 2014 23:16:52 -0800 (PST) Received: from mail-vb0-f42.google.com (mail-vb0-f42.google.com [209.85.212.42]) by mx.google.com with ESMTPS id mj10si1254032vcb.87.2014.01.14.23.16.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 14 Jan 2014 23:16:52 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.42 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.42; Received: by mail-vb0-f42.google.com with SMTP id i11so262511vbh.1 for ; Tue, 14 Jan 2014 23:16:52 -0800 (PST) X-Received: by 10.220.174.200 with SMTP id u8mr442090vcz.6.1389770212004; Tue, 14 Jan 2014 23:16:52 -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 ey3csp254124ved; Tue, 14 Jan 2014 23:16:51 -0800 (PST) X-Received: by 10.68.89.162 with SMTP id bp2mr638638pbb.151.1389770211094; Tue, 14 Jan 2014 23:16:51 -0800 (PST) Received: from mail-pd0-f181.google.com (mail-pd0-f181.google.com [209.85.192.181]) by mx.google.com with ESMTPS id qx4si2827391pbc.165.2014.01.14.23.16.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 14 Jan 2014 23:16:51 -0800 (PST) Received-SPF: neutral (google.com: 209.85.192.181 is neither permitted nor denied by best guess record for domain of zhangfei.gao@linaro.org) client-ip=209.85.192.181; Received: by mail-pd0-f181.google.com with SMTP id p10so746836pdj.12 for ; Tue, 14 Jan 2014 23:16:50 -0800 (PST) X-Received: by 10.66.190.198 with SMTP id gs6mr726384pac.49.1389770210654; Tue, 14 Jan 2014 23:16:50 -0800 (PST) Received: from localhost.localdomain ([124.73.90.72]) by mx.google.com with ESMTPSA id iq10sm5932707pbc.14.2014.01.14.23.16.41 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 14 Jan 2014 23:16:50 -0800 (PST) From: Zhangfei Gao To: Kevin Hilman , Chris Ball , Arnd Bergmann , Mike Turquette , Jaehoon Chung , Seungwon Jeon , Haojian Zhuang 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: Wed, 15 Jan 2014 15:15:59 +0800 Message-Id: <1389770159-21125-1-git-send-email-zhangfei.gao@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: 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.212.42 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: , Introdeced from commit b7db86adfa58b CDETECT is ingored since IS_ERR_VALUE(!mmc_gpio_get_cd(mmc)) does not work Add spin_lock_bh(&host->lock) for atomic accessing DW_MMC_CARD_PRESENT Signed-off-by: Zhangfei Gao Reported-by: Kevin Hilman --- drivers/mmc/host/dw_mmc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index a776f24f4311..9ded62c8225e 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) {