summaryrefslogtreecommitdiffstats
path: root/drivers/regulator/core.c
diff options
context:
space:
mode:
authorAhmad Fatoum <ahmad@a3f.at>2022-07-08 08:15:40 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-07-11 11:35:17 +0200
commit2b2b0527a3750a96cc90ca146e754ad9bd350466 (patch)
tree048fd7c7ee0eff9a4dbac00c17249b06acb677d0 /drivers/regulator/core.c
parent1d09667d3b37628df2902be25a4776ad9867228f (diff)
downloadbarebox-2b2b0527a3750a96cc90ca146e754ad9bd350466.tar.gz
barebox-2b2b0527a3750a96cc90ca146e754ad9bd350466.tar.xz
regulator: fixed: remove duplicate always-on handling
Regulator core already handles always-on property by enabling always-on regulators at registration time, so we can remove duplicate handling in the fixed-regulator driver. To avoid regressions due to previously unnoticed unbalanced regulator usage, maintain a positive use count always like Linux does and additionally warn on violation attempt. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20220708061539.1193059-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r--drivers/regulator/core.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index af8a0cb4fc..1fb344656f 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -66,6 +66,7 @@ static int regulator_enable_internal(struct regulator_internal *ri)
static int regulator_disable_internal(struct regulator_internal *ri)
{
+ struct regulator_dev *rdev = ri->rdev;
int ret;
if (!ri->enable_count)
@@ -76,10 +77,14 @@ static int regulator_disable_internal(struct regulator_internal *ri)
return 0;
}
- if (!ri->rdev->desc->ops->disable)
+ /* Crisis averted, be loud about the unbalanced regulator use */
+ if (WARN_ON(rdev->always_on))
+ return -EPERM;
+
+ if (!rdev->desc->ops->disable)
return -ENOSYS;
- ret = ri->rdev->desc->ops->disable(ri->rdev);
+ ret = rdev->desc->ops->disable(rdev);
if (ret)
return ret;