Maemo patchset 20101501+0m5
[h-e-n] / drivers / mmc / core / sd.c
index 26fc098..032945c 100644 (file)
@@ -558,8 +558,6 @@ static void mmc_sd_detect(struct mmc_host *host)
        }
 }
 
-#ifdef CONFIG_MMC_UNSAFE_RESUME
-
 /*
  * Suspend callback from host.
  */
@@ -602,20 +600,60 @@ static void mmc_sd_resume(struct mmc_host *host)
 
 }
 
-#else
+static void mmc_sd_power_restore(struct mmc_host *host)
+{
+       host->card->state &= ~MMC_STATE_HIGHSPEED;
+       mmc_claim_host(host);
+       mmc_sd_init_card(host, host->ocr, host->card);
+       mmc_release_host(host);
+}
 
-#define mmc_sd_suspend NULL
-#define mmc_sd_resume NULL
+#ifdef CONFIG_MMC_UNSAFE_RESUME
 
-#endif
+static const struct mmc_bus_ops mmc_sd_ops = {
+       .remove = mmc_sd_remove,
+       .detect = mmc_sd_detect,
+       .suspend = mmc_sd_suspend,
+       .resume = mmc_sd_resume,
+       .power_restore = mmc_sd_power_restore,
+};
+
+static void mmc_sd_attach_bus_ops(struct mmc_host *host)
+{
+       mmc_attach_bus(host, &mmc_sd_ops);
+}
+
+#else
 
 static const struct mmc_bus_ops mmc_sd_ops = {
        .remove = mmc_sd_remove,
        .detect = mmc_sd_detect,
+       .suspend = NULL,
+       .resume = NULL,
+       .power_restore = mmc_sd_power_restore,
+};
+
+static const struct mmc_bus_ops mmc_sd_ops_unsafe = {
+       .remove = mmc_sd_remove,
+       .detect = mmc_sd_detect,
        .suspend = mmc_sd_suspend,
        .resume = mmc_sd_resume,
+       .power_restore = mmc_sd_power_restore,
 };
 
+static void mmc_sd_attach_bus_ops(struct mmc_host *host)
+{
+       const struct mmc_bus_ops *bus_ops;
+
+       if (host->caps & MMC_CAP_NONREMOVABLE)
+               bus_ops = &mmc_sd_ops_unsafe;
+       else
+               bus_ops = &mmc_sd_ops;
+       mmc_attach_bus(host, bus_ops);
+}
+
+#endif
+
 /*
  * Starting point for SD card init.
  */
@@ -626,7 +664,7 @@ int mmc_attach_sd(struct mmc_host *host, u32 ocr)
        BUG_ON(!host);
        WARN_ON(!host->claimed);
 
-       mmc_attach_bus(host, &mmc_sd_ops);
+       mmc_sd_attach_bus_ops(host);
 
        /*
         * We need to get OCR a different way for SPI.