Since commit 1fc12b05895e ("regulator: core: Avoid propagating to
supplies when possible") regulators marked with boot-on can't be
disabled anymore because the commit handles always-on and boot-on
regulators the same way.

Now commit 05f224ca6693 ("regulator: core: Clean enabling always-on
regulators + their supplies") changed the regulator_resolve_supply()
logic a bit by using 'use_count'. So we can't just skip the
'use_count++' during set_machine_constraints(). The easiest way I found
is to correct the 'use_count' just before returning the rdev device
during regulator_register().

Signed-off-by: Marco Felsch <[email protected]>
---
 drivers/regulator/core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index e0c0cf462004..f9444f509440 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -5170,6 +5170,11 @@ regulator_register(const struct regulator_desc 
*regulator_desc,
        /* try to resolve regulators supply since a new one was registered */
        class_for_each_device(&regulator_class, NULL, NULL,
                              regulator_register_resolve_supply);
+
+       /* cleanup use_count -> boot-on marked regulators can be disabled */
+       if (rdev->constraints->boot_on && !rdev->constraints->always_on)
+               rdev->use_count--;
+
        kfree(config);
        return rdev;
 
-- 
2.20.1

Reply via email to