فهرست منبع

mmc: Add helper function to check if a card is removable

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>
Matt Fleming 14 سال پیش
والد
کامیت
71d7d3d190
5فایلهای تغییر یافته به همراه11 افزوده شده و 3 حذف شده
  1. 1 0
      drivers/mmc/core/core.c
  2. 0 1
      drivers/mmc/core/core.h
  3. 1 1
      drivers/mmc/core/mmc.c
  4. 1 1
      drivers/mmc/core/sd.c
  5. 8 0
      include/linux/mmc/host.h

+ 1 - 0
drivers/mmc/core/core.c

@@ -58,6 +58,7 @@ int mmc_assume_removable;
 #else
 #else
 int mmc_assume_removable = 1;
 int mmc_assume_removable = 1;
 #endif
 #endif
+EXPORT_SYMBOL(mmc_assume_removable);
 module_param_named(removable, mmc_assume_removable, bool, 0644);
 module_param_named(removable, mmc_assume_removable, bool, 0644);
 MODULE_PARM_DESC(
 MODULE_PARM_DESC(
 	removable,
 	removable,

+ 0 - 1
drivers/mmc/core/core.h

@@ -58,7 +58,6 @@ int mmc_attach_sdio(struct mmc_host *host, u32 ocr);
 
 
 /* Module parameters */
 /* Module parameters */
 extern int use_spi_crc;
 extern int use_spi_crc;
-extern int mmc_assume_removable;
 
 
 /* Debugfs information for hosts and cards */
 /* Debugfs information for hosts and cards */
 void mmc_add_host_debugfs(struct mmc_host *host);
 void mmc_add_host_debugfs(struct mmc_host *host);

+ 1 - 1
drivers/mmc/core/mmc.c

@@ -685,7 +685,7 @@ static void mmc_attach_bus_ops(struct mmc_host *host)
 {
 {
 	const struct mmc_bus_ops *bus_ops;
 	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;
 		bus_ops = &mmc_ops_unsafe;
 	else
 	else
 		bus_ops = &mmc_ops;
 		bus_ops = &mmc_ops;

+ 1 - 1
drivers/mmc/core/sd.c

@@ -750,7 +750,7 @@ static void mmc_sd_attach_bus_ops(struct mmc_host *host)
 {
 {
 	const struct mmc_bus_ops *bus_ops;
 	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;
 		bus_ops = &mmc_sd_ops_unsafe;
 	else
 	else
 		bus_ops = &mmc_sd_ops;
 		bus_ops = &mmc_sd_ops;

+ 8 - 0
include/linux/mmc/host.h

@@ -267,5 +267,13 @@ static inline void mmc_set_disable_delay(struct mmc_host *host,
 	host->disable_delay = disable_delay;
 	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
 #endif