linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] regulator: core: Fix off-on-delay-us for always-on/boot-on regulators
@ 2022-07-17 11:30 Christian Kohlschuetter
  2022-07-17 11:39 ` Christian Kohlschütter
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Christian Kohlschuetter @ 2022-07-17 11:30 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, linux-kernel

Regulators marked with "regulator-always-on" or "regulator-boot-on"
as well as an "off-on-delay-us", may run into cycling issues that are
hard to detect.

This is caused by the "last_off" state not being initialized in this
case.

Fix the "last_off" initialization by setting it to the current kernel
time upon initialization, regardless of always_on/boot_on state.

Signed-off-by: Christian Kohlschütter <christian@kohlschutter.com>
---
 drivers/regulator/core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index c4d844ffad7a..48ed33ad48c8 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1522,6 +1522,9 @@ static int set_machine_constraints(struct regulator_dev *rdev)
 		}
 	}
 
+	if (rdev->desc->off_on_delay)
+		rdev->last_off = ktime_get();
+
 	/* If the constraints say the regulator should be on at this point
 	 * and we have control then make sure it is enabled.
 	 */
@@ -1549,8 +1552,6 @@ static int set_machine_constraints(struct regulator_dev *rdev)
 
 		if (rdev->constraints->always_on)
 			rdev->use_count++;
-	} else if (rdev->desc->off_on_delay) {
-		rdev->last_off = ktime_get();
 	}
 
 	print_constraints(rdev);
-- 
2.36.1



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

end of thread, other threads:[~2022-07-19 19:39 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-17 11:30 [PATCH] regulator: core: Fix off-on-delay-us for always-on/boot-on regulators Christian Kohlschuetter
2022-07-17 11:39 ` Christian Kohlschütter
2022-07-17 11:49   ` Christian Kohlschütter
2022-07-18 12:36 ` Mark Brown
2022-07-18 17:24   ` [PATCH REBASE] " Christian Kohlschuetter
2022-07-19 13:57     ` [PATCH] " Mark Brown
2022-07-19 14:02       ` Christian Kohlschuetter
2022-07-19 14:02     ` [PATCH REBASE] " Christian Kohlschütter
2022-07-19 14:27       ` Mark Brown
2022-07-19 14:29       ` Mark Brown
2022-07-19 18:49         ` Christian Kohlschütter
2022-07-19 19:38           ` Mark Brown
2022-07-19 19:39             ` Christian Kohlschütter
2022-07-19 18:48       ` Mark Brown
2022-07-19 18:54         ` Christian Kohlschütter
2022-07-19 18:48     ` Mark Brown
2022-07-19 18:48 ` [PATCH] " Mark Brown

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).