From 6d0cb62e4792fdee03d6c76fc2ebdc186a2e6385 Mon Sep 17 00:00:00 2001
From: Pascal Paillet
Date: Wed, 13 Nov 2019 11:27:37 +0100
Subject: [PATCH] UPSTREAM: regulator: core: Let boot-on regulators be powered
off
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.
Change-Id: I7adc58a78fec934e245d9ec94c4604b4d7c7ebb5
Fixes: 05f224ca6693 ("regulator: core: Clean enabling always-on regulators + their supplies")
Signed-off-by: Pascal Paillet
Link: https://lore.kernel.org/r/20191113102737.27831-1-p.paillet@st.com
Signed-off-by: Mark Brown
Signed-off-by: Tao Huang
(cherry picked from commit 089b3f61ecfc43ca4ea26d595e1d31ead6de3f7b)
---
drivers/regulator/core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index b6724b62476e..8eba2eb0793e 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1260,7 +1260,9 @@ static int set_machine_constraints(struct regulator_dev *rdev)
return ret;
}
}
- rdev->use_count++;
+
+ if (rdev->constraints->always_on)
+ rdev->use_count++;
}
print_constraints(rdev);