regulator: core: Let boot-on regulators be powered off
authorPascal Paillet <p.paillet@st.com>
Wed, 13 Nov 2019 10:27:37 +0000 (11:27 +0100)
committerMark Brown <broonie@kernel.org>
Fri, 15 Nov 2019 12:05:27 +0000 (12:05 +0000)
Boot-on regulators are always kept on because their use_count value
is now incremented at boot time and never cleaned.

Only increment count value for alway-on regulators.
regulator_late_cleanup() is now able to power off boot-on regulators
when unused.

Fixes: 05f224ca6693 ("regulator: core: Clean enabling always-on regulators + their supplies")
Signed-off-by: Pascal Paillet <p.paillet@st.com>
Link: https://lore.kernel.org/r/20191113102737.27831-1-p.paillet@st.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/core.c

index a5b2a9b021087aa1c82a7878794ae86a293e9f64..5e6c629806e42548e31699c020de6c024f48e432 100644 (file)
@@ -1403,7 +1403,9 @@ static int set_machine_constraints(struct regulator_dev *rdev,
                        rdev_err(rdev, "failed to enable\n");
                        return ret;
                }
-               rdev->use_count++;
+
+               if (rdev->constraints->always_on)
+                       rdev->use_count++;
        }
 
        print_constraints(rdev);