Merge tag 'mmc-updates-for-3.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel...
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / mmc / core / bus.c
index 9d5c711..704bf66 100644 (file)
@@ -122,15 +122,39 @@ static int mmc_bus_remove(struct device *dev)
        return 0;
 }
 
+static void mmc_bus_shutdown(struct device *dev)
+{
+       struct mmc_driver *drv = to_mmc_driver(dev->driver);
+       struct mmc_card *card = mmc_dev_to_card(dev);
+       struct mmc_host *host = card->host;
+       int ret;
+
+       if (dev->driver && drv->shutdown)
+               drv->shutdown(card);
+
+       if (host->bus_ops->shutdown) {
+               ret = host->bus_ops->shutdown(host);
+               if (ret)
+                       pr_warn("%s: error %d during shutdown\n",
+                               mmc_hostname(host), ret);
+       }
+}
+
 #ifdef CONFIG_PM_SLEEP
 static int mmc_bus_suspend(struct device *dev)
 {
        struct mmc_driver *drv = to_mmc_driver(dev->driver);
        struct mmc_card *card = mmc_dev_to_card(dev);
-       int ret = 0;
+       struct mmc_host *host = card->host;
+       int ret;
 
-       if (dev->driver && drv->suspend)
+       if (dev->driver && drv->suspend) {
                ret = drv->suspend(card);
+               if (ret)
+                       return ret;
+       }
+
+       ret = host->bus_ops->suspend(host);
        return ret;
 }
 
@@ -138,10 +162,17 @@ static int mmc_bus_resume(struct device *dev)
 {
        struct mmc_driver *drv = to_mmc_driver(dev->driver);
        struct mmc_card *card = mmc_dev_to_card(dev);
-       int ret = 0;
+       struct mmc_host *host = card->host;
+       int ret;
+
+       ret = host->bus_ops->resume(host);
+       if (ret)
+               pr_warn("%s: error %d during resume (card was removed?)\n",
+                       mmc_hostname(host), ret);
 
        if (dev->driver && drv->resume)
                ret = drv->resume(card);
+
        return ret;
 }
 #endif
@@ -151,15 +182,25 @@ static int mmc_bus_resume(struct device *dev)
 static int mmc_runtime_suspend(struct device *dev)
 {
        struct mmc_card *card = mmc_dev_to_card(dev);
+       struct mmc_host *host = card->host;
+       int ret = 0;
+
+       if (host->bus_ops->runtime_suspend)
+               ret = host->bus_ops->runtime_suspend(host);
 
-       return mmc_power_save_host(card->host);
+       return ret;
 }
 
 static int mmc_runtime_resume(struct device *dev)
 {
        struct mmc_card *card = mmc_dev_to_card(dev);
+       struct mmc_host *host = card->host;
+       int ret = 0;
+
+       if (host->bus_ops->runtime_resume)
+               ret = host->bus_ops->runtime_resume(host);
 
-       return mmc_power_restore_host(card->host);
+       return ret;
 }
 
 static int mmc_runtime_idle(struct device *dev)
@@ -182,6 +223,7 @@ static struct bus_type mmc_bus_type = {
        .uevent         = mmc_bus_uevent,
        .probe          = mmc_bus_probe,
        .remove         = mmc_bus_remove,
+       .shutdown       = mmc_bus_shutdown,
        .pm             = &mmc_bus_pm_ops,
 };