mmc: core: Handle card shutdown from mmc_bus
authorUlf Hansson <ulf.hansson@linaro.org>
Mon, 10 Jun 2013 15:03:40 +0000 (17:03 +0200)
committerlintao <lintao@rock-chips.com>
Fri, 7 Mar 2014 05:07:45 +0000 (13:07 +0800)
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>
drivers/mmc/card/block.c
drivers/mmc/card/mmc_test.c
drivers/mmc/core/bus.c
include/linux/mmc/card.h

index a383849b32a98ab0899ee58202be64ba35a11220..721e74e36171aa4327b88225ed38ab5eef4258cf 100644 (file)
@@ -2454,8 +2454,7 @@ static void mmc_blk_remove(struct mmc_card *card)
 #endif
 }
 
-#ifdef CONFIG_PM
-static int mmc_blk_suspend(struct mmc_card *card)
+static int _mmc_blk_suspend(struct mmc_card *card)
 {
        struct mmc_blk_data *part_md;
        struct mmc_blk_data *md = mmc_get_drvdata(card);
@@ -2470,6 +2469,17 @@ static int mmc_blk_suspend(struct mmc_card *card)
        return 0;
 }
 
+static void mmc_blk_shutdown(struct mmc_card *card)
+{
+       _mmc_blk_suspend(card);
+}
+
+#ifdef CONFIG_PM
+static int mmc_blk_suspend(struct mmc_card *card)
+{
+       return _mmc_blk_suspend(card);
+}
+
 static int mmc_blk_resume(struct mmc_card *card)
 {
        struct mmc_blk_data *part_md;
@@ -2502,6 +2512,7 @@ static struct mmc_driver mmc_driver = {
        .remove         = mmc_blk_remove,
        .suspend        = mmc_blk_suspend,
        .resume         = mmc_blk_resume,
+       .shutdown       = mmc_blk_shutdown,
 };
 
 static int __init mmc_blk_init(void)
index 759714ed6bee8f791b2cbd4a5959f2ca12d7e9ec..a69df5216274d8f017f6f8cc0e96f1419cce784e 100644 (file)
@@ -3025,12 +3025,17 @@ static void mmc_test_remove(struct mmc_card *card)
        mmc_test_free_dbgfs_file(card);
 }
 
+static void mmc_test_shutdown(struct mmc_card *card)
+{
+}
+
 static struct mmc_driver mmc_driver = {
        .drv            = {
                .name   = "mmc_test",
        },
        .probe          = mmc_test_probe,
        .remove         = mmc_test_remove,
+       .shutdown       = mmc_test_shutdown,
 };
 
 static int __init mmc_test_init(void)
index a5bcf82ae0d24b2e08848bbde5498cb53b6724c5..93663cc3bc3f86d6677ed70b3fce8bc8f002a7dc 100644 (file)
@@ -122,6 +122,14 @@ static int mmc_bus_remove(struct device *dev)
        return 0;
 }
 
+static void mmc_bus_shutdown(struct device *dev)
+{
+       struct mmc_driver *drv = to_mmc_driver(dev->driver);
+       struct mmc_card *card = mmc_dev_to_card(dev);
+
+       drv->shutdown(card);
+}
+
 #ifdef CONFIG_PM_SLEEP
 static int mmc_bus_suspend(struct device *dev)
 {
@@ -205,6 +213,7 @@ static struct bus_type mmc_bus_type = {
        .uevent         = mmc_bus_uevent,
        .probe          = mmc_bus_probe,
        .remove         = mmc_bus_remove,
+       .shutdown       = mmc_bus_shutdown,
        .pm             = &mmc_bus_pm_ops,
 };
 
index 6a98f32670b846608e04502ba888c9ba53d950ad..842de3e21e70c4125f3d1574ebb0391a8d2b4cd5 100644 (file)
@@ -520,6 +520,7 @@ struct mmc_driver {
        void (*remove)(struct mmc_card *);
        int (*suspend)(struct mmc_card *);
        int (*resume)(struct mmc_card *);
+       void (*shutdown)(struct mmc_card *);
 };
 
 extern int mmc_register_driver(struct mmc_driver *);