From bbe76701c2dcf0e46273efbea6b9979b891b6662 Mon Sep 17 00:00:00 2001 From: Ulf Hansson Date: Thu, 13 Oct 2011 16:03:58 +0200 Subject: [PATCH] --- yaml --- r: 270305 b: refs/heads/master c: b6ad726e3fe69e1ff3c3b2ad272ba3e4c376cd6a h: refs/heads/master i: 270303: 4bb9aa64e948f67442b5b7868a7d06815f457248 v: v3 --- [refs] | 2 +- trunk/drivers/mmc/core/core.c | 42 ++++++++++++++++++++++------------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/[refs] b/[refs] index 51cc0174f625..8f28a4cf5f5a 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b4625dab2c618eb87e177761dda3182b4cfaa604 +refs/heads/master: b6ad726e3fe69e1ff3c3b2ad272ba3e4c376cd6a diff --git a/trunk/drivers/mmc/core/core.c b/trunk/drivers/mmc/core/core.c index fe65bb377e25..5278ffb20e74 100644 --- a/trunk/drivers/mmc/core/core.c +++ b/trunk/drivers/mmc/core/core.c @@ -2294,21 +2294,33 @@ int mmc_suspend_host(struct mmc_host *host) mmc_bus_get(host); if (host->bus_ops && !host->bus_dead) { - if (host->bus_ops->suspend) - err = host->bus_ops->suspend(host); - if (err == -ENOSYS || !host->bus_ops->resume) { - /* - * We simply "remove" the card in this case. - * It will be redetected on resume. - */ - if (host->bus_ops->remove) - host->bus_ops->remove(host); - mmc_claim_host(host); - mmc_detach_bus(host); - mmc_power_off(host); - mmc_release_host(host); - host->pm_flags = 0; - err = 0; + + /* + * A long response time is not acceptable for device drivers + * when doing suspend. Prevent mmc_claim_host in the suspend + * sequence, to potentially wait "forever" by trying to + * pre-claim the host. + */ + if (mmc_try_claim_host(host)) { + if (host->bus_ops->suspend) + err = host->bus_ops->suspend(host); + if (err == -ENOSYS || !host->bus_ops->resume) { + /* + * We simply "remove" the card in this case. + * It will be redetected on resume. + */ + if (host->bus_ops->remove) + host->bus_ops->remove(host); + mmc_claim_host(host); + mmc_detach_bus(host); + mmc_power_off(host); + mmc_release_host(host); + host->pm_flags = 0; + err = 0; + } + mmc_do_release_host(host); + } else { + err = -EBUSY; } } mmc_bus_put(host);