linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Deepak Saxena <deepak_saxena@mentor.com>
To: devicetree-discuss@ozlabs.org
Cc: linuxppc-dev@lists.ozlabs.org
Subject: [PATCH 4/5] of/device: Create _of_get_next_child()
Date: Wed, 8 Dec 2010 11:29:22 -0800	[thread overview]
Message-ID: <20101208192922.GC32473@mentor.com> (raw)
In-Reply-To: <cover.1291799069.git.deepak_saxena@mentor.com>

There aren't many, but some of_get_next_child() callers do need an unabridged
view of the device tree so we provide a wrapper that can be used by them.

Signed-off-by: Hollis Blanchard <hollis_blanchard@mentor.com>
Signed-off-by: Deepak Saxena <deepak_saxena@mentor.com>
---
 drivers/of/base.c  |   26 ++++++++++++++++++++++++++
 include/linux/of.h |    2 ++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 81b2601..7bc1398 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -315,6 +315,32 @@ struct device_node *of_get_next_parent(struct device_node *node)
 }
 
 /**
+ *	_of_get_next_child - Iterate a node childs
+ *	@node:	parent node
+ *	@prev:	previous child of the parent node, or NULL to get first
+ *
+ *	Returns a node pointer with refcount incremented, use
+ *	of_node_put() on it when done.
+ *
+ *	Unlike most other node accessors, ignores status properties.
+ */
+struct device_node *_of_get_next_child(const struct device_node *node,
+	struct device_node *prev)
+{
+	struct device_node *next;
+
+	read_lock(&devtree_lock);
+	next = prev ? prev->sibling : node->child;
+	for (; next; next = next->sibling)
+		if (of_device_is_available(next) && of_node_get(next))
+			break;
+	of_node_put(prev);
+	read_unlock(&devtree_lock);
+	return next;
+}
+EXPORT_SYMBOL(_of_get_next_child);
+
+/**
  *	of_get_next_child - Iterate a node childs
  *	@node:	parent node
  *	@prev:	previous child of the parent node, or NULL to get first
diff --git a/include/linux/of.h b/include/linux/of.h
index cad7cf0..1fea01d 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -175,6 +175,8 @@ extern struct device_node *of_find_node_by_path(const char *path);
 extern struct device_node *of_find_node_by_phandle(phandle handle);
 extern struct device_node *of_get_parent(const struct device_node *node);
 extern struct device_node *of_get_next_parent(struct device_node *node);
+extern struct device_node *_of_get_next_child(const struct device_node *node,
+					     struct device_node *prev);
 extern struct device_node *of_get_next_child(const struct device_node *node,
 					     struct device_node *prev);
 #define for_each_child_of_node(parent, child) \
-- 
1.6.3.3

  parent reply	other threads:[~2010-12-08 20:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1291799069.git.deepak_saxena@mentor.com>
2010-12-08 19:29 ` [PATCH 1/5] of/device: Centralize checking of 'status' properties Deepak Saxena
2010-12-31  7:43   ` Grant Likely
2010-12-08 19:29 ` Deepak Saxena [this message]
2010-12-08 19:29 ` [PATCH 5/5] of/device: Show even unavailable nodes in procfs Deepak Saxena
2010-12-08 19:29 ` [PATCH 3/5] of/device: Make of_get_next_child() check status properties Deepak Saxena
2010-12-08 21:01   ` Scott Wood
2010-12-09  1:33     ` Michael Ellerman
2010-12-09  3:09       ` David Gibson
2010-12-15 18:35         ` Hollis Blanchard
2010-12-15 22:40           ` Michael Ellerman
2010-12-31  7:39             ` Grant Likely
2010-12-08 19:29 ` [PATCH 2/5] of/device: make for_each_node* " Deepak Saxena
2010-12-31  7:46   ` Grant Likely

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=20101208192922.GC32473@mentor.com \
    --to=deepak_saxena@mentor.com \
    --cc=devicetree-discuss@ozlabs.org \
    --cc=linuxppc-dev@lists.ozlabs.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;
as well as URLs for NNTP newsgroup(s).