Commit 4d1f52f9 authored by Tim Kryger's avatar Tim Kryger Committed by Chris Ball

mmc: core: Improve support for deferred regulators

Callers of mmc_regulator_get_supply could benefit from knowing if either
of the regulators are present but not yet available.  Since callers do
not currently examine the return value, modify this function to return
zero or -EPROBE_DEFER if either regulator get returns the same.

Furthermore, since callers check vmmc/vqmmc using IS_ERR and can deal
with absent regulators, switch to devm_regulator_get_optional. This has
the added benefit of allowing this function to behave correctly even in
the !CONFIG_REGULATOR case such that the stub can be removed.
Signed-off-by: default avatarTim Kryger <tim.kryger@linaro.org>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Signed-off-by: default avatarChris Ball <chris@printf.net>
parent bc3c1771
...@@ -1314,31 +1314,38 @@ int mmc_regulator_set_ocr(struct mmc_host *mmc, ...@@ -1314,31 +1314,38 @@ int mmc_regulator_set_ocr(struct mmc_host *mmc,
} }
EXPORT_SYMBOL_GPL(mmc_regulator_set_ocr); EXPORT_SYMBOL_GPL(mmc_regulator_set_ocr);
#endif /* CONFIG_REGULATOR */
int mmc_regulator_get_supply(struct mmc_host *mmc) int mmc_regulator_get_supply(struct mmc_host *mmc)
{ {
struct device *dev = mmc_dev(mmc); struct device *dev = mmc_dev(mmc);
struct regulator *supply;
int ret; int ret;
supply = devm_regulator_get(dev, "vmmc"); mmc->supply.vmmc = devm_regulator_get_optional(dev, "vmmc");
mmc->supply.vmmc = supply;
mmc->supply.vqmmc = devm_regulator_get_optional(dev, "vqmmc"); mmc->supply.vqmmc = devm_regulator_get_optional(dev, "vqmmc");
if (IS_ERR(supply)) if (IS_ERR(mmc->supply.vmmc)) {
return PTR_ERR(supply); if (PTR_ERR(mmc->supply.vmmc) == -EPROBE_DEFER)
return -EPROBE_DEFER;
dev_info(dev, "No vmmc regulator found\n");
} else {
ret = mmc_regulator_get_ocrmask(mmc->supply.vmmc);
if (ret > 0)
mmc->ocr_avail = ret;
else
dev_warn(dev, "Failed getting OCR mask: %d\n", ret);
}
ret = mmc_regulator_get_ocrmask(supply); if (IS_ERR(mmc->supply.vqmmc)) {
if (ret > 0) if (PTR_ERR(mmc->supply.vqmmc) == -EPROBE_DEFER)
mmc->ocr_avail = ret; return -EPROBE_DEFER;
else dev_info(dev, "No vqmmc regulator found\n");
dev_warn(mmc_dev(mmc), "Failed getting OCR mask: %d\n", ret); }
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(mmc_regulator_get_supply); EXPORT_SYMBOL_GPL(mmc_regulator_get_supply);
#endif /* CONFIG_REGULATOR */
/* /*
* Mask off any voltages we don't support and select * Mask off any voltages we don't support and select
* the lowest voltage * the lowest voltage
......
...@@ -402,7 +402,6 @@ int mmc_regulator_get_ocrmask(struct regulator *supply); ...@@ -402,7 +402,6 @@ int mmc_regulator_get_ocrmask(struct regulator *supply);
int mmc_regulator_set_ocr(struct mmc_host *mmc, int mmc_regulator_set_ocr(struct mmc_host *mmc,
struct regulator *supply, struct regulator *supply,
unsigned short vdd_bit); unsigned short vdd_bit);
int mmc_regulator_get_supply(struct mmc_host *mmc);
#else #else
static inline int mmc_regulator_get_ocrmask(struct regulator *supply) static inline int mmc_regulator_get_ocrmask(struct regulator *supply)
{ {
...@@ -415,13 +414,10 @@ static inline int mmc_regulator_set_ocr(struct mmc_host *mmc, ...@@ -415,13 +414,10 @@ static inline int mmc_regulator_set_ocr(struct mmc_host *mmc,
{ {
return 0; return 0;
} }
static inline int mmc_regulator_get_supply(struct mmc_host *mmc)
{
return 0;
}
#endif #endif
int mmc_regulator_get_supply(struct mmc_host *mmc);
int mmc_pm_notify(struct notifier_block *notify_block, unsigned long, void *); int mmc_pm_notify(struct notifier_block *notify_block, unsigned long, void *);
static inline int mmc_card_is_removable(struct mmc_host *host) static inline int mmc_card_is_removable(struct mmc_host *host)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment