Commit 2501c917 authored by Ulf Hansson's avatar Ulf Hansson Committed by Chris Ball

mmc: core: Use MMC_UNSAFE_RESUME as default behavior

Invoking system suspend or shutdown without using the Kconfig option
MMC_UNSAFE_RESUME, did trigger an ungraceful power cut of the card.

To improve the situation, change the behavior to always make use of the
available bus_ops callbacks that handles system suspend and shutdown
properly.

By changing the behavior MMC_UNSAFE_RESUME becomes redundant, so lets's
remove it.
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Signed-off-by: default avatarChris Ball <chris@printf.net>
parent 710dec95
...@@ -2,21 +2,6 @@ ...@@ -2,21 +2,6 @@
# MMC core configuration # MMC core configuration
# #
config MMC_UNSAFE_RESUME
bool "Assume MMC/SD cards are non-removable (DANGEROUS)"
help
If you say Y here, the MMC layer will assume that all cards
stayed in their respective slots during the suspend. The
normal behaviour is to remove them at suspend and
redetecting them at resume. Breaking this assumption will
in most cases result in data corruption.
This option is usually just for embedded systems which use
a MMC/SD card for rootfs. Most people should say N here.
This option sets a default which can be overridden by the
module parameter "removable=0" or "removable=1".
config MMC_CLKGATE config MMC_CLKGATE
bool "MMC host clock gating" bool "MMC host clock gating"
help help
......
...@@ -64,23 +64,6 @@ static const unsigned freqs[] = { 400000, 300000, 200000, 100000 }; ...@@ -64,23 +64,6 @@ static const unsigned freqs[] = { 400000, 300000, 200000, 100000 };
bool use_spi_crc = 1; bool use_spi_crc = 1;
module_param(use_spi_crc, bool, 0); module_param(use_spi_crc, bool, 0);
/*
* We normally treat cards as removed during suspend if they are not
* known to be on a non-removable bus, to avoid the risk of writing
* back data to a different card after resume. Allow this to be
* overridden if necessary.
*/
#ifdef CONFIG_MMC_UNSAFE_RESUME
bool mmc_assume_removable;
#else
bool mmc_assume_removable = 1;
#endif
EXPORT_SYMBOL(mmc_assume_removable);
module_param_named(removable, mmc_assume_removable, bool, 0644);
MODULE_PARM_DESC(
removable,
"MMC/SD cards are removable and may be removed during suspend");
/* /*
* Internal function. Schedule delayed work in the MMC work queue. * Internal function. Schedule delayed work in the MMC work queue.
*/ */
......
...@@ -1634,16 +1634,6 @@ static int mmc_power_restore(struct mmc_host *host) ...@@ -1634,16 +1634,6 @@ static int mmc_power_restore(struct mmc_host *host)
} }
static const struct mmc_bus_ops mmc_ops = { static const struct mmc_bus_ops mmc_ops = {
.remove = mmc_remove,
.detect = mmc_detect,
.suspend = NULL,
.resume = NULL,
.power_restore = mmc_power_restore,
.alive = mmc_alive,
.shutdown = mmc_shutdown,
};
static const struct mmc_bus_ops mmc_ops_unsafe = {
.remove = mmc_remove, .remove = mmc_remove,
.detect = mmc_detect, .detect = mmc_detect,
.suspend = mmc_suspend, .suspend = mmc_suspend,
...@@ -1655,17 +1645,6 @@ static const struct mmc_bus_ops mmc_ops_unsafe = { ...@@ -1655,17 +1645,6 @@ static const struct mmc_bus_ops mmc_ops_unsafe = {
.shutdown = mmc_shutdown, .shutdown = mmc_shutdown,
}; };
static void mmc_attach_bus_ops(struct mmc_host *host)
{
const struct mmc_bus_ops *bus_ops;
if (!mmc_card_is_removable(host))
bus_ops = &mmc_ops_unsafe;
else
bus_ops = &mmc_ops;
mmc_attach_bus(host, bus_ops);
}
/* /*
* Starting point for MMC card init. * Starting point for MMC card init.
*/ */
...@@ -1685,7 +1664,7 @@ int mmc_attach_mmc(struct mmc_host *host) ...@@ -1685,7 +1664,7 @@ int mmc_attach_mmc(struct mmc_host *host)
if (err) if (err)
return err; return err;
mmc_attach_bus_ops(host); mmc_attach_bus(host, &mmc_ops);
if (host->ocr_avail_mmc) if (host->ocr_avail_mmc)
host->ocr_avail = host->ocr_avail_mmc; host->ocr_avail = host->ocr_avail_mmc;
......
...@@ -1207,16 +1207,6 @@ static int mmc_sd_power_restore(struct mmc_host *host) ...@@ -1207,16 +1207,6 @@ static int mmc_sd_power_restore(struct mmc_host *host)
} }
static const struct mmc_bus_ops mmc_sd_ops = { 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,
.alive = mmc_sd_alive,
.shutdown = mmc_sd_suspend,
};
static const struct mmc_bus_ops mmc_sd_ops_unsafe = {
.remove = mmc_sd_remove, .remove = mmc_sd_remove,
.detect = mmc_sd_detect, .detect = mmc_sd_detect,
.runtime_suspend = mmc_sd_runtime_suspend, .runtime_suspend = mmc_sd_runtime_suspend,
...@@ -1228,17 +1218,6 @@ static const struct mmc_bus_ops mmc_sd_ops_unsafe = { ...@@ -1228,17 +1218,6 @@ static const struct mmc_bus_ops mmc_sd_ops_unsafe = {
.shutdown = mmc_sd_suspend, .shutdown = mmc_sd_suspend,
}; };
static void mmc_sd_attach_bus_ops(struct mmc_host *host)
{
const struct mmc_bus_ops *bus_ops;
if (!mmc_card_is_removable(host))
bus_ops = &mmc_sd_ops_unsafe;
else
bus_ops = &mmc_sd_ops;
mmc_attach_bus(host, bus_ops);
}
/* /*
* Starting point for SD card init. * Starting point for SD card init.
*/ */
...@@ -1254,7 +1233,7 @@ int mmc_attach_sd(struct mmc_host *host) ...@@ -1254,7 +1233,7 @@ int mmc_attach_sd(struct mmc_host *host)
if (err) if (err)
return err; return err;
mmc_sd_attach_bus_ops(host); mmc_attach_bus(host, &mmc_sd_ops);
if (host->ocr_avail_sd) if (host->ocr_avail_sd)
host->ocr_avail = host->ocr_avail_sd; host->ocr_avail = host->ocr_avail_sd;
......
...@@ -424,12 +424,9 @@ static inline int mmc_regulator_get_supply(struct mmc_host *mmc) ...@@ -424,12 +424,9 @@ static inline int mmc_regulator_get_supply(struct mmc_host *mmc)
int mmc_pm_notify(struct notifier_block *notify_block, unsigned long, void *); int mmc_pm_notify(struct notifier_block *notify_block, unsigned long, void *);
/* Module parameter */
extern bool mmc_assume_removable;
static inline int mmc_card_is_removable(struct mmc_host *host) static inline int mmc_card_is_removable(struct mmc_host *host)
{ {
return !(host->caps & MMC_CAP_NONREMOVABLE) && mmc_assume_removable; return !(host->caps & MMC_CAP_NONREMOVABLE);
} }
static inline int mmc_card_keep_power(struct mmc_host *host) static inline int mmc_card_keep_power(struct mmc_host *host)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment