mmc: add MMC_CAP_NONREMOVABLE host capability
authorAdrian Hunter <adrian.hunter@nokia.com>
Tue, 22 Sep 2009 23:44:32 +0000 (16:44 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 23 Sep 2009 14:39:33 +0000 (07:39 -0700)
eMMC's are not removable, so unsafe resume is OK always.

To permit this a new host capability MMC_CAP_NONREMOVABLE has been added
and suspend / resume updated accordingly.

Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>
Acked-by: Matt Fleming <matt@console-pimps.org>
Cc: Ian Molton <ian@mnementh.co.uk>
Cc: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Cc: Jarkko Lavinen <jarkko.lavinen@nokia.com>
Cc: Denis Karpov <ext-denis.2.karpov@nokia.com>
Cc: Pierre Ossman <pierre@ossman.eu>
Cc: Philip Langdale <philipl@overt.org>
Cc: "Madhusudhan" <madhu.cr@ti.com>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/mmc/core/mmc.c
drivers/mmc/core/sd.c
include/linux/mmc/host.h

index 2fb9d5f271ea4e2a3eabf4ebdd8dd65021a5025b..995db1853a81419435c8039d91736a5ac7414c8e 100644 (file)
@@ -507,8 +507,6 @@ static void mmc_detect(struct mmc_host *host)
        }
 }
 
-#ifdef CONFIG_MMC_UNSAFE_RESUME
-
 /*
  * Suspend callback from host.
  */
@@ -551,20 +549,49 @@ static void mmc_resume(struct mmc_host *host)
 
 }
 
-#else
+#ifdef CONFIG_MMC_UNSAFE_RESUME
 
-#define mmc_suspend NULL
-#define mmc_resume NULL
+static const struct mmc_bus_ops mmc_ops = {
+       .remove = mmc_remove,
+       .detect = mmc_detect,
+       .suspend = mmc_suspend,
+       .resume = mmc_resume,
+};
 
-#endif
+static void mmc_attach_bus_ops(struct mmc_host *host)
+{
+       mmc_attach_bus(host, &mmc_ops);
+}
+
+#else
 
 static const struct mmc_bus_ops mmc_ops = {
+       .remove = mmc_remove,
+       .detect = mmc_detect,
+       .suspend = NULL,
+       .resume = NULL,
+};
+
+static const struct mmc_bus_ops mmc_ops_unsafe = {
        .remove = mmc_remove,
        .detect = mmc_detect,
        .suspend = mmc_suspend,
        .resume = mmc_resume,
 };
 
+static void mmc_attach_bus_ops(struct mmc_host *host)
+{
+       const struct mmc_bus_ops *bus_ops;
+
+       if (host->caps & MMC_CAP_NONREMOVABLE)
+               bus_ops = &mmc_ops_unsafe;
+       else
+               bus_ops = &mmc_ops;
+       mmc_attach_bus(host, bus_ops);
+}
+
+#endif
+
 /*
  * Starting point for MMC card init.
  */
@@ -575,7 +602,7 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr)
        BUG_ON(!host);
        WARN_ON(!host->claimed);
 
-       mmc_attach_bus(host, &mmc_ops);
+       mmc_attach_bus_ops(host);
 
        /*
         * We need to get OCR a different way for SPI.
index 7ad646fe077ec796da7a390c8a2a0dfe624f39b1..92fa9dceca7962d784dd66bf0baa3beefea3f221 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.
index 631a2fea5264ec30c1b0e623df83a8ce5d799586..bb867d2c26bdc5ad1c651b4a85a89f1a2890f54a 100644 (file)
@@ -148,6 +148,7 @@ struct mmc_host {
 #define MMC_CAP_NEEDS_POLL     (1 << 5)        /* Needs polling for card-detection */
 #define MMC_CAP_8_BIT_DATA     (1 << 6)        /* Can the host do 8 bit transfers */
 #define MMC_CAP_DISABLE                (1 << 7)        /* Can the host be disabled */
+#define MMC_CAP_NONREMOVABLE   (1 << 8)        /* Nonremovable e.g. eMMC */
 
        /* host specific block data */
        unsigned int            max_seg_size;   /* see blk_queue_max_segment_size */