mmc: add MMC_CAP_NONREMOVABLE host capability
[safe/jmp/linux-2.6] / drivers / mmc / core / sd.c
index 7ad646f..92fa9dc 100644 (file)
@@ -561,8 +561,6 @@ static void mmc_sd_detect(struct mmc_host *host)
        }
 }
 
-#ifdef CONFIG_MMC_UNSAFE_RESUME
-
 /*
  * Suspend callback from host.
  */
@@ -605,20 +603,49 @@ static void mmc_sd_resume(struct mmc_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,
+};
 
-#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,
+};
+
+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,
 };
 
+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 +656,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.