[PATCH master 4/5] regulator: fix broken reference counting on disable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 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


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux