aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/core.c
diff options
context:
space:
mode:
authorChristian Kohlschütter <christian@kohlschutter.com>2022-07-19 16:02:00 +0200
committerMark Brown <broonie@kernel.org>2022-07-19 18:47:19 +0100
commit218320fec29430438016f88dd4fbebfa1b95ad8d (patch)
treeb4ddef029db6377e42075cd93280cdd0d645978c /drivers/regulator/core.c
parentregulator: of: Fix refcount leak bug in of_get_regulation_constraints() (diff)
downloadlinux-dev-218320fec29430438016f88dd4fbebfa1b95ad8d.tar.xz
linux-dev-218320fec29430438016f88dd4fbebfa1b95ad8d.zip
regulator: core: Fix off-on-delay-us for always-on/boot-on regulators
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> Link: https://lore.kernel.org/r/FAFD5B39-E9C4-47C7-ACF1-2A04CD59758D@kohlschutter.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r--drivers/regulator/core.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 1e54a833f2cf..398c8d6afd47 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1565,6 +1565,9 @@ static int set_machine_constraints(struct regulator_dev *rdev)
rdev->constraints->always_on = true;
}
+ 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.
*/
@@ -1592,8 +1595,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);