Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 176397
b: refs/heads/master
c: bd68e08
h: refs/heads/master
i:
  176395: e49afe4
v: v3
  • Loading branch information
Ben Hutchings authored and Linus Torvalds committed Dec 15, 2009
1 parent 9740522 commit 7df3cd9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 44 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c78402e95dd8238ee2b0e6e62b9a0c8b2bb9bba9
refs/heads/master: bd68e0838fe85794b06892054772fa013a8d1986
4 changes: 3 additions & 1 deletion trunk/drivers/mmc/core/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#

config MMC_UNSAFE_RESUME
bool "Allow unsafe resume (DANGEROUS)"
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
Expand All @@ -14,3 +14,5 @@ config MMC_UNSAFE_RESUME
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".
16 changes: 16 additions & 0 deletions trunk/drivers/mmc/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ static struct workqueue_struct *workqueue;
int use_spi_crc = 1;
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
int mmc_assume_removable;
#else
int mmc_assume_removable = 1;
#endif
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.
*/
Expand Down
2 changes: 2 additions & 0 deletions trunk/drivers/mmc/core/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr);
int mmc_attach_sd(struct mmc_host *host, u32 ocr);
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);
Expand Down
23 changes: 1 addition & 22 deletions trunk/drivers/mmc/core/mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,25 +602,6 @@ static int mmc_awake(struct mmc_host *host)
return err;
}

#ifdef CONFIG_MMC_UNSAFE_RESUME

static const struct mmc_bus_ops mmc_ops = {
.awake = mmc_awake,
.sleep = mmc_sleep,
.remove = mmc_remove,
.detect = mmc_detect,
.suspend = mmc_suspend,
.resume = mmc_resume,
.power_restore = mmc_power_restore,
};

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 = {
.awake = mmc_awake,
.sleep = mmc_sleep,
Expand All @@ -645,15 +626,13 @@ static void mmc_attach_bus_ops(struct mmc_host *host)
{
const struct mmc_bus_ops *bus_ops;

if (host->caps & MMC_CAP_NONREMOVABLE)
if (host->caps & MMC_CAP_NONREMOVABLE || !mmc_assume_removable)
bus_ops = &mmc_ops_unsafe;
else
bus_ops = &mmc_ops;
mmc_attach_bus(host, bus_ops);
}

#endif

/*
* Starting point for MMC card init.
*/
Expand Down
21 changes: 1 addition & 20 deletions trunk/drivers/mmc/core/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,23 +606,6 @@ static void mmc_sd_power_restore(struct mmc_host *host)
mmc_release_host(host);
}

#ifdef CONFIG_MMC_UNSAFE_RESUME

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,
.power_restore = mmc_sd_power_restore,
};

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,
Expand All @@ -643,15 +626,13 @@ static void mmc_sd_attach_bus_ops(struct mmc_host *host)
{
const struct mmc_bus_ops *bus_ops;

if (host->caps & MMC_CAP_NONREMOVABLE)
if (host->caps & MMC_CAP_NONREMOVABLE || !mmc_assume_removable)
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.
*/
Expand Down

0 comments on commit 7df3cd9

Please sign in to comment.