diff options
author | Mark Brown <broonie@linaro.org> | 2013-09-13 14:50:37 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-09-16 19:30:25 -0400 |
commit | 4ddfebd3b0d5b65c69492408bb67fd1202104643 (patch) | |
tree | 75f540d31a044399680db0f8a8b756f733b39ffb | |
parent | 272b98c6455f00884f0350f775c5342358ebb73f (diff) |
regulator: core: Provide a dummy regulator with full constraints
When a system has said that it has fully specified constraints for its
regulators it is still possible that some supplies may be missing,
especially if regulator support has been added to a driver after the
board was integrated. We can handle such situations more gracefully by
providing a dummy regulator.
Unless the caller has specifically indicated that the system design may
not include a given regulator by using regulator_get_optional() or that
it needs its interactions to have an effect using regulator_get_exclusive()
provide a dummy regulator if we can't locate a real one.
The kconfig option REGULATOR_DUMMY that provided similar behaviour for all
regulators has been removed, systems that need it should flag that they
have full constraints instead.
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/regulator/Kconfig | 10 | ||||
-rw-r--r-- | drivers/regulator/core.c | 36 |
2 files changed, 19 insertions, 27 deletions
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index dfe58096b374..0417ce327cd8 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig | |||
@@ -28,16 +28,6 @@ config REGULATOR_DEBUG | |||
28 | help | 28 | help |
29 | Say yes here to enable debugging support. | 29 | Say yes here to enable debugging support. |
30 | 30 | ||
31 | config REGULATOR_DUMMY | ||
32 | bool "Provide a dummy regulator if regulator lookups fail" | ||
33 | help | ||
34 | If this option is enabled then when a regulator lookup fails | ||
35 | and the board has not specified that it has provided full | ||
36 | constraints the regulator core will provide an always | ||
37 | enabled dummy regulator, allowing consumer drivers to continue. | ||
38 | |||
39 | A warning will be generated when this substitution is done. | ||
40 | |||
41 | config REGULATOR_FIXED_VOLTAGE | 31 | config REGULATOR_FIXED_VOLTAGE |
42 | tristate "Fixed voltage regulator support" | 32 | tristate "Fixed voltage regulator support" |
43 | help | 33 | help |
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a01b8b3b70ca..8fd170788c3e 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -1243,7 +1243,7 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev, | |||
1243 | 1243 | ||
1244 | /* Internal regulator request function */ | 1244 | /* Internal regulator request function */ |
1245 | static struct regulator *_regulator_get(struct device *dev, const char *id, | 1245 | static struct regulator *_regulator_get(struct device *dev, const char *id, |
1246 | bool exclusive) | 1246 | bool exclusive, bool allow_dummy) |
1247 | { | 1247 | { |
1248 | struct regulator_dev *rdev; | 1248 | struct regulator_dev *rdev; |
1249 | struct regulator *regulator = ERR_PTR(-EPROBE_DEFER); | 1249 | struct regulator *regulator = ERR_PTR(-EPROBE_DEFER); |
@@ -1268,30 +1268,32 @@ static struct regulator *_regulator_get(struct device *dev, const char *id, | |||
1268 | * If we have return value from dev_lookup fail, we do not expect to | 1268 | * If we have return value from dev_lookup fail, we do not expect to |
1269 | * succeed, so, quit with appropriate error value | 1269 | * succeed, so, quit with appropriate error value |
1270 | */ | 1270 | */ |
1271 | if (ret) { | 1271 | if (ret && ret != -ENODEV) { |
1272 | regulator = ERR_PTR(ret); | 1272 | regulator = ERR_PTR(ret); |
1273 | goto out; | 1273 | goto out; |
1274 | } | 1274 | } |
1275 | 1275 | ||
1276 | if (board_wants_dummy_regulator) { | ||
1277 | rdev = dummy_regulator_rdev; | ||
1278 | goto found; | ||
1279 | } | ||
1280 | |||
1281 | #ifdef CONFIG_REGULATOR_DUMMY | ||
1282 | if (!devname) | 1276 | if (!devname) |
1283 | devname = "deviceless"; | 1277 | devname = "deviceless"; |
1284 | 1278 | ||
1285 | /* If the board didn't flag that it was fully constrained then | 1279 | /* |
1286 | * substitute in a dummy regulator so consumers can continue. | 1280 | * Assume that a regulator is physically present and enabled |
1281 | * even if it isn't hooked up and just provide a dummy. | ||
1287 | */ | 1282 | */ |
1288 | if (!has_full_constraints) { | 1283 | if (has_full_constraints && allow_dummy) { |
1289 | pr_warn("%s supply %s not found, using dummy regulator\n", | 1284 | /* |
1290 | devname, id); | 1285 | * Log the substitution if regulator configuration is |
1286 | * not complete to help development. | ||
1287 | */ | ||
1288 | if (!has_full_constraints) | ||
1289 | pr_warn("%s supply %s not found, using dummy regulator\n", | ||
1290 | devname, id); | ||
1291 | |||
1291 | rdev = dummy_regulator_rdev; | 1292 | rdev = dummy_regulator_rdev; |
1292 | goto found; | 1293 | goto found; |
1294 | } else { | ||
1295 | dev_err(dev, "dummy supplies not allowed\n"); | ||
1293 | } | 1296 | } |
1294 | #endif | ||
1295 | 1297 | ||
1296 | mutex_unlock(®ulator_list_mutex); | 1298 | mutex_unlock(®ulator_list_mutex); |
1297 | return regulator; | 1299 | return regulator; |
@@ -1349,7 +1351,7 @@ out: | |||
1349 | */ | 1351 | */ |
1350 | struct regulator *regulator_get(struct device *dev, const char *id) | 1352 | struct regulator *regulator_get(struct device *dev, const char *id) |
1351 | { | 1353 | { |
1352 | return _regulator_get(dev, id, false); | 1354 | return _regulator_get(dev, id, false, true); |
1353 | } | 1355 | } |
1354 | EXPORT_SYMBOL_GPL(regulator_get); | 1356 | EXPORT_SYMBOL_GPL(regulator_get); |
1355 | 1357 | ||
@@ -1410,7 +1412,7 @@ EXPORT_SYMBOL_GPL(devm_regulator_get); | |||
1410 | */ | 1412 | */ |
1411 | struct regulator *regulator_get_exclusive(struct device *dev, const char *id) | 1413 | struct regulator *regulator_get_exclusive(struct device *dev, const char *id) |
1412 | { | 1414 | { |
1413 | return _regulator_get(dev, id, true); | 1415 | return _regulator_get(dev, id, true, false); |
1414 | } | 1416 | } |
1415 | EXPORT_SYMBOL_GPL(regulator_get_exclusive); | 1417 | EXPORT_SYMBOL_GPL(regulator_get_exclusive); |
1416 | 1418 | ||
@@ -1439,7 +1441,7 @@ EXPORT_SYMBOL_GPL(regulator_get_exclusive); | |||
1439 | */ | 1441 | */ |
1440 | struct regulator *regulator_get_optional(struct device *dev, const char *id) | 1442 | struct regulator *regulator_get_optional(struct device *dev, const char *id) |
1441 | { | 1443 | { |
1442 | return _regulator_get(dev, id, 0); | 1444 | return _regulator_get(dev, id, false, false); |
1443 | } | 1445 | } |
1444 | EXPORT_SYMBOL_GPL(regulator_get_optional); | 1446 | EXPORT_SYMBOL_GPL(regulator_get_optional); |
1445 | 1447 | ||