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);
list_for_each_entry(part_md, &md->part, part) {
mmc_queue_resume(&part_md->queue);
}
- pm_runtime_put(&card->dev);
}
return 0;
}
*/
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.
*/
return err;
}
+
+/*
+ * Callback for resume.
+ */
+static int mmc_resume(struct mmc_host *host)
+{
+ int err = 0;
+
+ if (!(host->caps & MMC_CAP_RUNTIME_RESUME)) {
+ 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);
+}
/*
* Shutdown callback
*/
*/
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);
return err;
}
-/*
- * Callback for resume.
- */
-static int mmc_resume(struct mmc_host *host)
-{
- int err = 0;
-
- if (!(host->caps & MMC_CAP_RUNTIME_RESUME)) {
- 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.
*/
}
}
-static int _mmc_sd_suspend(struct mmc_host *host)
+
+/*
+ * Callback for suspend
+ */
+static int mmc_sd_suspend(struct mmc_host *host)
{
- int err = 0;
+ int err;
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);
- }
-
+ 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
- */
-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);
- }
+ mmc_release_host(host);
+ return err;
- return err;
}
/*
}
pm_runtime_enable(&host->card->dev);
+out:
+ mmc_release_host(host);
return err;
}
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);