Skip to contentSkip to conversation

regulator: Make regulator_sync_voltage() usable by coupled regulators

PATCH Superseded Dmitry Osipenko 2 participants 3 messages Jan 21, 2021 – Jan 22, 2021

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 regulator: Make regulator_sync_voltage() usable by coupled regulators

Make regulator_sync_voltage() to re-balance voltage state of a coupled regulators instead of changing the voltage directly.

---

Changelog:

v3: - This patch is factored out from [1] to ease merging of the patches
that will use the regulator_sync_voltage(). The goal is to get this change merged into 5.12, it will remove dependency for the Tegra Core power domain driver which will target 5.13.

[1] https://patchwork.ozlabs.org/project/linux-tegra/list/?series=221130

 drivers/regulator/core.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/regulator/core.c +6 -0
index 3ae5ccd9277d..032d4e7df682 100644
@@ -4148,6 +4148,12 @@ int regulator_sync_voltage(struct regulator *regulator)
 	if (ret < 0)
 		goto out;
 
+	/* balance only if there are regulators coupled */
+	if (rdev->coupling_desc.n_coupled > 1) {
+		ret = regulator_balance_voltage(rdev, PM_SUSPEND_ON);
+		goto out;
+	}
+
 	ret = _regulator_do_set_voltage(rdev, min_uV, max_uV);
 
 out:
Signature · 1 line
2.29.2
maintainer
#1 lore raw

drivers/regulator/core.c int regulator_sync_voltage(struct regulator *regulator) · line 4159

Quoted 9 lines · Dmitry Osipenko
drivers/regulator/core.c +6 -0
+	/* balance only if there are regulators coupled */
+	if (rdev->coupling_desc.n_coupled > 1) {
+		ret = regulator_balance_voltage(rdev, PM_SUSPEND_ON);
+		goto out;
+	}
+
 	ret = _regulator_do_set_voltage(rdev, min_uV, max_uV);
 
 out:

This would be clearer written as an if/else rather than using the goto.

#2 lore raw

22.01.2021 16:40, Mark Brown пишет:

Quoted 10 lines · Dmitry Osipenko
Quoted 9 lines
drivers/regulator/core.c +6 -0
+	/* balance only if there are regulators coupled */
+	if (rdev->coupling_desc.n_coupled > 1) {
+		ret = regulator_balance_voltage(rdev, PM_SUSPEND_ON);
+		goto out;
+	}
+
 	ret = _regulator_do_set_voltage(rdev, min_uV, max_uV);
Quoted 4 lines
Quoted 1 line

out:

This would be clearer written as an if/else rather than using the goto.

I'll make v4, thanks.