]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mmc: Use regulator_set_enable_if_allowed
authorJonas Karlman <jonas@kwiboo.se>
Wed, 19 Jul 2023 21:20:59 +0000 (21:20 +0000)
committerTom Rini <trini@konsulko.com>
Mon, 14 Aug 2023 13:14:41 +0000 (09:14 -0400)
With the commit 4fcba5d556b4 ("regulator: implement basic reference
counter") the return value of regulator_set_enable may be EALREADY or
EBUSY for fixed/gpio regulators.

Change to use the more relaxed regulator_set_enable_if_allowed to
continue if regulator already was enabled or disabled.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # P895 Tegra 3;
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org> # rockpro64-rk3399
drivers/mmc/mmc.c

index 31cfda288587119cf65de3e483be69d6437bcedc..089a0442568cf3d698cbe88fd2897c6a8337c66b 100644 (file)
@@ -2775,9 +2775,10 @@ static int mmc_power_on(struct mmc *mmc)
 {
 #if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(DM_REGULATOR)
        if (mmc->vmmc_supply) {
-               int ret = regulator_set_enable(mmc->vmmc_supply, true);
+               int ret = regulator_set_enable_if_allowed(mmc->vmmc_supply,
+                                                         true);
 
-               if (ret && ret != -EACCES) {
+               if (ret && ret != -ENOSYS) {
                        printf("Error enabling VMMC supply : %d\n", ret);
                        return ret;
                }
@@ -2791,9 +2792,10 @@ static int mmc_power_off(struct mmc *mmc)
        mmc_set_clock(mmc, 0, MMC_CLK_DISABLE);
 #if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(DM_REGULATOR)
        if (mmc->vmmc_supply) {
-               int ret = regulator_set_enable(mmc->vmmc_supply, false);
+               int ret = regulator_set_enable_if_allowed(mmc->vmmc_supply,
+                                                         false);
 
-               if (ret && ret != -EACCES) {
+               if (ret && ret != -ENOSYS) {
                        pr_debug("Error disabling VMMC supply : %d\n", ret);
                        return ret;
                }