public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: Johan Rudholm <johan.rudholm@axis.com>
To: linux-mmc@vger.kernel.org, Chris Ball <chris@printf.net>,
	Ulf Hansson <ulf.hansson@linaro.org>
Cc: "Adrian Hunter" <adrian.hunter@intel.com>,
	"Guennadi Liakhovetski" <g.liakhovetski@gmx.de>,
	"David Lanzendörfer" <david.lanzendoerfer@o2s.ch>,
	"Jesper Nilsson" <jespern@axis.com>,
	"Johan Rudholm" <johanru@axis.com>
Subject: [PATCH v5 2/2] mmc: core: let hw_reset default to power_cycle
Date: Fri, 28 Nov 2014 16:56:54 +0100	[thread overview]
Message-ID: <1417190214-32181-3-git-send-email-johanru@axis.com> (raw)
In-Reply-To: <1417190214-32181-1-git-send-email-johanru@axis.com>

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@axis.com>
---
 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


      parent reply	other threads:[~2014-11-28 15:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-28 15:56 [PATCH v5 0/2] mmc: core: hw_reset changes Johan Rudholm
2014-11-28 15:56 ` [PATCH v5 1/2] mmc: core: refactor the hw_reset routines Johan Rudholm
2014-11-28 15:56 ` Johan Rudholm [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1417190214-32181-3-git-send-email-johanru@axis.com \
    --to=johan.rudholm@axis.com \
    --cc=adrian.hunter@intel.com \
    --cc=chris@printf.net \
    --cc=david.lanzendoerfer@o2s.ch \
    --cc=g.liakhovetski@gmx.de \
    --cc=jespern@axis.com \
    --cc=johanru@axis.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox