Skip to content

Commit 4f3323b

Browse files
andredbroonie
authored andcommitted
regulator: core: streamline supply resolution for always-on/boot-on regulators
For always-on and boot-on regulators, regulator_register() is currently trying to anticipate the requirement to resolve a supply early. Unfortunately, this code executes too early, before we have potentially updated the regulator's always_on constraint as part of set_machine_constraints(), causing it to miss cases. Rather than trying to hack it more, just defer to the outcome of set_machine_constraints(). The latter returns early (without doing any regulator initialisation) with -EPROBE_DEFER as of commit 'regulator: core: move supply check earlier in set_machine_constraints()' and is therefore safe to call multiple times to determine if supplies need to be resolved early. Commit 8a866d5 ("regulator: core: Resolve supply name earlier to prevent double-init") (later updated by commit 520fb17 ("regulator: core: Fix regulator supply registration with sysfs")) added these tests originally to avoid calling set_machine_constraints() multiple times to try to avoid voltage glitches due to all the regulator initialisation happening each time. This isn't an issue anymore as per above. Signed-off-by: André Draszik <andre.draszik@linaro.org> Link: https://patch.msgid.link/20260109-regulators-defer-v2-4-1a25dc968e60@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 86a8eeb commit 4f3323b

1 file changed

Lines changed: 4 additions & 15 deletions

File tree

drivers/regulator/core.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5937,7 +5937,6 @@ regulator_register(struct device *dev,
59375937
bool dangling_cfg_gpiod = false;
59385938
bool dangling_of_gpiod = false;
59395939
int ret, i;
5940-
bool resolved_early = false;
59415940

59425941
if (cfg == NULL)
59435942
return ERR_PTR(-EINVAL);
@@ -6075,17 +6074,6 @@ regulator_register(struct device *dev,
60756074
goto wash;
60766075
}
60776076

6078-
if ((rdev->supply_name && !rdev->supply) &&
6079-
(rdev->constraints->always_on ||
6080-
rdev->constraints->boot_on)) {
6081-
ret = regulator_resolve_supply(rdev);
6082-
if (ret)
6083-
rdev_dbg(rdev, "unable to resolve supply early: %pe\n",
6084-
ERR_PTR(ret));
6085-
6086-
resolved_early = true;
6087-
}
6088-
60896077
if (config->ena_gpiod) {
60906078
ret = regulator_ena_gpio_request(rdev, config);
60916079
if (ret != 0) {
@@ -6099,9 +6087,10 @@ regulator_register(struct device *dev,
60996087
}
61006088

61016089
ret = set_machine_constraints(rdev);
6102-
if (ret == -EPROBE_DEFER && !resolved_early) {
6103-
/* Regulator might be in bypass mode and so needs its supply
6104-
* to set the constraints
6090+
if (ret == -EPROBE_DEFER) {
6091+
/* Regulator might be in bypass mode or an always-on or boot-on
6092+
* regulator and so needs its supply to set the constraints or
6093+
* for enable.
61056094
*/
61066095
/* FIXME: this currently triggers a chicken-and-egg problem
61076096
* when creating -SUPPLY symlink in sysfs to a regulator

0 commit comments

Comments
 (0)