[PATCH v5 2/2] mmc: core: let hw_reset default to power_cycle

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

 



If bus_ops->hw_reset is missing, try to power cycle the card instead.

This will allow SD cards to be power cycled and re-initialized as well.
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 |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 7a17cd2..45b367d 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2254,19 +2254,23 @@ static int mmc_do_hw_reset(struct mmc_host *host, int do_init)
 		return -EINVAL;
 
 	mmc_bus_get(host);
-	if (!host->bus_ops || host->bus_dead || !host->bus_ops->hw_reset) {
+	if (!host->bus_ops || host->bus_dead) {
 		ret = -EINVAL;
 		goto out;
 	}
 
-	ret = host->bus_ops->hw_reset(host);
-	if (ret)
-		goto out;
+	if (!host->bus_ops->hw_reset) {
+		mmc_power_cycle(host, host->card->ocr);
+	} else {
+		ret = host->bus_ops->hw_reset(host);
+		if (ret)
+			goto out;
+		if (do_init)
+			mmc_set_initial_state(host);
+	}
 
-	if (do_init) {
-		mmc_set_initial_state(host);
+	if (do_init)
 		ret = host->bus_ops->power_restore(host);
-	}
 
 	pr_warn("%s: tried to reset card\n", mmc_hostname(host));
 out:
-- 
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