regulator: core: check whether the regulator is being on at startup

If the regulator is enabled, don't have to enable it again.

Signed-off-by: shengfei Xu <xsf@rock-chips.com>
Change-Id: I293b9002b6373f977313b410709b0e9ad916243d
This commit is contained in:
shengfei Xu
2020-07-09 21:20:49 +08:00
committed by Tao Huang
parent 972d5ed2eb
commit 94e7a45020

View File

@@ -1195,10 +1195,13 @@ 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) {
ret = _regulator_do_enable(rdev);
if (ret < 0 && ret != -EINVAL) {
rdev_err(rdev, "failed to enable\n");
return ret;
/* The regulator may on if it's not switchable or left on */
if (!_regulator_is_enabled(rdev)) {
ret = _regulator_do_enable(rdev);
if (ret < 0 && ret != -EINVAL) {
rdev_err(rdev, "failed to enable\n");
return ret;
}
}
}