diff mbox

[1/3] mmc: dw_mmc: check the "present" variable before checking flags

Message ID 20161124110442.22058-1-jh80.chung@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jaehoon Chung Nov. 24, 2016, 11:04 a.m. UTC
Before checking flags, it has to check "present" variable.
Otherwise, flags should be cleared everytime.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
---
 drivers/mmc/host/dw_mmc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jaehoon Chung Nov. 28, 2016, 1:42 a.m. UTC | #1
On 11/24/2016 08:04 PM, Jaehoon Chung wrote:
> Before checking flags, it has to check "present" variable.
> Otherwise, flags should be cleared everytime.
> 
> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>

Applied on my dwmmc repository.

Best Regards,
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);
>  
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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);