Skip to contentSkip to conversation

mmc: dw-mmc: fix the present flags for card detect

PATCH In review Jaehoon Chung 2 participants 3 messages Aug 28, 2012 – Aug 29, 2012

Subsystems (2)
lore
Share & tools
lore

Jaehoon Chung

author maintainer
#0 lore raw

PATCH v2 5/5 mmc: dw-mmc: fix the present flags for card detect

dw_mci_get_cd() is registered to call-back function.
If call host->ops->get_cd(), host didn't set any card present flag. Then host didn't know whether card is present or not. This patch fixed them.

---
 drivers/mmc/host/dw_mmc.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
drivers/mmc/host/dw_mmc.c +5 -2
index 3642455..8a87d38 100644
@@ -909,10 +909,13 @@ static int dw_mci_get_cd(struct mmc_host *mmc)
 		present = (mci_readl(slot->host, CDETECT) & (1 << slot->id))
 			== 0 ? 1 : 0;
 
-	if (present)
+	if (present) {
+		set_bit(DW_MMC_CARD_PRESENT, &slot->flags);
 		dev_dbg(&mmc->class_dev, "card is present\n");
-	else
+	} else {
+		clear_bit(DW_MMC_CARD_PRESENT, &slot->flags);
 		dev_dbg(&mmc->class_dev, "card is not present\n");
+	}
 
 	return present;
 }
Signature · 1 line
1.7.4.1
#1 lore raw
Quoted 32 lines · Jaehoon Chung

dw_mci_get_cd() is registered to call-back function.
If call host->ops->get_cd(), host didn't set any card present flag. Then host didn't know whether card is present or not. This patch fixed them.

---
 drivers/mmc/host/dw_mmc.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
drivers/mmc/host/dw_mmc.c +5 -3
index 3642455..8a87d38 100644
@@ -909,10 +909,13 @@ static int dw_mci_get_cd(struct mmc_host *mmc)
                present = (mci_readl(slot->host, CDETECT) & (1 << slot->id))
                        == 0 ? 1 : 0;
 
-       if (present)
+       if (present) {
+               set_bit(DW_MMC_CARD_PRESENT, &slot->flags);
                dev_dbg(&mmc->class_dev, "card is present\n");
-       else
+       } else {
+               clear_bit(DW_MMC_CARD_PRESENT, &slot->flags);
                dev_dbg(&mmc->class_dev, "card is not present\n");
+       }
 
        return present;
 }
--
Quoted 1 line

1.7.4.1

Isn't this already done in dw_mci_init_slot() function and other places in the driver? I have tested with card insert/removal multiple times and did not notice any failure.

Thanks,
Thomas.

author maintainer
#2 lore raw
Quoted 30 lines · Thomas Abraham
Quoted 29 lines · Jaehoon Chung

dw_mci_get_cd() is registered to call-back function.
If call host->ops->get_cd(), host didn't set any card present flag. Then host didn't know whether card is present or not. This patch fixed them.

---
 drivers/mmc/host/dw_mmc.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
drivers/mmc/host/dw_mmc.c +5 -2
index 3642455..8a87d38 100644
@@ -909,10 +909,13 @@ static int dw_mci_get_cd(struct mmc_host *mmc)
                present = (mci_readl(slot->host, CDETECT) & (1 << slot->id))
                        == 0 ? 1 : 0;
 
-       if (present)
+       if (present) {
+               set_bit(DW_MMC_CARD_PRESENT, &slot->flags);
                dev_dbg(&mmc->class_dev, "card is present\n");
-       else
+       } else {
+               clear_bit(DW_MMC_CARD_PRESENT, &slot->flags);
                dev_dbg(&mmc->class_dev, "card is not present\n");
+       }
 
Quoted 8 lines
Quoted 4 lines
drivers/mmc/host/dw_mmc.c +0 -1
        return present;
 }
--

1.7.4.1

Isn't this already done in dw_mci_init_slot() function and other places in the driver? I have tested with card insert/removal multiple times and did not notice any failure.

In my case, use the external cd-gpio pin and use the mmc_gpio_request_cd(). In that case, if didn't insert SD-card when boot at first time, at next time host didn't recognize Sd-card.
And it's no problem that the code is placed into get_cd().

Best Regards,
Jaehoon Chung

Quoted 8 lines

Thanks,
Thomas.
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html