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 3/5] of: base: Add of_parse_phandle_from
Date: Tue, 30 Sep 2014 13:15:28 +0200	[thread overview]
Message-ID: <1412075730-5946-3-git-send-email-t.gamez@phytec.de> (raw)
In-Reply-To: <1412075730-5946-1-git-send-email-t.gamez@phytec.de>

Added of_parse_phandle_from() to be able to use external root nodes.

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

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 061fc79..f363cc1 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1130,16 +1130,19 @@ int of_property_write_u64_array(struct device_node *np,
 }
 
 /**
- * of_parse_phandle - Resolve a phandle property to a device_node pointer
+ * of_parse_phandle_from - Resolve a phandle property to a device_node pointer from
+ * a given root node
  * @np: Pointer to device node holding phandle property
+ * @root: root node of the tree to search in. If NULL use the internal tree.
  * @phandle_name: Name of property holding a phandle value
  * @index: For properties holding a table of phandles, this is the index into
  *         the table
  *
  * Returns the device_node pointer found or NULL.
  */
-struct device_node *of_parse_phandle(const struct device_node *np,
-				     const char *phandle_name, int index)
+struct device_node *of_parse_phandle_from(const struct device_node *np,
+					struct device_node *root,
+					const char *phandle_name, int index)
 {
 	const __be32 *phandle;
 	int size;
@@ -1148,7 +1151,24 @@ struct device_node *of_parse_phandle(const struct device_node *np,
 	if ((!phandle) || (size < sizeof(*phandle) * (index + 1)))
 		return NULL;
 
-	return of_find_node_by_phandle(be32_to_cpup(phandle + index));
+	return of_find_node_by_phandle_from(be32_to_cpup(phandle + index),
+					root);
+}
+EXPORT_SYMBOL(of_parse_phandle_from);
+
+/**
+ * of_parse_phandle - Resolve a phandle property to a device_node pointer
+ * @np: Pointer to device node holding phandle property
+ * @phandle_name: Name of property holding a phandle value
+ * @index: For properties holding a table of phandles, this is the index into
+ *         the table
+ *
+ * Returns the device_node pointer found or NULL.
+ */
+struct device_node *of_parse_phandle(const struct device_node *np,
+				     const char *phandle_name, int index)
+{
+	return of_parse_phandle_from(np, root_node, phandle_name, index);
 }
 EXPORT_SYMBOL(of_parse_phandle);
 
diff --git a/include/of.h b/include/of.h
index 4281cce..decf151 100644
--- a/include/of.h
+++ b/include/of.h
@@ -205,6 +205,10 @@ extern int of_property_write_u64_array(struct device_node *np,
 extern struct device_node *of_parse_phandle(const struct device_node *np,
 					    const char *phandle_name,
 					    int index);
+extern struct device_node *of_parse_phandle_from(const struct device_node *np,
+					    struct device_node *root,
+					    const char *phandle_name,
+					    int index);
 extern int of_parse_phandle_with_args(const struct device_node *np,
 	const char *list_name, const char *cells_name, int index,
 	struct of_phandle_args *out_args);
@@ -439,6 +443,13 @@ static inline struct device_node *of_parse_phandle(const struct device_node *np,
 	return NULL;
 }
 
+static inline struct device_node *of_parse_phandle_from(const struct device_node *np,
+					    struct device_node *root,
+					    const char *phandle_name, int index)
+{
+	return NULL;
+}
+
 static inline int of_parse_phandle_with_args(const struct device_node *np,
 		const char *list_name, const char *cells_name, int index,
 		struct of_phandle_args *out_args)
-- 
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 ` Teresa Gámez [this message]
2014-09-30 11:15 ` [PATCHv3 4/5] of: Added of_set_property_to_child_phandle Teresa Gámez
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-3-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