mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] of: Added of_set_property_to_child_phandle
@ 2014-09-24  9:33 Teresa Gámez
  2014-09-24  9:33 ` [PATCH 2/2] commands: add of_display_timings Teresa Gámez
  0 siblings, 1 reply; 4+ messages in thread
From: Teresa Gámez @ 2014-09-24  9:33 UTC (permalink / raw)
  To: barebox

Set a property to a phandle of a child node. This may be used
for selections like display-timings.

Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
---
 drivers/of/base.c |   21 +++++++++++++++++++++
 include/of.h      |    1 +
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index c440a69..eb5e1a1 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -336,6 +336,27 @@ phandle of_node_create_phandle(struct device_node *node)
 }
 EXPORT_SYMBOL(of_node_create_phandle);
 
+int of_set_property_to_child_phandle(struct device_node *node, char *prop_name)
+{
+	int ret;
+	phandle p;
+
+	/* Check if property exist */
+	if (!of_get_property(of_get_parent(node), prop_name, NULL))
+		return -EINVAL;
+
+	/* Create or get existing phandle of child node */
+	p = of_node_create_phandle(node);
+	p = cpu_to_be32(p);
+
+	node = of_get_parent(node);
+
+	ret = of_set_property(node, prop_name, &p, sizeof(p), 0);
+
+	return ret;
+}
+EXPORT_SYMBOL(of_set_property_to_child_phandle);
+
 /*
  * Find a property with a given name for a given node
  * and return the value.
diff --git a/include/of.h b/include/of.h
index e6993fd..45ef56d 100644
--- a/include/of.h
+++ b/include/of.h
@@ -692,6 +692,7 @@ int of_device_disable_path(const char *path);
 
 phandle of_get_tree_max_phandle(struct device_node *root);
 phandle of_node_create_phandle(struct device_node *node);
+int of_set_property_to_child_phandle(struct device_node *node, char *prop_name);
 struct device_node *of_find_node_by_alias(struct device_node *root,
 		const char *alias);
 struct device_node *of_find_node_by_path_or_alias(struct device_node *root,
-- 
1.7.0.4


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-09-25 11:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-24  9:33 [PATCH 1/2] of: Added of_set_property_to_child_phandle Teresa Gámez
2014-09-24  9:33 ` [PATCH 2/2] commands: add of_display_timings Teresa Gámez
2014-09-25  6:07   ` Sascha Hauer
2014-09-25 11:22     ` Teresa Gamez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox