aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Wood <scottwood@freescale.com>2007-03-12 16:41:56 -0400
committerPaul Mackerras <paulus@samba.org>2007-03-16 00:49:11 -0400
commita9ec7669fc07f80f6e39807f1ac319764a304319 (patch)
treecce2cf16a4b2f2dcf88b0b21399e9f29e3fa0de6
parentc350038b2bdabb07611dcc8116b55f917ada09fa (diff)
[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>
-rw-r--r--arch/powerpc/boot/flatdevtree.c21
-rw-r--r--arch/powerpc/boot/flatdevtree.h1
2 files changed, 14 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)
728 return NULL; 728 return NULL;
729} 729}
730 730
731void *ft_get_parent(struct ft_cxt *cxt, const void *phandle) 731void *__ft_get_parent(struct ft_cxt *cxt, void *node)
732{ 732{
733 void *node;
734 int d; 733 int d;
735 struct ft_atom atom; 734 struct ft_atom atom;
736 char *p; 735 char *p;
737 736
738 node = ft_node_ph2node(cxt, phandle);
739 if (node == NULL)
740 return NULL;
741
742 for (d = 0; cxt->genealogy[d] != NULL; ++d) 737 for (d = 0; cxt->genealogy[d] != NULL; ++d)
743 if (cxt->genealogy[d] == node) 738 if (cxt->genealogy[d] == node)
744 return cxt->genealogy[d > 0 ? d - 1 : 0]; 739 return d > 0 ? cxt->genealogy[d - 1] : NULL;
745 740
746 /* have to do it the hard way... */ 741 /* have to do it the hard way... */
747 p = ft_root_node(cxt); 742 p = ft_root_node(cxt);
@@ -753,7 +748,7 @@ void *ft_get_parent(struct ft_cxt *cxt, const void *phandle)
753 if (node == atom.data) { 748 if (node == atom.data) {
754 /* found it */ 749 /* found it */
755 cxt->genealogy[d + 1] = NULL; 750 cxt->genealogy[d + 1] = NULL;
756 return d > 0 ? cxt->genealogy[d - 1] : node; 751 return d > 0 ? cxt->genealogy[d - 1] : NULL;
757 } 752 }
758 ++d; 753 ++d;
759 break; 754 break;
@@ -765,6 +760,16 @@ void *ft_get_parent(struct ft_cxt *cxt, const void *phandle)
765 return NULL; 760 return NULL;
766} 761}
767 762
763void *ft_get_parent(struct ft_cxt *cxt, const void *phandle)
764{
765 void *node = ft_node_ph2node(cxt, phandle);
766 if (node == NULL)
767 return NULL;
768
769 node = __ft_get_parent(cxt, node);
770 return ft_get_phandle(cxt, node);
771}
772
768static const void *__ft_get_prop(struct ft_cxt *cxt, void *node, 773static const void *__ft_get_prop(struct ft_cxt *cxt, void *node,
769 const char *propname, unsigned int *len) 774 const char *propname, unsigned int *len)
770{ 775{
diff --git a/arch/powerpc/boot/flatdevtree.h b/arch/powerpc/boot/flatdevtree.h
index 1f37ca2d34f6..950042493fb7 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, const void *phandle, const char *propname,
104 void *buf, const unsigned int buflen); 104 void *buf, const unsigned int buflen);
105int ft_set_prop(struct ft_cxt *cxt, const void *phandle, const char *propname, 105int ft_set_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
106 const void *buf, const unsigned int buflen); 106 const void *buf, const unsigned int buflen);
107void *ft_get_parent(struct ft_cxt *cxt, const void *phandle);
107 108
108#endif /* FLATDEVTREE_H */ 109#endif /* FLATDEVTREE_H */