mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Teresa Gámez" <t.gamez@phytec.de>
To: barebox@lists.infradead.org
Subject: [PATCHv3 4/5] of: Added of_set_property_to_child_phandle
Date: Tue, 30 Sep 2014 13:15:29 +0200	[thread overview]
Message-ID: <1412075730-5946-4-git-send-email-t.gamez@phytec.de> (raw)
In-Reply-To: <1412075730-5946-1-git-send-email-t.gamez@phytec.de>

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(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index f363cc1..e9f0883 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -356,6 +356,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 decf151..29694a9 100644
--- a/include/of.h
+++ b/include/of.h
@@ -714,6 +714,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.9.1


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

  parent reply	other threads:[~2014-09-30 11:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-30 11:15 [PATCHv3 1/5] of: base: Add for_each_node_by_name_from Teresa Gámez
2014-09-30 11:15 ` [PATCHv3 2/5] of: base: Add of_find_node_by_phandle_from Teresa Gámez
2014-09-30 11:15 ` [PATCHv3 3/5] of: base: Add of_parse_phandle_from Teresa Gámez
2014-09-30 11:15 ` Teresa Gámez [this message]
2014-09-30 11:15 ` [PATCHv3 5/5] commands: add of_display_timings Teresa Gámez
2014-10-01  6:13 ` [PATCHv3 1/5] of: base: Add for_each_node_by_name_from 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=1412075730-5946-4-git-send-email-t.gamez@phytec.de \
    --to=t.gamez@phytec.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