aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/boot/flatdevtree.c
diff options
context:
space:
mode:
authorScott Wood <scottwood@freescale.com>2007-03-12 14:41:56 -0600
committerPaul Mackerras <paulus@samba.org>2007-03-16 15:49:11 +1100
commita9ec7669fc07f80f6e39807f1ac319764a304319 (patch)
treecce2cf16a4b2f2dcf88b0b21399e9f29e3fa0de6 /arch/powerpc/boot/flatdevtree.c
parent[POWERPC] bootwrapper: Refactor ft_get_prop() into internal and external functions. (diff)
downloadlinux-dev-a9ec7669fc07f80f6e39807f1ac319764a304319.tar.xz
linux-dev-a9ec7669fc07f80f6e39807f1ac319764a304319.zip
[POWERPC] bootwrapper: Make ft_get_parent() return a phandle, and NULL if already top-level.
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> Acked-by: Mark A. Greer <mgreer@mvista.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/boot/flatdevtree.c')
-rw-r--r--arch/powerpc/boot/flatdevtree.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index 9de267dd1cdc..88b178a77e87 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -728,20 +728,15 @@ void *ft_find_descendent(struct ft_cxt *cxt, void *top, const char *srch_path)
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, const void *phandle)
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, const void *phandle)
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)
{