Skip to content

Commit 4e2a354

Browse files
Oliver Bartabroonie
authored andcommitted
regulator: core: fix false positive in regulator_late_cleanup()
The check done by regulator_late_cleanup() to detect whether a regulator is on was inconsistent with the check done by _regulator_is_enabled(). While _regulator_is_enabled() takes the enable GPIO into account, regulator_late_cleanup() was not doing that. This resulted in a false positive, e.g. when a GPIO-controlled fixed regulator was used, which was not enabled at boot time, e.g. reg_disp_1v2: reg_disp_1v2 { compatible = "regulator-fixed"; regulator-name = "display_1v2"; regulator-min-microvolt = <1200000>; regulator-max-microvolt = <1200000>; gpio = <&tlmm 148 0>; enable-active-high; }; Such regulator doesn't have an is_enabled() operation. Nevertheless it's state can be determined based on the enable GPIO. The check in regulator_late_cleanup() wrongly assumed that the regulator is on and tried to disable it. Signed-off-by: Oliver Barta <oliver.barta@aptiv.com> Link: https://lore.kernel.org/r/20220208084645.8686-1-oliver.barta@aptiv.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent b4c18c1 commit 4e2a354

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

drivers/regulator/core.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6014,9 +6014,8 @@ core_initcall(regulator_init);
60146014
static int regulator_late_cleanup(struct device *dev, void *data)
60156015
{
60166016
struct regulator_dev *rdev = dev_to_rdev(dev);
6017-
const struct regulator_ops *ops = rdev->desc->ops;
60186017
struct regulation_constraints *c = rdev->constraints;
6019-
int enabled, ret;
6018+
int ret;
60206019

60216020
if (c && c->always_on)
60226021
return 0;
@@ -6029,14 +6028,8 @@ static int regulator_late_cleanup(struct device *dev, void *data)
60296028
if (rdev->use_count)
60306029
goto unlock;
60316030

6032-
/* If we can't read the status assume it's always on. */
6033-
if (ops->is_enabled)
6034-
enabled = ops->is_enabled(rdev);
6035-
else
6036-
enabled = 1;
6037-
6038-
/* But if reading the status failed, assume that it's off. */
6039-
if (enabled <= 0)
6031+
/* If reading the status failed, assume that it's off. */
6032+
if (_regulator_is_enabled(rdev) <= 0)
60406033
goto unlock;
60416034

60426035
if (have_full_constraints()) {

0 commit comments

Comments
 (0)