diff options
author | Scott Wood <scottwood@freescale.com> | 2007-09-05 15:21:04 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-09-13 11:33:23 -0400 |
commit | 4674f2f33948432469e52d5bcaeda9904e34fe46 (patch) | |
tree | a58ebf94e2d09ddada9365f8d1401efcaef5e088 /arch/powerpc | |
parent | 6bcc4c01755fd2066bc374193cf3b0849cbabe47 (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>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/boot/flatdevtree.c | 41 | ||||
-rw-r--r-- | arch/powerpc/boot/flatdevtree.h | 7 | ||||
-rw-r--r-- | arch/powerpc/boot/flatdevtree_misc.c | 2 |
3 files changed, 23 insertions, 27 deletions
diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c index 13761bf160c4..0af7291fc67c 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 | ||
357 | int ft_begin_node(struct ft_cxt *cxt, const char *name) | 357 | char *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 | ||
369 | void ft_end_node(struct ft_cxt *cxt) | 374 | void 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 | ||
628 | void *ft_find_device(struct ft_cxt *cxt, const char *srch_path) | 633 | void *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 | |||
639 | void *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) | |||
945 | void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *name) | 942 | void *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 cb26325d72db..2c1c826c4eca 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 | ||
79 | int ft_begin_node(struct ft_cxt *cxt, const char *name); | 79 | char *ft_begin_node(struct ft_cxt *cxt, const char *name); |
80 | void ft_end_node(struct ft_cxt *cxt); | 80 | void ft_end_node(struct ft_cxt *cxt); |
81 | 81 | ||
82 | void ft_begin_tree(struct ft_cxt *cxt); | 82 | void 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 | ||
97 | void ft_dump_blob(const void *bphp); | 97 | void ft_dump_blob(const void *bphp); |
98 | void ft_merge_blob(struct ft_cxt *cxt, void *blob); | 98 | void ft_merge_blob(struct ft_cxt *cxt, void *blob); |
99 | void *ft_find_device(struct ft_cxt *cxt, const char *srch_path); | 99 | void *ft_find_device(struct ft_cxt *cxt, const void *top, |
100 | void *ft_find_device_rel(struct ft_cxt *cxt, const void *top, | 100 | const char *srch_path); |
101 | const char *srch_path); | ||
102 | void *ft_find_descendent(struct ft_cxt *cxt, void *top, const char *srch_path); | 101 | void *ft_find_descendent(struct ft_cxt *cxt, void *top, const char *srch_path); |
103 | int ft_get_prop(struct ft_cxt *cxt, const void *phandle, const char *propname, | 102 | int 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 4341e6558c1a..8d1debe8d941 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 | ||
19 | static void *fdtm_finddevice(const char *name) | 19 | static 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 | ||
24 | static int fdtm_getprop(const void *phandle, const char *propname, | 24 | static int fdtm_getprop(const void *phandle, const char *propname, |