From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Enrico Jorns <ejo@pengutronix.de>,
Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 4/5] regulator: fix broken reference counting on disable
Date: Mon, 3 Jan 2022 12:57:17 +0100 [thread overview]
Message-ID: <20220103115718.1723730-5-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20220103115718.1723730-1-a.fatoum@pengutronix.de>
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@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@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
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2022-01-03 11:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-03 11:57 [PATCH master 0/5] misc fixes Ahmad Fatoum
2022-01-03 11:57 ` [PATCH master 1/5] pwm: atmel: point MMIO accesses at correct address Ahmad Fatoum
2022-01-03 16:11 ` Sam Ravnborg
2022-01-03 16:18 ` Sam Ravnborg
2022-01-03 11:57 ` [PATCH master 2/5] clk: fixed: record parent name in clk_register_fixed_rate Ahmad Fatoum
2022-01-03 11:57 ` [PATCH master 3/5] imx-bbu-nand-fcb: suppress compiler warning about uninitialized use Ahmad Fatoum
2022-01-03 11:57 ` Ahmad Fatoum [this message]
2022-01-03 11:57 ` [PATCH master 5/5] regulator: respect "regulator-always-on" property Ahmad Fatoum
2022-01-05 7:28 ` [PATCH master 0/5] misc fixes Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220103115718.1723730-5-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=ejo@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox