All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: Flag uncontrollable regulators as always_on
@ 2022-03-25 14:46 Mark Brown
  2022-04-05  9:32 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Brown @ 2022-03-25 14:46 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: linux-kernel, Mark Brown

While we currently assume that regulators with no control available are
just uncontionally enabled this isn't always as clearly displayed to
users as is desirable, for example the code for disabling unused
regulators will log that it is about to disable them. Clean this up a
bit by setting always_on during constraint evaluation if we have no
available mechanism for controlling the regualtor so things that check
the constraint will do the right thing.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/regulator/core.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index d2553970a67b..a8a95d09ca11 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1522,6 +1522,24 @@ static int set_machine_constraints(struct regulator_dev *rdev)
 		}
 	}
 
+	/*
+	 * If there is no mechanism for controlling the regulator then
+	 * flag it as always_on so we don't end up duplicating checks
+	 * for this so much.  Note that we could control the state of
+	 * a supply to control the output on a regulator that has no
+	 * direct control.
+	 */
+	if (!rdev->ena_pin && !ops->enable) {
+		if (rdev->supply_name && !rdev->supply)
+			return -EPROBE_DEFER;
+
+		if (rdev->supply)
+			rdev->constraints->always_on =
+				rdev->supply->rdev->constraints->always_on;
+		else
+			rdev->constraints->always_on = true;
+	}
+
 	/* If the constraints say the regulator should be on at this point
 	 * and we have control then make sure it is enabled.
 	 */
-- 
2.30.2


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

* Re: [PATCH] regulator: Flag uncontrollable regulators as always_on
  2022-03-25 14:46 [PATCH] regulator: Flag uncontrollable regulators as always_on Mark Brown
@ 2022-04-05  9:32 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2022-04-05  9:32 UTC (permalink / raw)
  To: broonie, lgirdwood; +Cc: linux-kernel

On Fri, 25 Mar 2022 14:46:37 +0000, Mark Brown wrote:
> While we currently assume that regulators with no control available are
> just uncontionally enabled this isn't always as clearly displayed to
> users as is desirable, for example the code for disabling unused
> regulators will log that it is about to disable them. Clean this up a
> bit by setting always_on during constraint evaluation if we have no
> available mechanism for controlling the regualtor so things that check
> the constraint will do the right thing.
> 
> [...]

Applied to

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

Thanks!

[1/1] regulator: Flag uncontrollable regulators as always_on
      commit: 261f06315cf7c3744731e36bfd8d4434949e3389

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

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

end of thread, other threads:[~2022-04-05 15:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-25 14:46 [PATCH] regulator: Flag uncontrollable regulators as always_on Mark Brown
2022-04-05  9:32 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.