linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] regulator: Make regulator_sync_voltage() usable by coupled regulators
@ 2021-01-21 22:16 Dmitry Osipenko
  2021-01-22 13:40 ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Osipenko @ 2021-01-21 22:16 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, Mark Brown, Liam Girdwood,
	Peter Geis, Nicolas Chauvet, Matt Merhar
  Cc: linux-kernel, linux-tegra

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

Tested-by: Peter Geis <pgwipeout@gmail.com> # Ouya T30
Tested-by: Dmitry Osipenko <digetx@gmail.com> # A500 T20 and Nexus7 T30
Tested-by: Nicolas Chauvet <kwizart@gmail.com> # PAZ00 T20
Tested-by: Matt Merhar <mattmerhar@protonmail.com> # Ouya T30
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---

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(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 3ae5ccd9277d..032d4e7df682 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -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:
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] regulator: Make regulator_sync_voltage() usable by coupled regulators
  2021-01-21 22:16 [PATCH v3] regulator: Make regulator_sync_voltage() usable by coupled regulators Dmitry Osipenko
@ 2021-01-22 13:40 ` Mark Brown
  2021-01-22 16:00   ` Dmitry Osipenko
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2021-01-22 13:40 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Thierry Reding, Jonathan Hunter, Liam Girdwood, Peter Geis,
	Nicolas Chauvet, Matt Merhar, linux-kernel, linux-tegra

[-- Attachment #1: Type: text/plain, Size: 407 bytes --]

On Fri, Jan 22, 2021 at 01:16:49AM +0300, Dmitry Osipenko wrote:

> +	/* 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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] regulator: Make regulator_sync_voltage() usable by coupled regulators
  2021-01-22 13:40 ` Mark Brown
@ 2021-01-22 16:00   ` Dmitry Osipenko
  0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Osipenko @ 2021-01-22 16:00 UTC (permalink / raw)
  To: Mark Brown
  Cc: Thierry Reding, Jonathan Hunter, Liam Girdwood, Peter Geis,
	Nicolas Chauvet, Matt Merhar, linux-kernel, linux-tegra

22.01.2021 16:40, Mark Brown пишет:
> On Fri, Jan 22, 2021 at 01:16:49AM +0300, Dmitry Osipenko wrote:
> 
>> +	/* 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.
> 

I'll make v4, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-22 16:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-21 22:16 [PATCH v3] regulator: Make regulator_sync_voltage() usable by coupled regulators Dmitry Osipenko
2021-01-22 13:40 ` Mark Brown
2021-01-22 16:00   ` Dmitry Osipenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).