mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/2] regulator: Add support for regulator-boot-on device tree property
Date: Wed, 15 Jul 2015 07:52:46 +0200	[thread overview]
Message-ID: <1436939566-20823-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1436939566-20823-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/regulator/core.c | 15 +++++++++++++++
 include/regulator.h      |  1 +
 2 files changed, 16 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 96bf846..73f5c6e 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -89,6 +89,7 @@ static int regulator_disable_internal(struct regulator_internal *ri)
 static struct regulator_internal * __regulator_register(struct regulator_dev *rd, const char *name)
 {
 	struct regulator_internal *ri;
+	int ret;
 
 	ri = xzalloc(sizeof(*ri));
 	ri->rdev = rd;
@@ -100,7 +101,19 @@ static struct regulator_internal * __regulator_register(struct regulator_dev *rd
 	if (name)
 		ri->name = xstrdup(name);
 
+	if (rd->boot_on) {
+		ret = regulator_enable_internal(ri);
+		if (ret && ret != -ENOSYS)
+			goto err;
+	}
+
 	return ri;
+err:
+	list_del(&ri->list);
+	free(ri->name);
+	free(ri);
+
+	return ERR_PTR(ret);
 }
 
 
@@ -117,6 +130,8 @@ int of_regulator_register(struct regulator_dev *rd, struct device_node *node)
 	struct regulator_internal *ri;
 	const char *name;
 
+	rd->boot_on = of_property_read_bool(node, "regulator-boot-on");
+
 	name = of_get_property(node, "regulator-name", NULL);
 
 	ri = __regulator_register(rd, name);
diff --git a/include/regulator.h b/include/regulator.h
index a43d3df..367e13f 100644
--- a/include/regulator.h
+++ b/include/regulator.h
@@ -6,6 +6,7 @@ struct regulator;
 
 struct regulator_dev {
 	struct regulator_ops *ops;
+	int boot_on;
 };
 
 struct regulator_ops {
-- 
2.1.4


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

      reply	other threads:[~2015-07-15  5:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-15  5:52 [PATCH 1/2] regulator: Factor out functions to work with regulator_internal Sascha Hauer
2015-07-15  5:52 ` Sascha Hauer [this message]

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=1436939566-20823-2-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@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