diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index b22eff80a95e12381b1c952287c9fd0e8614ec5d..7f5dc26865de7b31932e362f97308c0d4d81d71e 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -1510,20 +1511,26 @@ static int _mmc_suspend(struct mmc_host *host, bool is_suspend) } /* - * Suspend callback from host. + * Suspend callback */ static int mmc_suspend(struct mmc_host *host) { - return _mmc_suspend(host, true); + int err; + + err = _mmc_suspend(host, true); + if (!err) { + pm_runtime_disable(&host->card->dev); + pm_runtime_set_suspended(&host->card->dev); + } + + return err; } /* - * Resume callback from host. - * * This function tries to determine if the same card is still present * and, if so, restore all state to it. */ -static int mmc_resume(struct mmc_host *host) +static int _mmc_resume(struct mmc_host *host) { int err = 0; @@ -1557,7 +1564,7 @@ static int mmc_shutdown(struct mmc_host *host) */ if (mmc_can_poweroff_notify(host->card) && !(host->caps2 & MMC_CAP2_FULL_PWR_CYCLE)) - err = mmc_resume(host); + err = _mmc_resume(host); if (!err) err = _mmc_suspend(host, false); @@ -1565,6 +1572,21 @@ static int mmc_shutdown(struct mmc_host *host) return err; } +/* + * Callback for resume. + */ +static int mmc_resume(struct mmc_host *host) +{ + int err; + + err = _mmc_resume(host); + pm_runtime_set_active(&host->card->dev); + pm_runtime_mark_last_busy(&host->card->dev); + pm_runtime_enable(&host->card->dev); + + return err; +} + /* * Callback for runtime_suspend. */ @@ -1575,7 +1597,7 @@ static int mmc_runtime_suspend(struct mmc_host *host) if (!(host->caps & MMC_CAP_AGGRESSIVE_PM)) return 0; - err = mmc_suspend(host); + err = _mmc_suspend(host, true); if (err) pr_err("%s: error %d doing aggessive suspend\n", mmc_hostname(host), err); @@ -1593,7 +1615,7 @@ static int mmc_runtime_resume(struct mmc_host *host) if (!(host->caps & MMC_CAP_AGGRESSIVE_PM)) return 0; - err = mmc_resume(host); + err = _mmc_resume(host); if (err) pr_err("%s: error %d doing aggessive resume\n", mmc_hostname(host), err); diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 7b2854009e39cf8f65d12f42e3f1ca4c756f0b21..447fa8e9f322f805907b65042a04a721053a9534 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -1067,10 +1068,7 @@ static void mmc_sd_detect(struct mmc_host *host) } } -/* - * Suspend callback from host. - */ -static int mmc_sd_suspend(struct mmc_host *host) +static int _mmc_sd_suspend(struct mmc_host *host) { int err = 0; @@ -1096,12 +1094,26 @@ static int mmc_sd_suspend(struct mmc_host *host) } /* - * Resume callback from host. - * + * Callback for suspend + */ +static int mmc_sd_suspend(struct mmc_host *host) +{ + int err; + + err = _mmc_sd_suspend(host); + if (!err) { + pm_runtime_disable(&host->card->dev); + pm_runtime_set_suspended(&host->card->dev); + } + + return err; +} + +/* * This function tries to determine if the same card is still present * and, if so, restore all state to it. */ -static int mmc_sd_resume(struct mmc_host *host) +static int _mmc_sd_resume(struct mmc_host *host) { int err = 0; @@ -1122,6 +1134,21 @@ static int mmc_sd_resume(struct mmc_host *host) return err; } +/* + * Callback for resume + */ +static int mmc_sd_resume(struct mmc_host *host) +{ + int err; + + err = _mmc_sd_resume(host); + pm_runtime_set_active(&host->card->dev); + pm_runtime_mark_last_busy(&host->card->dev); + pm_runtime_enable(&host->card->dev); + + return err; +} + /* * Callback for runtime_suspend. */ @@ -1132,7 +1159,7 @@ static int mmc_sd_runtime_suspend(struct mmc_host *host) if (!(host->caps & MMC_CAP_AGGRESSIVE_PM)) return 0; - err = mmc_sd_suspend(host); + err = _mmc_sd_suspend(host); if (err) pr_err("%s: error %d doing aggessive suspend\n", mmc_hostname(host), err); @@ -1150,7 +1177,7 @@ static int mmc_sd_runtime_resume(struct mmc_host *host) if (!(host->caps & MMC_CAP_AGGRESSIVE_PM)) return 0; - err = mmc_sd_resume(host); + err = _mmc_sd_resume(host); if (err) pr_err("%s: error %d doing aggessive resume\n", mmc_hostname(host), err);