diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index e2adbe0216cc..65d6c0d566de 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -2461,7 +2461,6 @@ static int _mmc_blk_suspend(struct mmc_card *card) struct mmc_blk_data *md = mmc_get_drvdata(card); if (md) { - pm_runtime_get_sync(&card->dev); mmc_queue_suspend(&md->queue); list_for_each_entry(part_md, &md->part, part) { mmc_queue_suspend(&part_md->queue); @@ -2496,7 +2495,6 @@ static int mmc_blk_resume(struct mmc_card *card) list_for_each_entry(part_md, &md->part, part) { mmc_queue_resume(&part_md->queue); } - pm_runtime_put(&card->dev); } return 0; } diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 98e9eb0f6643..be163d65cd23 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1511,18 +1511,12 @@ out: */ static int mmc_suspend(struct mmc_host *host) { - int err; - - err = _mmc_suspend(host, true); - if (!err) { - pm_runtime_disable(&host->card->dev); - pm_runtime_set_suspended(&host->card->dev); - } - - return err; + return _mmc_suspend(host, true); } /* + * Resume callback from host. + * * This function tries to determine if the same card is still present * and, if so, restore all state to it. */ @@ -1547,26 +1541,6 @@ out: return err; } -/* - * Shutdown callback - */ -static int mmc_shutdown(struct mmc_host *host) -{ - int err = 0; - - /* - * In a specific case for poweroff notify, we need to resume the card - * before we can shutdown it properly. - */ - if (mmc_can_poweroff_notify(host->card) && - !(host->caps2 & MMC_CAP2_FULL_PWR_CYCLE)) - err = _mmc_resume(host); - - if (!err) - err = _mmc_suspend(host, false); - - return err; -} /* * Callback for resume. @@ -1581,6 +1555,24 @@ static int mmc_resume(struct mmc_host *host) pm_runtime_mark_last_busy(&host->card->dev); } pm_runtime_enable(&host->card->dev); +} +/* + * Shutdown callback + */ +static int mmc_shutdown(struct mmc_host *host) +{ + int err = 0; + + /* + * In a specific case for poweroff notify, we need to resume the card + * before we can shutdown it properly. + */ + if (mmc_can_poweroff_notify(host->card) && + !(host->caps2 & MMC_CAP2_FULL_PWR_CYCLE)) + err = mmc_resume(host); + + if (!err) + err = _mmc_suspend(host, false); return err; } diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 8a4dfbbfbb72..f291ad7bf68b 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -1116,30 +1116,6 @@ static void mmc_sd_detect(struct mmc_host *host) } } -static int _mmc_sd_suspend(struct mmc_host *host) -{ - int err = 0; - - BUG_ON(!host); - BUG_ON(!host->card); - - mmc_claim_host(host); - - if (mmc_card_suspended(host->card)) - goto out; - - if (!mmc_host_is_spi(host)) - err = mmc_deselect_cards(host); - host->card->state &= ~MMC_STATE_HIGHSPEED; - if (!err) { - mmc_power_off(host); - mmc_card_set_suspended(host->card); - } - -out: - mmc_release_host(host); - return err; -} /* * Callback for suspend @@ -1148,13 +1124,25 @@ 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); - } + BUG_ON(!host); + BUG_ON(!host->card); + + mmc_claim_host(host); + + if (mmc_card_suspended(host->card)) + goto out; + if (!mmc_host_is_spi(host)) + err = mmc_deselect_cards(host); + + host->card->state &= ~MMC_STATE_HIGHSPEED; + if (!err) { + mmc_power_off(host); + mmc_card_set_suspended(host->card); + } +out: + mmc_release_host(host); + return err; - return err; } /* @@ -1196,6 +1184,8 @@ static int mmc_sd_resume(struct mmc_host *host) } pm_runtime_enable(&host->card->dev); +out: + mmc_release_host(host); return err; } @@ -1209,7 +1199,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);