[v2,09/12] regulator: register dependency parser for firmware nodes
diff mbox

Message ID 1435743667-11987-10-git-send-email-tomeu.vizoso@collabora.com
State New
Headers show

Commit Message

Tomeu Vizoso July 1, 2015, 9:41 a.m. UTC
So others can find out what depends on regulators, as specified
in bindings/regulator/regulator.txt.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---

Changes in v2: None

 drivers/regulator/core.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Comments

Mark Brown July 16, 2015, 9:38 p.m. UTC | #1
On Wed, Jul 01, 2015 at 11:41:04AM +0200, Tomeu Vizoso wrote:
> So others can find out what depends on regulators, as specified
> in bindings/regulator/regulator.txt.

Reviewed-by: Mark Brown <broonie@kernel.org>

from a regulator point of view.

Patch
diff mbox

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index c9f7201..535cad0 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -4112,6 +4112,31 @@  static const struct file_operations regulator_summary_fops = {
 #endif
 };
 
+static void regulator_get_dependencies(struct fwnode_handle *fwnode,
+				       struct list_head *deps)
+{
+	struct device_node *np;
+	struct property *pp;
+	struct device_node *dep;
+
+	np = to_of_node(fwnode);
+	if (!np)
+		return;
+
+	for_each_property_of_node(np, pp) {
+		if (!strends(pp->name, "-supply"))
+			continue;
+
+		dep = of_parse_phandle(np, pp->name, 0);
+		if (!dep)
+			continue;
+
+		fwnode_add_dependency(&dep->fwnode, deps);
+
+		of_node_put(dep);
+	}
+}
+
 static int __init regulator_init(void)
 {
 	int ret;
@@ -4130,6 +4155,8 @@  static int __init regulator_init(void)
 
 	regulator_dummy_init();
 
+	fwnode_add_dependency_parser(regulator_get_dependencies);
+
 	return ret;
 }