aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Wood <scottwood@freescale.com>2007-09-05 15:21:04 -0400
committerPaul Mackerras <paulus@samba.org>2007-09-13 11:33:23 -0400
commit4674f2f33948432469e52d5bcaeda9904e34fe46 (patch)
treea58ebf94e2d09ddada9365f8d1401efcaef5e088
parent6bcc4c01755fd2066bc374193cf3b0849cbabe47 (diff)
[POWERPC] bootwrapper: flatdevtree fixes
1. ft_create_node was returning the internal pointer rather than a phandle. 2. ft_find_device_rel was treating a "top" phandle of NULL as an error, rather than as the root of the tree. The old, absolute ft_find_device is removed, and the relative version is renamed to ft_find_device(). Signed-off-by: Scott Wood <scottwood@freescale.com> Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Paul Mackerras <paulus@samba.org>
-rw-r--r--arch/powerpc/boot/flatdevtree.c41
-rw-r--r--arch/powerpc/boot/flatdevtree.h7
-rw-r--r--arch/powerpc/boot/flatdevtree_misc.c2
3 files changed, 23 insertions, 27 deletions
diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index 13761bf160c..0af7291fc67 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -354,16 +354,21 @@ static void ft_put_bin(struct ft_cxt *cxt, const void *data, unsigned int sz)
354 cxt->p += sza; 354 cxt->p += sza;
355} 355}
356 356
357int ft_begin_node(struct ft_cxt *cxt, const char *name) 357char *ft_begin_node(struct ft_cxt *cxt, const char *name)
358{ 358{
359 unsigned long nlen = strlen(name) + 1; 359 unsigned long nlen = strlen(name) + 1;
360 unsigned long len = 8 + _ALIGN(nlen, 4); 360 unsigned long len = 8 + _ALIGN(nlen, 4);
361 char *ret;
361 362
362 if (!ft_make_space(cxt, &cxt->p, FT_STRUCT, len)) 363 if (!ft_make_space(cxt, &cxt->p, FT_STRUCT, len))
363 return -1; 364 return NULL;
365
366 ret = cxt->p;
367
364 ft_put_word(cxt, OF_DT_BEGIN_NODE); 368 ft_put_word(cxt, OF_DT_BEGIN_NODE);
365 ft_put_bin(cxt, name, strlen(name) + 1); 369 ft_put_bin(cxt, name, strlen(name) + 1);
366 return 0; 370
371 return ret;
367} 372}
368 373
369void ft_end_node(struct ft_cxt *cxt) 374void ft_end_node(struct ft_cxt *cxt)
@@ -625,25 +630,17 @@ void ft_end_tree(struct ft_cxt *cxt)
625 bph->dt_strings_size = cpu_to_be32(ssize); 630 bph->dt_strings_size = cpu_to_be32(ssize);
626} 631}
627 632
628void *ft_find_device(struct ft_cxt *cxt, const char *srch_path) 633void *ft_find_device(struct ft_cxt *cxt, const void *top, const char *srch_path)
629{
630 char *node;
631
632 /* require absolute path */
633 if (srch_path[0] != '/')
634 return NULL;
635 node = ft_find_descendent(cxt, ft_root_node(cxt), srch_path);
636 return ft_get_phandle(cxt, node);
637}
638
639void *ft_find_device_rel(struct ft_cxt *cxt, const void *top,
640 const char *srch_path)
641{ 634{
642 char *node; 635 char *node;
643 636
644 node = ft_node_ph2node(cxt, top); 637 if (top) {
645 if (node == NULL) 638 node = ft_node_ph2node(cxt, top);
646 return NULL; 639 if (node == NULL)
640 return NULL;
641 } else {
642 node = ft_root_node(cxt);
643 }
647 644
648 node = ft_find_descendent(cxt, node, srch_path); 645 node = ft_find_descendent(cxt, node, srch_path);
649 return ft_get_phandle(cxt, node); 646 return ft_get_phandle(cxt, node);
@@ -945,7 +942,7 @@ int ft_del_prop(struct ft_cxt *cxt, const void *phandle, const char *propname)
945void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *name) 942void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *name)
946{ 943{
947 struct ft_atom atom; 944 struct ft_atom atom;
948 char *p, *next; 945 char *p, *next, *ret;
949 int depth = 0; 946 int depth = 0;
950 947
951 if (parent) { 948 if (parent) {
@@ -970,9 +967,9 @@ void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *name)
970 break; 967 break;
971 /* end of node, insert here */ 968 /* end of node, insert here */
972 cxt->p = p; 969 cxt->p = p;
973 ft_begin_node(cxt, name); 970 ret = ft_begin_node(cxt, name);
974 ft_end_node(cxt); 971 ft_end_node(cxt);
975 return p; 972 return ft_get_phandle(cxt, ret);
976 } 973 }
977 p = next; 974 p = next;
978 } 975 }
diff --git a/arch/powerpc/boot/flatdevtree.h b/arch/powerpc/boot/flatdevtree.h
index cb26325d72d..2c1c826c4ec 100644
--- a/arch/powerpc/boot/flatdevtree.h
+++ b/arch/powerpc/boot/flatdevtree.h
@@ -76,7 +76,7 @@ struct ft_cxt {
76 unsigned int nodes_used; 76 unsigned int nodes_used;
77}; 77};
78 78
79int ft_begin_node(struct ft_cxt *cxt, const char *name); 79char *ft_begin_node(struct ft_cxt *cxt, const char *name);
80void ft_end_node(struct ft_cxt *cxt); 80void ft_end_node(struct ft_cxt *cxt);
81 81
82void ft_begin_tree(struct ft_cxt *cxt); 82void ft_begin_tree(struct ft_cxt *cxt);
@@ -96,9 +96,8 @@ int ft_add_rsvmap(struct ft_cxt *cxt, u64 physaddr, u64 size);
96 96
97void ft_dump_blob(const void *bphp); 97void ft_dump_blob(const void *bphp);
98void ft_merge_blob(struct ft_cxt *cxt, void *blob); 98void ft_merge_blob(struct ft_cxt *cxt, void *blob);
99void *ft_find_device(struct ft_cxt *cxt, const char *srch_path); 99void *ft_find_device(struct ft_cxt *cxt, const void *top,
100void *ft_find_device_rel(struct ft_cxt *cxt, const void *top, 100 const char *srch_path);
101 const char *srch_path);
102void *ft_find_descendent(struct ft_cxt *cxt, void *top, const char *srch_path); 101void *ft_find_descendent(struct ft_cxt *cxt, void *top, const char *srch_path);
103int ft_get_prop(struct ft_cxt *cxt, const void *phandle, const char *propname, 102int ft_get_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
104 void *buf, const unsigned int buflen); 103 void *buf, const unsigned int buflen);
diff --git a/arch/powerpc/boot/flatdevtree_misc.c b/arch/powerpc/boot/flatdevtree_misc.c
index 4341e6558c1..8d1debe8d94 100644
--- a/arch/powerpc/boot/flatdevtree_misc.c
+++ b/arch/powerpc/boot/flatdevtree_misc.c
@@ -18,7 +18,7 @@ static struct ft_cxt cxt;
18 18
19static void *fdtm_finddevice(const char *name) 19static void *fdtm_finddevice(const char *name)
20{ 20{
21 return ft_find_device(&cxt, name); 21 return ft_find_device(&cxt, NULL, name);
22} 22}
23 23
24static int fdtm_getprop(const void *phandle, const char *propname, 24static int fdtm_getprop(const void *phandle, const char *propname,