From: Renaud Barbier <renaud.barbier@ge.com>
To: barebox@lists.infradead.org
Subject: [PATCH 1/4] of: base: import of_find_node_by_type
Date: Tue, 3 Sep 2013 15:54:24 +0100 [thread overview]
Message-ID: <1378220067-22296-2-git-send-email-renaud.barbier@ge.com> (raw)
In-Reply-To: <1378220067-22296-1-git-send-email-renaud.barbier@ge.com>
Import of_find_node_by_type from Linux drivers/of/base.c -
commit id d8dfad3.
This function retrieves a node pointer based on the "device_type"
property of the node.
This is used by device tree update functions in PPC support.
Signed-off-by: Renaud Barbier <renaud.barbier@ge.com>
---
drivers/of/base.c | 29 +++++++++++++++++++++++++++++
include/of.h | 2 ++
2 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index c2fb712..a261435 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -401,6 +401,35 @@ struct device_node *of_find_node_by_name(struct device_node *from,
EXPORT_SYMBOL(of_find_node_by_name);
/**
+ * of_find_node_by_type - Find a node by its "device_type" property
+ * @from: The node to start searching from, or NULL to start searching
+ * the entire device tree. The node you pass will not be
+ * searched, only the next one will; typically, you pass
+ * what the previous call returned.
+ * @type: The type string to match against.
+ *
+ * Returns a pointer to the node found or NULL.
+ */
+struct device_node *of_find_node_by_type(struct device_node *from,
+ const char *type)
+{
+ struct device_node *np;
+ const char *device_type;
+ int ret;
+
+ if (!from)
+ from = root_node;
+
+ of_tree_for_each_node_from(np, from) {
+ ret = of_property_read_string(np, "device_type", &device_type);
+ if (!ret && !of_node_cmp(device_type, type))
+ return np;
+ }
+ return NULL;
+}
+EXPORT_SYMBOL(of_find_node_by_type)
+
+/**
* of_find_compatible_node - Find a node based on type and one of the
* tokens in its "compatible" property
* @from: The node to start searching from or NULL, the node
diff --git a/include/of.h b/include/of.h
index 2c77ee6..e5cd750 100644
--- a/include/of.h
+++ b/include/of.h
@@ -124,6 +124,8 @@ extern struct device_node *of_find_node_by_path_from(struct device_node *from,
const char *path);
extern struct device_node *of_find_node_by_path(const char *path);
extern struct device_node *of_find_node_by_phandle(phandle phandle);
+extern struct device_node *of_find_node_by_type(struct device_node *from,
+ const char *type);
extern struct device_node *of_find_compatible_node(struct device_node *from,
const char *type, const char *compat);
extern const struct of_device_id *of_match_node(
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-09-03 14:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-03 14:54 [PATCH v2 0/4] Update P2020RDB board support to allow NFS booting Renaud Barbier
2013-09-03 14:54 ` Renaud Barbier [this message]
2013-09-03 14:54 ` [PATCH 2/4] ppc: add and update device tree fixup functions Renaud Barbier
2013-09-03 14:54 ` [PATCH 3/4] ppc: bootm: relocate fdt to valid boot memory Renaud Barbier
2013-09-05 12:21 ` Sascha Hauer
2013-09-06 10:53 ` Renaud Barbier
2013-09-09 15:08 ` Sascha Hauer
2013-09-03 14:54 ` [PATCH 4/4] ppc: P2020RDB configuration update Renaud Barbier
2013-09-04 6:46 ` [PATCH v2 0/4] Update P2020RDB board support to allow NFS booting Sascha Hauer
-- strict thread matches above, loose matches on Subject: below --
2013-08-30 13:34 [PATCH " Renaud Barbier
2013-08-30 13:34 ` [PATCH 1/4] of: base: import of_find_node_by_type Renaud Barbier
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=1378220067-22296-2-git-send-email-renaud.barbier@ge.com \
--to=renaud.barbier@ge.com \
--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