linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: linuxppc-dev@ozlabs.org
Subject: [PATCH 12/18] bootwrapper: Make ft_get_parent() return a phandle, and NULL if already top-level.
Date: Mon, 29 Jan 2007 14:12:11 -0600	[thread overview]
Message-ID: <20070129201211.GL13485@ld0162-tx32.am.freescale.net> (raw)
In-Reply-To: <ca1ac163-f732-45ce-9629-e6f4a8c3a880@ld0162-tx32.am.freescale.net>

Most of ft_get_parent() is factored out into __ft_get_parent(), which
deals only in internal node pointers.  The ft_get_parent() wrapper
handles phandle conversion in both directions (previously,
ft_get_parent() did not convert its return value).

It also now returns NULL as the parent of the toplevel node, rather than
just returning the toplevel node again (which made it rather useless in
loops).

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/flatdevtree.c |   21 +++++++++++++--------
 arch/powerpc/boot/flatdevtree.h |    1 +
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index 9de267d..88b178a 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -728,20 +728,15 @@ void *ft_find_descendent(struct ft_cxt *
 	return NULL;
 }
 
-void *ft_get_parent(struct ft_cxt *cxt, const void *phandle)
+void *__ft_get_parent(struct ft_cxt *cxt, void *node)
 {
-	void *node;
 	int d;
 	struct ft_atom atom;
 	char *p;
 
-	node = ft_node_ph2node(cxt, phandle);
-	if (node == NULL)
-		return NULL;
-
 	for (d = 0; cxt->genealogy[d] != NULL; ++d)
 		if (cxt->genealogy[d] == node)
-			return cxt->genealogy[d > 0 ? d - 1 : 0];
+			return d > 0 ? cxt->genealogy[d - 1] : NULL;
 
 	/* have to do it the hard way... */
 	p = ft_root_node(cxt);
@@ -753,7 +748,7 @@ void *ft_get_parent(struct ft_cxt *cxt,
 			if (node == atom.data) {
 				/* found it */
 				cxt->genealogy[d + 1] = NULL;
-				return d > 0 ? cxt->genealogy[d - 1] : node;
+				return d > 0 ? cxt->genealogy[d - 1] : NULL;
 			}
 			++d;
 			break;
@@ -765,6 +760,16 @@ void *ft_get_parent(struct ft_cxt *cxt,
 	return NULL;
 }
 
+void *ft_get_parent(struct ft_cxt *cxt, const void *phandle)
+{
+	void *node = ft_node_ph2node(cxt, phandle);
+	if (node == NULL)
+		return NULL;
+
+	node = __ft_get_parent(cxt, node);
+	return ft_get_phandle(cxt, node);
+}
+
 static const void *__ft_get_prop(struct ft_cxt *cxt, void *node,
                                  const char *propname, unsigned int *len)
 {
diff --git a/arch/powerpc/boot/flatdevtree.h b/arch/powerpc/boot/flatdevtree.h
index 1f37ca2..9500424 100644
--- a/arch/powerpc/boot/flatdevtree.h
+++ b/arch/powerpc/boot/flatdevtree.h
@@ -104,5 +104,6 @@ int ft_get_prop(struct ft_cxt *cxt, cons
 		void *buf, const unsigned int buflen);
 int ft_set_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
 		const void *buf, const unsigned int buflen);
+void *ft_get_parent(struct ft_cxt *cxt, const void *phandle);
 
 #endif /* FLATDEVTREE_H */
-- 
1.4.4

  parent reply	other threads:[~2007-01-29 20:12 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <ca1ac163-f732-45ce-9629-e6f4a8c3a880@ld0162-tx32.am.freescale.net>
2007-01-29 20:11 ` [PATCH 02/18] bootwrapper: Set -msoft-float and assembler target options Scott Wood
2007-01-29 20:40   ` Scott Wood
2007-01-30 19:42   ` Segher Boessenkool
2007-01-29 20:11 ` [PATCH 03/18] bootwrapper: Remove OF-isms Scott Wood
2007-01-29 20:11 ` [PATCH 04/18] bootwrapper: Add ft_root_node() Scott Wood
2007-01-30 19:44   ` Segher Boessenkool
2007-01-29 20:11 ` [PATCH 05/18] bootwrapper: Rename ft_node_add() to ft_get_phandle() Scott Wood
2007-01-29 20:12 ` [PATCH 06/18] bootwrapper: Make ft_get_phandle() accept and return NULL Scott Wood
2007-01-30 19:48   ` Segher Boessenkool
2007-01-30 19:51     ` Scott Wood
2007-01-29 20:12 ` [PATCH 07/18] bootwrapper: Preserve the pp pointer in ft_make_space() when calling ft_reorder() Scott Wood
2007-01-29 20:12 ` [PATCH 08/18] bootwrapper: Modify *pp, not *p, in ft_shuffle() Scott Wood
2007-01-30 19:49   ` Segher Boessenkool
2007-01-29 20:12 ` [PATCH 09/18] bootwrapper: Use map_string() instead of lookup_string() in ft_prop() Scott Wood
2007-01-29 20:12 ` [PATCH 10/18] bootwrapper: Add ft_find_device_rel() Scott Wood
2007-01-30 19:53   ` Segher Boessenkool
2007-01-30 20:25     ` Scott Wood
2007-01-29 20:12 ` [PATCH 11/18] bootwrapper: Refactor ft_get_prop() into internal and external functions Scott Wood
2007-01-29 20:12 ` Scott Wood [this message]
2007-01-30 19:56   ` [PATCH 12/18] bootwrapper: Make ft_get_parent() return a phandle, and NULL if already top-level Segher Boessenkool
2007-01-30 20:39     ` Scott Wood
2007-01-29 20:13 ` [PATCH 13/18] bootwrapper: Add ft_find_prop() Scott Wood
2007-01-30 19:57   ` Segher Boessenkool
2007-01-29 20:13 ` [PATCH 14/18] bootwrapper: Add initrd information to the device tree in ft_finalize() Scott Wood
2007-01-29 20:13 ` [PATCH 15/18] bootwrapper: Make ft_create_node() pay attention to the parent parameter Scott Wood
2007-01-29 20:13 ` [PATCH 16/18] bootwrapper: Add dt_ops methods Scott Wood
2007-01-30 20:01   ` Segher Boessenkool
2007-01-31  7:02     ` David Gibson
2007-01-29 20:13 ` [PATCH 17/18] bootwrapper: Add xlate_reg(), and use it to find serial registers Scott Wood
2007-01-29 20:13 ` [PATCH 18/18] bootwrapper: Compatibility layer for old U-Boots (a.k.a. cuImage, cuboot) Scott Wood

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=20070129201211.GL13485@ld0162-tx32.am.freescale.net \
    --to=scottwood@freescale.com \
    --cc=linuxppc-dev@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).