mmc: host: omap_hsmmc: use devm_regulator_get_optional() for vmmc
authorKishon Vijay Abraham I <kishon@ti.com>
Thu, 27 Aug 2015 09:13:53 +0000 (14:43 +0530)
committerUlf Hansson <ulf.hansson@linaro.org>
Thu, 27 Aug 2015 12:54:05 +0000 (14:54 +0200)
Since vmmc can be optional for some platforms, use
devm_regulator_get_optional() for vmmc. Now return error only
if the return value of devm_regulator_get_optional() is not the
same as -ENODEV, since with -EPROBE_DEFER, the regulator can be
obtained later and all other errors are fatal.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Tested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/omap_hsmmc.c

index 19ae7e6..9b335af 100644 (file)
@@ -345,15 +345,19 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 {
        struct regulator *reg;
        int ocr_value = 0;
+       int ret;
 
        if (mmc_pdata(host)->set_power)
                return 0;
 
-       reg = devm_regulator_get(host->dev, "vmmc");
+       reg = devm_regulator_get_optional(host->dev, "vmmc");
        if (IS_ERR(reg)) {
-               dev_err(host->dev, "unable to get vmmc regulator %ld\n",
+               ret = PTR_ERR(reg);
+               if (ret != -ENODEV)
+                       return ret;
+               host->vcc = NULL;
+               dev_dbg(host->dev, "unable to get vmmc regulator %ld\n",
                        PTR_ERR(reg));
-               return PTR_ERR(reg);
        } else {
                host->vcc = reg;
                ocr_value = mmc_regulator_get_ocrmask(reg);