aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/core.c
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-10-24 06:11:39 -0400
committerMark Brown <broonie@linaro.org>2013-10-24 06:11:39 -0400
commitaef393da7501693a1b91a1cfed1a9ea408ceabe6 (patch)
tree98af035479b8eb412a33259880a037169378cfa6 /drivers/regulator/core.c
parent88c260a180817093682af8bd311ca141ba3952c9 (diff)
parent4040394e12cb1eed21d1306cacdc8a6f0464c8e2 (diff)
Merge remote-tracking branch 'regulator/topic/optional' into regulator-next
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r--drivers/regulator/core.c49
1 files changed, 15 insertions, 34 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 960103a61000..6382f0af353b 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -55,7 +55,6 @@ static LIST_HEAD(regulator_map_list);
55static LIST_HEAD(regulator_ena_gpio_list); 55static LIST_HEAD(regulator_ena_gpio_list);
56static LIST_HEAD(regulator_supply_alias_list); 56static LIST_HEAD(regulator_supply_alias_list);
57static bool has_full_constraints; 57static bool has_full_constraints;
58static bool board_wants_dummy_regulator;
59 58
60static struct dentry *debugfs_root; 59static struct dentry *debugfs_root;
61 60
@@ -1303,12 +1302,12 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
1303 1302
1304/* Internal regulator request function */ 1303/* Internal regulator request function */
1305static struct regulator *_regulator_get(struct device *dev, const char *id, 1304static struct regulator *_regulator_get(struct device *dev, const char *id,
1306 bool exclusive) 1305 bool exclusive, bool allow_dummy)
1307{ 1306{
1308 struct regulator_dev *rdev; 1307 struct regulator_dev *rdev;
1309 struct regulator *regulator = ERR_PTR(-EPROBE_DEFER); 1308 struct regulator *regulator = ERR_PTR(-EPROBE_DEFER);
1310 const char *devname = NULL; 1309 const char *devname = NULL;
1311 int ret = 0; 1310 int ret = -EPROBE_DEFER;
1312 1311
1313 if (id == NULL) { 1312 if (id == NULL) {
1314 pr_err("get() with no identifier\n"); 1313 pr_err("get() with no identifier\n");
@@ -1324,34 +1323,32 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
1324 if (rdev) 1323 if (rdev)
1325 goto found; 1324 goto found;
1326 1325
1326 regulator = ERR_PTR(ret);
1327
1327 /* 1328 /*
1328 * If we have return value from dev_lookup fail, we do not expect to 1329 * If we have return value from dev_lookup fail, we do not expect to
1329 * succeed, so, quit with appropriate error value 1330 * succeed, so, quit with appropriate error value
1330 */ 1331 */
1331 if (ret) { 1332 if (ret && ret != -ENODEV) {
1332 regulator = ERR_PTR(ret);
1333 goto out; 1333 goto out;
1334 } 1334 }
1335 1335
1336 if (board_wants_dummy_regulator) {
1337 rdev = dummy_regulator_rdev;
1338 goto found;
1339 }
1340
1341#ifdef CONFIG_REGULATOR_DUMMY
1342 if (!devname) 1336 if (!devname)
1343 devname = "deviceless"; 1337 devname = "deviceless";
1344 1338
1345 /* If the board didn't flag that it was fully constrained then 1339 /*
1346 * substitute in a dummy regulator so consumers can continue. 1340 * Assume that a regulator is physically present and enabled
1341 * even if it isn't hooked up and just provide a dummy.
1347 */ 1342 */
1348 if (!has_full_constraints) { 1343 if (has_full_constraints && allow_dummy) {
1349 pr_warn("%s supply %s not found, using dummy regulator\n", 1344 pr_warn("%s supply %s not found, using dummy regulator\n",
1350 devname, id); 1345 devname, id);
1346
1351 rdev = dummy_regulator_rdev; 1347 rdev = dummy_regulator_rdev;
1352 goto found; 1348 goto found;
1349 } else {
1350 dev_err(dev, "dummy supplies not allowed\n");
1353 } 1351 }
1354#endif
1355 1352
1356 mutex_unlock(&regulator_list_mutex); 1353 mutex_unlock(&regulator_list_mutex);
1357 return regulator; 1354 return regulator;
@@ -1409,7 +1406,7 @@ out:
1409 */ 1406 */
1410struct regulator *regulator_get(struct device *dev, const char *id) 1407struct regulator *regulator_get(struct device *dev, const char *id)
1411{ 1408{
1412 return _regulator_get(dev, id, false); 1409 return _regulator_get(dev, id, false, true);
1413} 1410}
1414EXPORT_SYMBOL_GPL(regulator_get); 1411EXPORT_SYMBOL_GPL(regulator_get);
1415 1412
@@ -1436,7 +1433,7 @@ EXPORT_SYMBOL_GPL(regulator_get);
1436 */ 1433 */
1437struct regulator *regulator_get_exclusive(struct device *dev, const char *id) 1434struct regulator *regulator_get_exclusive(struct device *dev, const char *id)
1438{ 1435{
1439 return _regulator_get(dev, id, true); 1436 return _regulator_get(dev, id, true, false);
1440} 1437}
1441EXPORT_SYMBOL_GPL(regulator_get_exclusive); 1438EXPORT_SYMBOL_GPL(regulator_get_exclusive);
1442 1439
@@ -1465,7 +1462,7 @@ EXPORT_SYMBOL_GPL(regulator_get_exclusive);
1465 */ 1462 */
1466struct regulator *regulator_get_optional(struct device *dev, const char *id) 1463struct regulator *regulator_get_optional(struct device *dev, const char *id)
1467{ 1464{
1468 return _regulator_get(dev, id, 0); 1465 return _regulator_get(dev, id, false, false);
1469} 1466}
1470EXPORT_SYMBOL_GPL(regulator_get_optional); 1467EXPORT_SYMBOL_GPL(regulator_get_optional);
1471 1468
@@ -3664,22 +3661,6 @@ void regulator_has_full_constraints(void)
3664EXPORT_SYMBOL_GPL(regulator_has_full_constraints); 3661EXPORT_SYMBOL_GPL(regulator_has_full_constraints);
3665 3662
3666/** 3663/**
3667 * regulator_use_dummy_regulator - Provide a dummy regulator when none is found
3668 *
3669 * Calling this function will cause the regulator API to provide a
3670 * dummy regulator to consumers if no physical regulator is found,
3671 * allowing most consumers to proceed as though a regulator were
3672 * configured. This allows systems such as those with software
3673 * controllable regulators for the CPU core only to be brought up more
3674 * readily.
3675 */
3676void regulator_use_dummy_regulator(void)
3677{
3678 board_wants_dummy_regulator = true;
3679}
3680EXPORT_SYMBOL_GPL(regulator_use_dummy_regulator);
3681
3682/**
3683 * rdev_get_drvdata - get rdev regulator driver data 3664 * rdev_get_drvdata - get rdev regulator driver data
3684 * @rdev: regulator 3665 * @rdev: regulator
3685 * 3666 *