diff options
-rw-r--r-- | drivers/regulator/core.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index ae0a559d1978..f211aa7da44e 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1399,11 +1399,21 @@ static int set_machine_constraints(struct regulator_dev *rdev, * and we have control then make sure it is enabled. */ if (rdev->constraints->always_on || rdev->constraints->boot_on) { + if (rdev->supply) { + ret = regulator_enable(rdev->supply); + if (ret < 0) { + _regulator_put(rdev->supply); + rdev->supply = NULL; + return ret; + } + } + ret = _regulator_do_enable(rdev); if (ret < 0 && ret != -EINVAL) { rdev_err(rdev, "failed to enable\n"); return ret; } + rdev->use_count++; } print_constraints(rdev); @@ -1820,15 +1830,18 @@ static int regulator_resolve_supply(struct regulator_dev *rdev) return ret; } - /* Cascade always-on state to supply */ - if (_regulator_is_enabled(rdev)) { + /* + * In set_machine_constraints() we may have turned this regulator on + * but we couldn't propagate to the supply if it hadn't been resolved + * yet. Do it now. + */ + if (rdev->use_count) { ret = regulator_enable(rdev->supply); if (ret < 0) { _regulator_put(rdev->supply); rdev->supply = NULL; return ret; } - rdev->use_count = 1; } return 0; |