aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Kryger <tim.kryger@linaro.org>2014-05-06 18:57:01 -0400
committerChris Ball <chris@printf.net>2014-05-12 18:08:24 -0400
commit4d1f52f9a9f9a63371dba589093b3ae90fc80c3d (patch)
treec79807df571fa6b0dd63abba62b8e1ccc92ca463
parentbc3c17711e5a6d3b1d1cf7f6b3fe081d81d68dcb (diff)
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: Tim Kryger <tim.kryger@linaro.org> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Chris Ball <chris@printf.net>
-rw-r--r--drivers/mmc/core/core.c31
-rw-r--r--include/linux/mmc/host.h8
2 files changed, 21 insertions, 18 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 02baa30653fa..7dc0c85fdb60 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1314,31 +1314,38 @@ int mmc_regulator_set_ocr(struct mmc_host *mmc,
1314} 1314}
1315EXPORT_SYMBOL_GPL(mmc_regulator_set_ocr); 1315EXPORT_SYMBOL_GPL(mmc_regulator_set_ocr);
1316 1316
1317#endif /* CONFIG_REGULATOR */
1318
1317int mmc_regulator_get_supply(struct mmc_host *mmc) 1319int mmc_regulator_get_supply(struct mmc_host *mmc)
1318{ 1320{
1319 struct device *dev = mmc_dev(mmc); 1321 struct device *dev = mmc_dev(mmc);
1320 struct regulator *supply;
1321 int ret; 1322 int ret;
1322 1323
1323 supply = devm_regulator_get(dev, "vmmc"); 1324 mmc->supply.vmmc = devm_regulator_get_optional(dev, "vmmc");
1324 mmc->supply.vmmc = supply;
1325 mmc->supply.vqmmc = devm_regulator_get_optional(dev, "vqmmc"); 1325 mmc->supply.vqmmc = devm_regulator_get_optional(dev, "vqmmc");
1326 1326
1327 if (IS_ERR(supply)) 1327 if (IS_ERR(mmc->supply.vmmc)) {
1328 return PTR_ERR(supply); 1328 if (PTR_ERR(mmc->supply.vmmc) == -EPROBE_DEFER)
1329 return -EPROBE_DEFER;
1330 dev_info(dev, "No vmmc regulator found\n");
1331 } else {
1332 ret = mmc_regulator_get_ocrmask(mmc->supply.vmmc);
1333 if (ret > 0)
1334 mmc->ocr_avail = ret;
1335 else
1336 dev_warn(dev, "Failed getting OCR mask: %d\n", ret);
1337 }
1329 1338
1330 ret = mmc_regulator_get_ocrmask(supply); 1339 if (IS_ERR(mmc->supply.vqmmc)) {
1331 if (ret > 0) 1340 if (PTR_ERR(mmc->supply.vqmmc) == -EPROBE_DEFER)
1332 mmc->ocr_avail = ret; 1341 return -EPROBE_DEFER;
1333 else 1342 dev_info(dev, "No vqmmc regulator found\n");
1334 dev_warn(mmc_dev(mmc), "Failed getting OCR mask: %d\n", ret); 1343 }
1335 1344
1336 return 0; 1345 return 0;
1337} 1346}
1338EXPORT_SYMBOL_GPL(mmc_regulator_get_supply); 1347EXPORT_SYMBOL_GPL(mmc_regulator_get_supply);
1339 1348
1340#endif /* CONFIG_REGULATOR */
1341
1342/* 1349/*
1343 * Mask off any voltages we don't support and select 1350 * Mask off any voltages we don't support and select
1344 * the lowest voltage 1351 * the lowest voltage
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 183087374215..cd595275e118 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -402,7 +402,6 @@ int mmc_regulator_get_ocrmask(struct regulator *supply);
402int mmc_regulator_set_ocr(struct mmc_host *mmc, 402int mmc_regulator_set_ocr(struct mmc_host *mmc,
403 struct regulator *supply, 403 struct regulator *supply,
404 unsigned short vdd_bit); 404 unsigned short vdd_bit);
405int mmc_regulator_get_supply(struct mmc_host *mmc);
406#else 405#else
407static inline int mmc_regulator_get_ocrmask(struct regulator *supply) 406static inline int mmc_regulator_get_ocrmask(struct regulator *supply)
408{ 407{
@@ -415,13 +414,10 @@ static inline int mmc_regulator_set_ocr(struct mmc_host *mmc,
415{ 414{
416 return 0; 415 return 0;
417} 416}
418
419static inline int mmc_regulator_get_supply(struct mmc_host *mmc)
420{
421 return 0;
422}
423#endif 417#endif
424 418
419int mmc_regulator_get_supply(struct mmc_host *mmc);
420
425int mmc_pm_notify(struct notifier_block *notify_block, unsigned long, void *); 421int mmc_pm_notify(struct notifier_block *notify_block, unsigned long, void *);
426 422
427static inline int mmc_card_is_removable(struct mmc_host *host) 423static inline int mmc_card_is_removable(struct mmc_host *host)