mmc: core: move the cache disabling operation to mmc_suspend
authorMaya Erez <merez@codeaurora.org>
Mon, 28 Jan 2013 21:44:22 +0000 (16:44 -0500)
committerChris Ball <cjb@laptop.org>
Sun, 24 Feb 2013 19:37:00 +0000 (14:37 -0500)
Cache control is an eMMC feature and in therefore should be
part of MMC's bus resume operations, performed in mmc_suspend,
rather than in the generic mmc_suspend_host().

Signed-off-by: Maya Erez <merez@codeaurora.org>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
drivers/mmc/core/core.c
drivers/mmc/core/mmc.c

index 8b3a1222e665a8a8ac087bf2ced4ac66565add76..39f28af34cb653475d8f9621d4b4606113a1c423 100644 (file)
@@ -2486,6 +2486,7 @@ EXPORT_SYMBOL(mmc_flush_cache);
  * Turn the cache ON/OFF.
  * Turning the cache OFF shall trigger flushing of the data
  * to the non-volatile storage.
+ * This function should be called with host claimed
  */
 int mmc_cache_ctrl(struct mmc_host *host, u8 enable)
 {
@@ -2497,7 +2498,6 @@ int mmc_cache_ctrl(struct mmc_host *host, u8 enable)
                        mmc_card_is_removable(host))
                return err;
 
-       mmc_claim_host(host);
        if (card && mmc_card_mmc(card) &&
                        (card->ext_csd.cache_size > 0)) {
                enable = !!enable;
@@ -2515,7 +2515,6 @@ int mmc_cache_ctrl(struct mmc_host *host, u8 enable)
                                card->ext_csd.cache_ctrl = enable;
                }
        }
-       mmc_release_host(host);
 
        return err;
 }
@@ -2534,10 +2533,6 @@ int mmc_suspend_host(struct mmc_host *host)
        cancel_delayed_work(&host->detect);
        mmc_flush_scheduled_work();
 
-       err = mmc_cache_ctrl(host, 0);
-       if (err)
-               goto out;
-
        mmc_bus_get(host);
        if (host->bus_ops && !host->bus_dead) {
                if (host->bus_ops->suspend) {
index e6e39111e05b416623f830060fd8fca86f44edf5..dc17d4097f9a3b3d2839d51099c75f01cca0dbab 100644 (file)
@@ -1379,6 +1379,11 @@ static int mmc_suspend(struct mmc_host *host)
        BUG_ON(!host->card);
 
        mmc_claim_host(host);
+
+       err = mmc_cache_ctrl(host, 0);
+       if (err)
+               goto out;
+
        if (mmc_can_poweroff_notify(host->card))
                err = mmc_poweroff_notify(host->card, EXT_CSD_POWER_OFF_SHORT);
        else if (mmc_card_can_sleep(host))
@@ -1386,8 +1391,9 @@ static int mmc_suspend(struct mmc_host *host)
        else if (!mmc_host_is_spi(host))
                err = mmc_deselect_cards(host);
        host->card->state &= ~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_200);
-       mmc_release_host(host);
 
+out:
+       mmc_release_host(host);
        return err;
 }