From patchwork Thu Nov 24 11:04:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 9445233 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 7D4876071C for ; Thu, 24 Nov 2016 11:15:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FA7427CF5 for ; Thu, 24 Nov 2016 11:15:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6145D27D45; Thu, 24 Nov 2016 11:15:03 +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 2CA7C27CF5 for ; Thu, 24 Nov 2016 11:15:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964912AbcKXLPB (ORCPT ); Thu, 24 Nov 2016 06:15:01 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:37963 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964907AbcKXLPA (ORCPT ); Thu, 24 Nov 2016 06:15:00 -0500 Received: from epcpsbgm2new.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OH5034GM83XHCD0@mailout2.samsung.com> for linux-mmc@vger.kernel.org; Thu, 24 Nov 2016 20:04:45 +0900 (KST) X-AuditID: cbfee61b-f796f6d000004092-40-5836c94d9177 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id AA.4D.16530.D49C6385; Thu, 24 Nov 2016 20:04:45 +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 <0OH500DQD83W0G60@mmp1.samsung.com>; Thu, 24 Nov 2016 20:04:44 +0900 (KST) From: Jaehoon Chung To: linux-mmc@vger.kernel.org Cc: ulf.hansson@linaro.org, shawn.lin@rock-chips.com, Jaehoon Chung Subject: [PATCH 1/3] mmc: dw_mmc: check the "present" variable before checking flags Date: Thu, 24 Nov 2016 20:04:40 +0900 Message-id: <20161124110442.22058-1-jh80.chung@samsung.com> X-Mailer: git-send-email 2.10.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrLLMWRmVeSWpSXmKPExsVy+t9jAV3fk2YRBu+3cFjc+NXGanHkfz+j xZ0n61ktjq8Nd2DxuHNtD5vH31n7WTz6tqxi9Pi8SS6AJcrNJiM1MSW1SCE1Lzk/JTMv3VYp NMRN10JJIS8xN9VWKULXNyRISaEsMacUyDMyQAMOzgHuwUr6dgluGTO/TWIraGOvODBhJ1sD YytbFyMHh4SAiUTPP+kuRk4gU0ziwr31QGEuDiGBpYwS1740M4EkhAR+MEosORkIYrMJ6Ehs /3YcLC4iICvx888FNhCbWSBOYtHRn+wgtrBAmMTC9oWMIPNZBFQlZnWDtfIKWEss+ryEEWKX vMSFq6dYJjByL2BkWMUokVqQXFCclJ5rlJdarlecmFtcmpeul5yfu4kRHHTPpHcwHt7lfohR gINRiYe3w8QsQog1say4MvcQowQHs5IIb8dRoBBvSmJlVWpRfnxRaU5q8SFGU6D9E5mlRJPz gRGRVxJvaGJuYm5sYGFuaWlipCTO2zj7WbiQQHpiSWp2ampBahFMHxMHp1QDo5fiXXYZs18i yorq4pyWubdsjhVKd3feuuhZlVH1p2A5N3umvfQjsQ3sitl3f5p5iM+b9vKovuiR8rWhky// e67GdrdgbVUKu5VQjrDhrunBOoVa26XWzK94+m/pPKO+yI3X+Fv/XBJ8xqkepLCiWTPK7ehJ /ToT8U29fJO2vQr+sS/J8cRGJZbijERDLeai4kQAId7f6lACAAA= X-MTR: 20000000000000000@CPGS 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 Before checking flags, it has to check "present" variable. Otherwise, flags should be cleared everytime. Signed-off-by: Jaehoon Chung --- drivers/mmc/host/dw_mmc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index d400afc..c6cc618 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -1536,7 +1536,8 @@ static int dw_mci_get_cd(struct mmc_host *mmc) spin_lock_bh(&host->lock); if (present && !test_and_set_bit(DW_MMC_CARD_PRESENT, &slot->flags)) dev_dbg(&mmc->class_dev, "card is present\n"); - else if (!test_and_clear_bit(DW_MMC_CARD_PRESENT, &slot->flags)) + else if (!present && + !test_and_clear_bit(DW_MMC_CARD_PRESENT, &slot->flags)) dev_dbg(&mmc->class_dev, "card is not present\n"); spin_unlock_bh(&host->lock);