]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/mmc/core/sd.c
Merge branch 'tracing-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[mv-sheeva.git] / drivers / mmc / core / sd.c
index 7ad646fe077ec796da7a390c8a2a0dfe624f39b1..10b2a4d20f5a1a6b270592d6b048514126bda96a 100644 (file)
@@ -210,11 +210,11 @@ static int mmc_read_switch(struct mmc_card *card)
 
        err = mmc_sd_switch(card, 0, 0, 1, status);
        if (err) {
-               /*
-                * We all hosts that cannot perform the command
-                * to fail more gracefully
-                */
-               if (err != -EINVAL)
+               /* If the host or the card can't do the switch,
+                * fail more gracefully. */
+               if ((err != -EINVAL)
+                && (err != -ENOSYS)
+                && (err != -EFAULT))
                        goto out;
 
                printk(KERN_WARNING "%s: problem reading switch "
@@ -561,12 +561,10 @@ static void mmc_sd_detect(struct mmc_host *host)
        }
 }
 
-#ifdef CONFIG_MMC_UNSAFE_RESUME
-
 /*
  * Suspend callback from host.
  */
-static void mmc_sd_suspend(struct mmc_host *host)
+static int mmc_sd_suspend(struct mmc_host *host)
 {
        BUG_ON(!host);
        BUG_ON(!host->card);
@@ -576,6 +574,8 @@ static void mmc_sd_suspend(struct mmc_host *host)
                mmc_deselect_cards(host);
        host->card->state &= ~MMC_STATE_HIGHSPEED;
        mmc_release_host(host);
+
+       return 0;
 }
 
 /*
@@ -584,7 +584,7 @@ static void mmc_sd_suspend(struct mmc_host *host)
  * This function tries to determine if the same card is still present
  * and, if so, restore all state to it.
  */
-static void mmc_sd_resume(struct mmc_host *host)
+static int mmc_sd_resume(struct mmc_host *host)
 {
        int err;
 
@@ -595,30 +595,63 @@ static void mmc_sd_resume(struct mmc_host *host)
        err = mmc_sd_init_card(host, host->ocr, host->card);
        mmc_release_host(host);
 
-       if (err) {
-               mmc_sd_remove(host);
-
-               mmc_claim_host(host);
-               mmc_detach_bus(host);
-               mmc_release_host(host);
-       }
+       return err;
+}
 
+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);
 }
 
-#else
+#ifdef CONFIG_MMC_UNSAFE_RESUME
 
-#define mmc_sd_suspend NULL
-#define mmc_sd_resume NULL
+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,
+};
 
-#endif
+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.
  */
@@ -629,7 +662,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.