Skip to content

Commit e4ead3c

Browse files
kmaincentbroonie
authored andcommitted
regulator: core: Propagate the regulator state in case of exclusive get
Previously, performing an exclusive get on an already-enabled regulator resulted in inconsistent state initialization between child and parent regulators. While the child's counts were updated, its parent's counters remained unaffected. Consequently, attempting to disable an already-enabled exclusive regulator triggered unbalanced disables warnings from its parent regulator. This commit addresses the issue by propagating the enable state to the parent regulator using a regulator_enable call. This ensures consistent state management across the regulator hierarchy, preventing warnings! Signed-off-by: Kory Maincent <kory.maincent@bootlin.com> Link: https://msgid.link/r/20240312091638.1266167-1-kory.maincent@bootlin.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent e6f0b08 commit e4ead3c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/regulator/core.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,6 +2274,17 @@ struct regulator *_regulator_get(struct device *dev, const char *id,
22742274
if (ret > 0) {
22752275
rdev->use_count = 1;
22762276
regulator->enable_count = 1;
2277+
2278+
/* Propagate the regulator state to its supply */
2279+
if (rdev->supply) {
2280+
ret = regulator_enable(rdev->supply);
2281+
if (ret < 0) {
2282+
destroy_regulator(regulator);
2283+
module_put(rdev->owner);
2284+
put_device(&rdev->dev);
2285+
return ERR_PTR(ret);
2286+
}
2287+
}
22772288
} else {
22782289
rdev->use_count = 0;
22792290
regulator->enable_count = 0;

0 commit comments

Comments
 (0)