Skip to content

Commit aef393d

Browse files
committed
Merge remote-tracking branch 'regulator/topic/optional' into regulator-next
2 parents 88c260a + 4040394 commit aef393d

3 files changed

Lines changed: 15 additions & 49 deletions

File tree

‎drivers/regulator/Kconfig‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@ config REGULATOR_DEBUG
2828
help
2929
Say yes here to enable debugging support.
3030

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-
4131
config REGULATOR_FIXED_VOLTAGE
4232
tristate "Fixed voltage regulator support"
4333
help

‎drivers/regulator/core.c‎

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ static LIST_HEAD(regulator_map_list);
5555
static LIST_HEAD(regulator_ena_gpio_list);
5656
static LIST_HEAD(regulator_supply_alias_list);
5757
static bool has_full_constraints;
58-
static bool board_wants_dummy_regulator;
5958

6059
static struct dentry *debugfs_root;
6160

@@ -1303,12 +1302,12 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
13031302

13041303
/* Internal regulator request function */
13051304
static struct regulator *_regulator_get(struct device *dev, const char *id,
1306-
bool exclusive)
1305+
bool exclusive, bool allow_dummy)
13071306
{
13081307
struct regulator_dev *rdev;
13091308
struct regulator *regulator = ERR_PTR(-EPROBE_DEFER);
13101309
const char *devname = NULL;
1311-
int ret = 0;
1310+
int ret = -EPROBE_DEFER;
13121311

13131312
if (id == NULL) {
13141313
pr_err("get() with no identifier\n");
@@ -1324,34 +1323,32 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
13241323
if (rdev)
13251324
goto found;
13261325

1326+
regulator = ERR_PTR(ret);
1327+
13271328
/*
13281329
* If we have return value from dev_lookup fail, we do not expect to
13291330
* succeed, so, quit with appropriate error value
13301331
*/
1331-
if (ret) {
1332-
regulator = ERR_PTR(ret);
1332+
if (ret && ret != -ENODEV) {
13331333
goto out;
13341334
}
13351335

1336-
if (board_wants_dummy_regulator) {
1337-
rdev = dummy_regulator_rdev;
1338-
goto found;
1339-
}
1340-
1341-
#ifdef CONFIG_REGULATOR_DUMMY
13421336
if (!devname)
13431337
devname = "deviceless";
13441338

1345-
/* If the board didn't flag that it was fully constrained then
1346-
* substitute in a dummy regulator so consumers can continue.
1339+
/*
1340+
* Assume that a regulator is physically present and enabled
1341+
* even if it isn't hooked up and just provide a dummy.
13471342
*/
1348-
if (!has_full_constraints) {
1343+
if (has_full_constraints && allow_dummy) {
13491344
pr_warn("%s supply %s not found, using dummy regulator\n",
13501345
devname, id);
1346+
13511347
rdev = dummy_regulator_rdev;
13521348
goto found;
1349+
} else {
1350+
dev_err(dev, "dummy supplies not allowed\n");
13531351
}
1354-
#endif
13551352

13561353
mutex_unlock(&regulator_list_mutex);
13571354
return regulator;
@@ -1409,7 +1406,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
14091406
*/
14101407
struct regulator *regulator_get(struct device *dev, const char *id)
14111408
{
1412-
return _regulator_get(dev, id, false);
1409+
return _regulator_get(dev, id, false, true);
14131410
}
14141411
EXPORT_SYMBOL_GPL(regulator_get);
14151412

@@ -1436,7 +1433,7 @@ EXPORT_SYMBOL_GPL(regulator_get);
14361433
*/
14371434
struct regulator *regulator_get_exclusive(struct device *dev, const char *id)
14381435
{
1439-
return _regulator_get(dev, id, true);
1436+
return _regulator_get(dev, id, true, false);
14401437
}
14411438
EXPORT_SYMBOL_GPL(regulator_get_exclusive);
14421439

@@ -1465,7 +1462,7 @@ EXPORT_SYMBOL_GPL(regulator_get_exclusive);
14651462
*/
14661463
struct regulator *regulator_get_optional(struct device *dev, const char *id)
14671464
{
1468-
return _regulator_get(dev, id, 0);
1465+
return _regulator_get(dev, id, false, false);
14691466
}
14701467
EXPORT_SYMBOL_GPL(regulator_get_optional);
14711468

@@ -3663,22 +3660,6 @@ void regulator_has_full_constraints(void)
36633660
}
36643661
EXPORT_SYMBOL_GPL(regulator_has_full_constraints);
36653662

3666-
/**
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-
*/
3676-
void regulator_use_dummy_regulator(void)
3677-
{
3678-
board_wants_dummy_regulator = true;
3679-
}
3680-
EXPORT_SYMBOL_GPL(regulator_use_dummy_regulator);
3681-
36823663
/**
36833664
* rdev_get_drvdata - get rdev regulator driver data
36843665
* @rdev: regulator

‎include/linux/regulator/machine.h‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,10 @@ int regulator_suspend_finish(void);
195195

196196
#ifdef CONFIG_REGULATOR
197197
void regulator_has_full_constraints(void);
198-
void regulator_use_dummy_regulator(void);
199198
#else
200199
static inline void regulator_has_full_constraints(void)
201200
{
202201
}
203-
204-
static inline void regulator_use_dummy_regulator(void)
205-
{
206-
}
207202
#endif
208203

209204
#endif

0 commit comments

Comments
 (0)