Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge remote-tracking branch 'regulator/topic/optional' into regulator-next

+15 -49
-10
drivers/regulator/Kconfig
··· 28 28 help 29 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 31 config REGULATOR_FIXED_VOLTAGE 42 32 tristate "Fixed voltage regulator support" 43 33 help
+15 -34
drivers/regulator/core.c
··· 55 55 static LIST_HEAD(regulator_ena_gpio_list); 56 56 static LIST_HEAD(regulator_supply_alias_list); 57 57 static bool has_full_constraints; 58 - static bool board_wants_dummy_regulator; 59 58 60 59 static struct dentry *debugfs_root; 61 60 ··· 1302 1303 1303 1304 /* Internal regulator request function */ 1304 1305 static struct regulator *_regulator_get(struct device *dev, const char *id, 1305 - bool exclusive) 1306 + bool exclusive, bool allow_dummy) 1306 1307 { 1307 1308 struct regulator_dev *rdev; 1308 1309 struct regulator *regulator = ERR_PTR(-EPROBE_DEFER); 1309 1310 const char *devname = NULL; 1310 - int ret = 0; 1311 + int ret = -EPROBE_DEFER; 1311 1312 1312 1313 if (id == NULL) { 1313 1314 pr_err("get() with no identifier\n"); ··· 1323 1324 if (rdev) 1324 1325 goto found; 1325 1326 1327 + regulator = ERR_PTR(ret); 1328 + 1326 1329 /* 1327 1330 * If we have return value from dev_lookup fail, we do not expect to 1328 1331 * succeed, so, quit with appropriate error value 1329 1332 */ 1330 - if (ret) { 1331 - regulator = ERR_PTR(ret); 1333 + if (ret && ret != -ENODEV) { 1332 1334 goto out; 1333 1335 } 1334 1336 1335 - if (board_wants_dummy_regulator) { 1336 - rdev = dummy_regulator_rdev; 1337 - goto found; 1338 - } 1339 - 1340 - #ifdef CONFIG_REGULATOR_DUMMY 1341 1337 if (!devname) 1342 1338 devname = "deviceless"; 1343 1339 1344 - /* If the board didn't flag that it was fully constrained then 1345 - * substitute in a dummy regulator so consumers can continue. 1340 + /* 1341 + * Assume that a regulator is physically present and enabled 1342 + * even if it isn't hooked up and just provide a dummy. 1346 1343 */ 1347 - if (!has_full_constraints) { 1344 + if (has_full_constraints && allow_dummy) { 1348 1345 pr_warn("%s supply %s not found, using dummy regulator\n", 1349 1346 devname, id); 1347 + 1350 1348 rdev = dummy_regulator_rdev; 1351 1349 goto found; 1350 + } else { 1351 + dev_err(dev, "dummy supplies not allowed\n"); 1352 1352 } 1353 - #endif 1354 1353 1355 1354 mutex_unlock(&regulator_list_mutex); 1356 1355 return regulator; ··· 1406 1409 */ 1407 1410 struct regulator *regulator_get(struct device *dev, const char *id) 1408 1411 { 1409 - return _regulator_get(dev, id, false); 1412 + return _regulator_get(dev, id, false, true); 1410 1413 } 1411 1414 EXPORT_SYMBOL_GPL(regulator_get); 1412 1415 ··· 1433 1436 */ 1434 1437 struct regulator *regulator_get_exclusive(struct device *dev, const char *id) 1435 1438 { 1436 - return _regulator_get(dev, id, true); 1439 + return _regulator_get(dev, id, true, false); 1437 1440 } 1438 1441 EXPORT_SYMBOL_GPL(regulator_get_exclusive); 1439 1442 ··· 1462 1465 */ 1463 1466 struct regulator *regulator_get_optional(struct device *dev, const char *id) 1464 1467 { 1465 - return _regulator_get(dev, id, 0); 1468 + return _regulator_get(dev, id, false, false); 1466 1469 } 1467 1470 EXPORT_SYMBOL_GPL(regulator_get_optional); 1468 1471 ··· 3659 3662 has_full_constraints = 1; 3660 3663 } 3661 3664 EXPORT_SYMBOL_GPL(regulator_has_full_constraints); 3662 - 3663 - /** 3664 - * regulator_use_dummy_regulator - Provide a dummy regulator when none is found 3665 - * 3666 - * Calling this function will cause the regulator API to provide a 3667 - * dummy regulator to consumers if no physical regulator is found, 3668 - * allowing most consumers to proceed as though a regulator were 3669 - * configured. This allows systems such as those with software 3670 - * controllable regulators for the CPU core only to be brought up more 3671 - * readily. 3672 - */ 3673 - void regulator_use_dummy_regulator(void) 3674 - { 3675 - board_wants_dummy_regulator = true; 3676 - } 3677 - EXPORT_SYMBOL_GPL(regulator_use_dummy_regulator); 3678 3665 3679 3666 /** 3680 3667 * rdev_get_drvdata - get rdev regulator driver data
-5
include/linux/regulator/machine.h
··· 195 195 196 196 #ifdef CONFIG_REGULATOR 197 197 void regulator_has_full_constraints(void); 198 - void regulator_use_dummy_regulator(void); 199 198 #else 200 199 static inline void regulator_has_full_constraints(void) 201 - { 202 - } 203 - 204 - static inline void regulator_use_dummy_regulator(void) 205 200 { 206 201 } 207 202 #endif