Skip to content

Commit 261f063

Browse files
committed
regulator: Flag uncontrollable regulators as always_on
While we currently assume that regulators with no control available are just uncontionally enabled this isn't always as clearly displayed to users as is desirable, for example the code for disabling unused regulators will log that it is about to disable them. Clean this up a bit by setting always_on during constraint evaluation if we have no available mechanism for controlling the regualtor so things that check the constraint will do the right thing. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20220325144637.1543496-1-broonie@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 6c315af commit 261f063

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

drivers/regulator/core.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,24 @@ static int set_machine_constraints(struct regulator_dev *rdev)
15221522
}
15231523
}
15241524

1525+
/*
1526+
* If there is no mechanism for controlling the regulator then
1527+
* flag it as always_on so we don't end up duplicating checks
1528+
* for this so much. Note that we could control the state of
1529+
* a supply to control the output on a regulator that has no
1530+
* direct control.
1531+
*/
1532+
if (!rdev->ena_pin && !ops->enable) {
1533+
if (rdev->supply_name && !rdev->supply)
1534+
return -EPROBE_DEFER;
1535+
1536+
if (rdev->supply)
1537+
rdev->constraints->always_on =
1538+
rdev->supply->rdev->constraints->always_on;
1539+
else
1540+
rdev->constraints->always_on = true;
1541+
}
1542+
15251543
/* If the constraints say the regulator should be on at this point
15261544
* and we have control then make sure it is enabled.
15271545
*/

0 commit comments

Comments
 (0)