[PATCH] mmc: core: make hw_reset power cycle SD-cards

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



SD-cards cannot be reset, but they can be power cycled. Power cycling
a buggy SD-card sometimes helps it get back on track.

Signed-off-by: Johan Rudholm <johanru@xxxxxxxx>
---
 drivers/mmc/core/core.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index d03a080..9171aa9 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2250,19 +2250,25 @@ static int mmc_do_hw_reset(struct mmc_host *host, int check)
 {
 	struct mmc_card *card = host->card;
 
-	if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset)
-		return -EOPNOTSUPP;
-
 	if (!card)
 		return -EINVAL;
 
-	if (!mmc_can_reset(card))
+	if (!mmc_card_sd(card) && !((host->caps & MMC_CAP_HW_RESET) &&
+							host->ops->hw_reset))
+		return -EOPNOTSUPP;
+
+	if (!mmc_card_sd(card) && !mmc_can_reset(card))
 		return -EOPNOTSUPP;
 
 	mmc_host_clk_hold(host);
 	mmc_set_clock(host, host->f_init);
 
-	host->ops->hw_reset(host);
+	if (mmc_card_sd(card))
+		mmc_power_cycle(host, card->ocr);
+	else
+		host->ops->hw_reset(host);
+
+	pr_warning("%s: reset device\n", mmc_hostname(host));
 
 	/* If the reset has happened, then a status command will fail */
 	if (check) {
-- 
1.7.2.5

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




[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux