Patch "regulator: core: fix false positive in regulator_late_cleanup()" has been added to the 5.16-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    regulator: core: fix false positive in regulator_late_cleanup()

to the 5.16-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     regulator-core-fix-false-positive-in-regulator_late_.patch
and it can be found in the queue-5.16 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 3da3c0ce897ebf1927c419f4cb98dfd13cd6e4cc
Author: Oliver Barta <oliver.barta@xxxxxxxxx>
Date:   Tue Feb 8 09:46:45 2022 +0100

    regulator: core: fix false positive in regulator_late_cleanup()
    
    [ Upstream commit 4e2a354e3775870ca823f1fb29bbbffbe11059a6 ]
    
    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@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20220208084645.8686-1-oliver.barta@xxxxxxxxx
    Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 86aa4141efa92..d2553970a67ba 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -6014,9 +6014,8 @@ core_initcall(regulator_init);
 static int regulator_late_cleanup(struct device *dev, void *data)
 {
 	struct regulator_dev *rdev = dev_to_rdev(dev);
-	const struct regulator_ops *ops = rdev->desc->ops;
 	struct regulation_constraints *c = rdev->constraints;
-	int enabled, ret;
+	int ret;
 
 	if (c && c->always_on)
 		return 0;
@@ -6029,14 +6028,8 @@ static int regulator_late_cleanup(struct device *dev, void *data)
 	if (rdev->use_count)
 		goto unlock;
 
-	/* If we can't read the status assume it's always on. */
-	if (ops->is_enabled)
-		enabled = ops->is_enabled(rdev);
-	else
-		enabled = 1;
-
-	/* But if reading the status failed, assume that it's off. */
-	if (enabled <= 0)
+	/* If reading the status failed, assume that it's off. */
+	if (_regulator_is_enabled(rdev) <= 0)
 		goto unlock;
 
 	if (have_full_constraints()) {



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux