aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hansson <ulf.hansson@linaro.org>2013-06-10 11:03:40 -0400
committerChris Ball <cjb@laptop.org>2013-06-27 12:39:18 -0400
commit7628774851751e55362ec7d9d57c9334e656a655 (patch)
tree54a8d24423250ceec0fd3468aeef20465941085a
parent986892ca78eeddd9d6b629050fea432979ddd321 (diff)
mmc: core: Handle card shutdown from mmc_bus
Considering shutdown of the card, the responsibility to initate this sequence shall be driven from the mmc_bus. This patch enables the mmc_bus to handle this sequence properly. A new .shutdown callback is added in the mmc_driver struct which is used to shutdown the blk device. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Chris Ball <cjb@laptop.org>
-rw-r--r--drivers/mmc/card/block.c15
-rw-r--r--drivers/mmc/card/mmc_test.c5
-rw-r--r--drivers/mmc/core/bus.c9
-rw-r--r--include/linux/mmc/card.h1
4 files changed, 28 insertions, 2 deletions
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 5411bf447369..cd0b7f4a1ff2 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -2403,8 +2403,7 @@ static void mmc_blk_remove(struct mmc_card *card)
2403 mmc_set_drvdata(card, NULL); 2403 mmc_set_drvdata(card, NULL);
2404} 2404}
2405 2405
2406#ifdef CONFIG_PM 2406static int _mmc_blk_suspend(struct mmc_card *card)
2407static int mmc_blk_suspend(struct mmc_card *card)
2408{ 2407{
2409 struct mmc_blk_data *part_md; 2408 struct mmc_blk_data *part_md;
2410 struct mmc_blk_data *md = mmc_get_drvdata(card); 2409 struct mmc_blk_data *md = mmc_get_drvdata(card);
@@ -2419,6 +2418,17 @@ static int mmc_blk_suspend(struct mmc_card *card)
2419 return 0; 2418 return 0;
2420} 2419}
2421 2420
2421static void mmc_blk_shutdown(struct mmc_card *card)
2422{
2423 _mmc_blk_suspend(card);
2424}
2425
2426#ifdef CONFIG_PM
2427static int mmc_blk_suspend(struct mmc_card *card)
2428{
2429 return _mmc_blk_suspend(card);
2430}
2431
2422static int mmc_blk_resume(struct mmc_card *card) 2432static int mmc_blk_resume(struct mmc_card *card)
2423{ 2433{
2424 struct mmc_blk_data *part_md; 2434 struct mmc_blk_data *part_md;
@@ -2451,6 +2461,7 @@ static struct mmc_driver mmc_driver = {
2451 .remove = mmc_blk_remove, 2461 .remove = mmc_blk_remove,
2452 .suspend = mmc_blk_suspend, 2462 .suspend = mmc_blk_suspend,
2453 .resume = mmc_blk_resume, 2463 .resume = mmc_blk_resume,
2464 .shutdown = mmc_blk_shutdown,
2454}; 2465};
2455 2466
2456static int __init mmc_blk_init(void) 2467static int __init mmc_blk_init(void)
diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index 759714ed6bee..a69df5216274 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -3025,12 +3025,17 @@ static void mmc_test_remove(struct mmc_card *card)
3025 mmc_test_free_dbgfs_file(card); 3025 mmc_test_free_dbgfs_file(card);
3026} 3026}
3027 3027
3028static void mmc_test_shutdown(struct mmc_card *card)
3029{
3030}
3031
3028static struct mmc_driver mmc_driver = { 3032static struct mmc_driver mmc_driver = {
3029 .drv = { 3033 .drv = {
3030 .name = "mmc_test", 3034 .name = "mmc_test",
3031 }, 3035 },
3032 .probe = mmc_test_probe, 3036 .probe = mmc_test_probe,
3033 .remove = mmc_test_remove, 3037 .remove = mmc_test_remove,
3038 .shutdown = mmc_test_shutdown,
3034}; 3039};
3035 3040
3036static int __init mmc_test_init(void) 3041static int __init mmc_test_init(void)
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index 3b7ca8ac0e61..219bf4b1d97e 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -122,6 +122,14 @@ static int mmc_bus_remove(struct device *dev)
122 return 0; 122 return 0;
123} 123}
124 124
125static void mmc_bus_shutdown(struct device *dev)
126{
127 struct mmc_driver *drv = to_mmc_driver(dev->driver);
128 struct mmc_card *card = mmc_dev_to_card(dev);
129
130 drv->shutdown(card);
131}
132
125#ifdef CONFIG_PM_SLEEP 133#ifdef CONFIG_PM_SLEEP
126static int mmc_bus_suspend(struct device *dev) 134static int mmc_bus_suspend(struct device *dev)
127{ 135{
@@ -205,6 +213,7 @@ static struct bus_type mmc_bus_type = {
205 .uevent = mmc_bus_uevent, 213 .uevent = mmc_bus_uevent,
206 .probe = mmc_bus_probe, 214 .probe = mmc_bus_probe,
207 .remove = mmc_bus_remove, 215 .remove = mmc_bus_remove,
216 .shutdown = mmc_bus_shutdown,
208 .pm = &mmc_bus_pm_ops, 217 .pm = &mmc_bus_pm_ops,
209}; 218};
210 219
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index 6a98f32670b8..842de3e21e70 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -520,6 +520,7 @@ struct mmc_driver {
520 void (*remove)(struct mmc_card *); 520 void (*remove)(struct mmc_card *);
521 int (*suspend)(struct mmc_card *); 521 int (*suspend)(struct mmc_card *);
522 int (*resume)(struct mmc_card *); 522 int (*resume)(struct mmc_card *);
523 void (*shutdown)(struct mmc_card *);
523}; 524};
524 525
525extern int mmc_register_driver(struct mmc_driver *); 526extern int mmc_register_driver(struct mmc_driver *);