Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Scott Wood and committed by
Paul Mackerras
4674f2f3 6bcc4c01

+23 -27
+19 -22
arch/powerpc/boot/flatdevtree.c
··· 354 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 359 unsigned long nlen = strlen(name) + 1; 360 360 unsigned long len = 8 + _ALIGN(nlen, 4); 361 + char *ret; 361 362 362 363 if (!ft_make_space(cxt, &cxt->p, FT_STRUCT, len)) 363 - return -1; 364 + return NULL; 365 + 366 + ret = cxt->p; 367 + 364 368 ft_put_word(cxt, OF_DT_BEGIN_NODE); 365 369 ft_put_bin(cxt, name, strlen(name) + 1); 366 - return 0; 370 + 371 + return ret; 367 372 } 368 373 369 374 void ft_end_node(struct ft_cxt *cxt) ··· 630 625 bph->dt_strings_size = cpu_to_be32(ssize); 631 626 } 632 627 633 - void *ft_find_device(struct ft_cxt *cxt, const char *srch_path) 628 + void *ft_find_device(struct ft_cxt *cxt, const void *top, const char *srch_path) 634 629 { 635 630 char *node; 636 631 637 - /* require absolute path */ 638 - if (srch_path[0] != '/') 639 - return NULL; 640 - node = ft_find_descendent(cxt, ft_root_node(cxt), srch_path); 641 - return ft_get_phandle(cxt, node); 642 - } 643 - 644 - void *ft_find_device_rel(struct ft_cxt *cxt, const void *top, 645 - const char *srch_path) 646 - { 647 - char *node; 648 - 649 - node = ft_node_ph2node(cxt, top); 650 - if (node == NULL) 651 - return NULL; 632 + if (top) { 633 + node = ft_node_ph2node(cxt, top); 634 + if (node == NULL) 635 + return NULL; 636 + } else { 637 + node = ft_root_node(cxt); 638 + } 652 639 653 640 node = ft_find_descendent(cxt, node, srch_path); 654 641 return ft_get_phandle(cxt, node); ··· 942 945 void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *name) 943 946 { 944 947 struct ft_atom atom; 945 - char *p, *next; 948 + char *p, *next, *ret; 946 949 int depth = 0; 947 950 948 951 if (parent) { ··· 967 970 break; 968 971 /* end of node, insert here */ 969 972 cxt->p = p; 970 - ft_begin_node(cxt, name); 973 + ret = ft_begin_node(cxt, name); 971 974 ft_end_node(cxt); 972 - return p; 975 + return ft_get_phandle(cxt, ret); 973 976 } 974 977 p = next; 975 978 }
+3 -4
arch/powerpc/boot/flatdevtree.h
··· 76 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 80 void ft_end_node(struct ft_cxt *cxt); 81 81 82 82 void ft_begin_tree(struct ft_cxt *cxt); ··· 96 96 97 97 void ft_dump_blob(const void *bphp); 98 98 void ft_merge_blob(struct ft_cxt *cxt, void *blob); 99 - void *ft_find_device(struct ft_cxt *cxt, const char *srch_path); 100 - void *ft_find_device_rel(struct ft_cxt *cxt, const void *top, 101 - const char *srch_path); 99 + void *ft_find_device(struct ft_cxt *cxt, const void *top, 100 + const char *srch_path); 102 101 void *ft_find_descendent(struct ft_cxt *cxt, void *top, const char *srch_path); 103 102 int ft_get_prop(struct ft_cxt *cxt, const void *phandle, const char *propname, 104 103 void *buf, const unsigned int buflen);
+1 -1
arch/powerpc/boot/flatdevtree_misc.c
··· 18 18 19 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 24 static int fdtm_getprop(const void *phandle, const char *propname,