]> Pileus Git - ~andy/linux/commitdiff
ARM: 7721/1: mmc: mmci: Fixup regulator handling for vqmmc
authorUlf Hansson <ulf.hansson@linaro.org>
Tue, 14 May 2013 12:53:10 +0000 (13:53 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Wed, 22 May 2013 23:07:07 +0000 (00:07 +0100)
We can not rely on regulator_is_enabled to decide whether to
enable|disable the regulator. It would mean that the reference
counter for it is not balanced properly.

Instead keep track of our internal state by using a new flag in
the host struct, so we can take correct decisions.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
drivers/mmc/host/mmci.c
drivers/mmc/host/mmci.h

index c6d8b621606998c9ce611b01bf954b5224be4ae5..a8bbdd1c4314f14fe77f33d7b14aef60117ea323 100644 (file)
@@ -1156,9 +1156,10 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
                if (!IS_ERR(mmc->supply.vmmc))
                        mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
 
-               if (!IS_ERR(mmc->supply.vqmmc) &&
-                   regulator_is_enabled(mmc->supply.vqmmc))
+               if (!IS_ERR(mmc->supply.vqmmc) && host->vqmmc_enabled) {
                        regulator_disable(mmc->supply.vqmmc);
+                       host->vqmmc_enabled = false;
+               }
 
                break;
        case MMC_POWER_UP:
@@ -1174,12 +1175,13 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 
                break;
        case MMC_POWER_ON:
-               if (!IS_ERR(mmc->supply.vqmmc) &&
-                   !regulator_is_enabled(mmc->supply.vqmmc)) {
+               if (!IS_ERR(mmc->supply.vqmmc) && !host->vqmmc_enabled) {
                        ret = regulator_enable(mmc->supply.vqmmc);
                        if (ret < 0)
                                dev_err(mmc_dev(mmc),
                                        "failed to enable vqmmc regulator\n");
+                       else
+                               host->vqmmc_enabled = true;
                }
 
                pwr |= MCI_PWR_ON;
index 1f33ad5333a081508f9e76e7cb727822cf234907..1383c9ce2646cc8192d34b8c9529039f5a4115fa 100644 (file)
@@ -183,6 +183,7 @@ struct mmci_host {
        unsigned int            cclk;
        u32                     pwr_reg;
        u32                     clk_reg;
+       bool                    vqmmc_enabled;
        struct mmci_platform_data *plat;
        struct variant_data     *variant;