[PATCH master 4/5] regulator: fix broken reference counting on disable
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Jan 3 03:57:17 PST 2022
Reference count is maintained correctly when enabling, but the very
first disable will ignore the reference count and disable the regulator
unconditionally. Make disable with an enable_count > 1 a no-op to fix
this.
Reported-by: Enrico Jorns <ejo at pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
drivers/regulator/core.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index d1d3a36dfc8d..ac4141c1cdbf 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -71,6 +71,11 @@ static int regulator_disable_internal(struct regulator_internal *ri)
if (!ri->enable_count)
return -EINVAL;
+ if (ri->enable_count > 1) {
+ ri->enable_count--;
+ return 0;
+ }
+
if (!ri->rdev->desc->ops->disable)
return -ENOSYS;
--
2.30.2
More information about the barebox
mailing list