linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arik Nemtsov <arik@wizery.com>
To: linux-mmc@vger.kernel.org
Cc: Chris Ball <cjb@laptop.org>, Ido Yariv <ido@wizery.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Arik Nemtsov <arik@wizery.com>
Subject: [PATCH v2] mmc: core: claim host during mmc_power_off on suspend
Date: Wed, 18 Jan 2012 15:38:51 +0200	[thread overview]
Message-ID: <1326893931-14500-1-git-send-email-arik@wizery.com> (raw)

Make sure the host is claimed in all calls of mmc_power_off() during
suspend. In addition make sure mmc_power_off() isn't called twice in
some suspend flows.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
Signed-off-by: Ido Yariv <ido@wizery.com>
---
v1->2: use mmc_try_claim_host(), as suggested by Adrian

 drivers/mmc/core/core.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index f545a3e..dd633d6 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2360,6 +2360,7 @@ EXPORT_SYMBOL(mmc_cache_ctrl);
 int mmc_suspend_host(struct mmc_host *host)
 {
 	int err = 0;
+	bool powered_off = false;
 
 	if (host->caps & MMC_CAP_DISABLE)
 		cancel_delayed_work(&host->disable);
@@ -2411,6 +2412,7 @@ int mmc_suspend_host(struct mmc_host *host)
 				mmc_release_host(host);
 				host->pm_flags = 0;
 				err = 0;
+				powered_off = true;
 			}
 		} else {
 			err = -EBUSY;
@@ -2418,8 +2420,14 @@ int mmc_suspend_host(struct mmc_host *host)
 	}
 	mmc_bus_put(host);
 
-	if (!err && !mmc_card_keep_power(host))
-		mmc_power_off(host);
+	if (!powered_off && !err && !mmc_card_keep_power(host)) {
+		if (mmc_try_claim_host(host)) {
+			mmc_power_off(host);
+			mmc_do_release_host(host);
+		} else {
+			err = -EBUSY;
+		}
+	}
 
 out:
 	return err;
-- 
1.7.5.4


                 reply	other threads:[~2012-01-18 13:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1326893931-14500-1-git-send-email-arik@wizery.com \
    --to=arik@wizery.com \
    --cc=adrian.hunter@intel.com \
    --cc=cjb@laptop.org \
    --cc=ido@wizery.com \
    --cc=linux-mmc@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).