Skip to contentSkip to conversation

regulator: core: Propagate the regulator state in case of exclusive get

PATCH In review Kory Maincent 2 participants 2 messages Mar 12, 2024 Voltage and current regulator framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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!

---
 drivers/regulator/core.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/regulator/core.c +11 -0
index a968dabb48f5..3f499761f8b0 100644
@@ -2274,6 +2274,17 @@ struct regulator *_regulator_get(struct device *dev, const char *id,
 		if (ret > 0) {
 			rdev->use_count = 1;
 			regulator->enable_count = 1;
+
+			/* Propagate the regulator state to its supply */
+			if (rdev->supply) {
+				ret = regulator_enable(rdev->supply);
+				if (ret < 0) {
+					destroy_regulator(regulator);
+					module_put(rdev->owner);
+					put_device(&rdev->dev);
+					return ERR_PTR(ret);
+				}
+			}
 		} else {
 			rdev->use_count = 0;
 			regulator->enable_count = 0;
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 9 lines · Kory Maincent

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.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[1/1] regulator: core: Propagate the regulator state in case of exclusive get

      commit: e4ead3cdfd798092288f3a06b405cf98ded6fa10

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark