mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 5/5] regulator: respect "regulator-always-on" property
Date: Mon,  3 Jan 2022 12:57:18 +0100	[thread overview]
Message-ID: <20220103115718.1723730-6-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20220103115718.1723730-1-a.fatoum@pengutronix.de>

From: Enrico Jorns <ejo@pengutronix.de>

As barebox ignored this property, a regulator could have been disabled
even if it should not have been.
By taking the same path as for 'regulator-boot-on', we ensure always
holding an enable count > 0 on the regulator.

Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/regulator/core.c | 3 ++-
 include/regulator.h      | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index ac4141c1cdbf..b2e5f8caa2ca 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -130,7 +130,7 @@ static struct regulator_internal * __regulator_register(struct regulator_dev *rd
 	if (name)
 		ri->name = xstrdup(name);
 
-	if (rd->boot_on) {
+	if (rd->boot_on && rd->always_on) {
 		ret = regulator_enable_internal(ri);
 		if (ret && ret != -ENOSYS)
 			goto err;
@@ -163,6 +163,7 @@ int of_regulator_register(struct regulator_dev *rd, struct device_node *node)
 		return -EINVAL;
 
 	rd->boot_on = of_property_read_bool(node, "regulator-boot-on");
+	rd->always_on = of_property_read_bool(node, "regulator-always-on");
 
 	name = of_get_property(node, "regulator-name", NULL);
 
diff --git a/include/regulator.h b/include/regulator.h
index bbe8dd91d84b..dfdfbf033262 100644
--- a/include/regulator.h
+++ b/include/regulator.h
@@ -84,7 +84,8 @@ struct regulator_desc {
 struct regulator_dev {
 	const struct regulator_desc *desc;
 	struct regmap *regmap;
-	int boot_on;
+	bool boot_on;
+	bool always_on;
 	/* the device this regulator device belongs to */
 	struct device_d *dev;
 };
-- 
2.30.2


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


  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 ` [PATCH master 4/5] regulator: fix broken reference counting on disable Ahmad Fatoum
2022-01-03 11:57 ` Ahmad Fatoum [this message]
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-6-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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