mmc: dw_mmc: check the "present" variable before checking flags
authorJaehoon Chung <jh80.chung@samsung.com>
Thu, 24 Nov 2016 11:04:40 +0000 (20:04 +0900)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 5 Dec 2016 09:31:15 +0000 (10:31 +0100)
Before checking flags, it has to check "present" variable.
Otherwise, flags should be cleared everytime.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/dw_mmc.c

index 0aa4bcd..c0e96ad 100644 (file)
@@ -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);