]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mmc: Add helper function to check if a card is removable
authorMatt Fleming <matt@console-pimps.org>
Mon, 27 Sep 2010 08:42:19 +0000 (09:42 +0100)
committerChris Ball <cjb@laptop.org>
Sat, 23 Oct 2010 13:11:15 +0000 (21:11 +0800)
There are two checks that need to be made when determining whether a
card is removable. A host controller may set MMC_CAP_NONREMOVABLE if the
controller does not support removing cards (e.g. eMMC), in which case
the card is physically non-removable. Also the 'mmc_assume_removable'
module parameter can be configured at module load time, in which case
the card may be logically non-removable.

A helper function keeps the logic in one place so that code always
checks both conditions.

Because this new function is likely to be called from modules we now
need to export the mmc_assume_removable symbol.

Signed-off-by: Matt Fleming <matt@console-pimps.org>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Tested-by: Jaehoon Chung <jh80.chung@samsung.com>
Acked-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Chris Ball <cjb@laptop.org>
drivers/mmc/core/core.c
drivers/mmc/core/core.h
drivers/mmc/core/mmc.c
drivers/mmc/core/sd.c
include/linux/mmc/host.h

index 09eee6df0653c84fc5c08023f8913a6afbb884a7..ab4446c428be50a68f8d3387f1fe58347db83d45 100644 (file)
@@ -58,6 +58,7 @@ int mmc_assume_removable;
 #else
 int mmc_assume_removable = 1;
 #endif
+EXPORT_SYMBOL(mmc_assume_removable);
 module_param_named(removable, mmc_assume_removable, bool, 0644);
 MODULE_PARM_DESC(
        removable,
index 9d9eef50e5d1976fb5d9874a00f4cf2db77c540a..a2ca770ca89bd6fa0148f585cc074f7f569599fe 100644 (file)
@@ -58,7 +58,6 @@ int mmc_attach_sdio(struct mmc_host *host, u32 ocr);
 
 /* Module parameters */
 extern int use_spi_crc;
-extern int mmc_assume_removable;
 
 /* Debugfs information for hosts and cards */
 void mmc_add_host_debugfs(struct mmc_host *host);
index 6909a54c39beac1a8ca277f317f43c4a4ea9d583..6570c03f9c767f089de15ebcd06b55efd639c005 100644 (file)
@@ -685,7 +685,7 @@ static void mmc_attach_bus_ops(struct mmc_host *host)
 {
        const struct mmc_bus_ops *bus_ops;
 
-       if (host->caps & MMC_CAP_NONREMOVABLE || !mmc_assume_removable)
+       if (!mmc_card_is_removable(host))
                bus_ops = &mmc_ops_unsafe;
        else
                bus_ops = &mmc_ops;
index 0f5241085557488dbfb674a60474fe7709719d44..bc745e1237bf87bd1feb1cea8a07ea06d0ea927d 100644 (file)
@@ -750,7 +750,7 @@ static void mmc_sd_attach_bus_ops(struct mmc_host *host)
 {
        const struct mmc_bus_ops *bus_ops;
 
-       if (host->caps & MMC_CAP_NONREMOVABLE || !mmc_assume_removable)
+       if (!mmc_card_is_removable(host))
                bus_ops = &mmc_sd_ops_unsafe;
        else
                bus_ops = &mmc_sd_ops;
index ded4017037621d2a9bf237099ae1ae2e7fed2913..2e0fe623df90f4f657567f78c1e1e867ec102a46 100644 (file)
@@ -267,5 +267,13 @@ static inline void mmc_set_disable_delay(struct mmc_host *host,
        host->disable_delay = disable_delay;
 }
 
+/* Module parameter */
+extern int mmc_assume_removable;
+
+static inline int mmc_card_is_removable(struct mmc_host *host)
+{
+       return !(host->caps & MMC_CAP_NONREMOVABLE) && mmc_assume_removable;
+}
+
 #endif