Commit:     7c40542ffaa20e361f5f37d112aba41a725fc759
Parent:     e3d67b663b5ededac1b2c552b4f0b4fbe94d7ac3
Author:     David Gibson <[EMAIL PROTECTED]>
AuthorDate: Mon May 14 13:13:57 2007 +1000
Committer:  Paul Mackerras <[EMAIL PROTECTED]>
CommitDate: Thu May 17 21:11:13 2007 +1000

    [POWERPC] Fix bug adding properties with flatdevtree.c's ft_set_prop()
    ft_set_prop() from flatdevtree.c in the zImage wrapper will either
    replace an existing property in the flat device tree, or add a new
    property definiion if the given property isn't present.
    However, when adding properties, it adds the property definition
    immediately before the node's END_NODE tag, potentially after any
    subnode definitions for the node.  This confuses the kernel flat tree
    parser in prom.c which assumes that all property definitions for a
    node come before all subnode definitions.
    This patch corrects ft_set_prop() so that it adds new properties
    before the first subnode, instead of before the END_NODE tag.
    Signed-off-by: David Gibson <[EMAIL PROTECTED]>
    Acked-by: Scott Wood <[EMAIL PROTECTED]>
    Acked-by: Mark A. Greer <[EMAIL PROTECTED]>
    Signed-off-by: Paul Mackerras <[EMAIL PROTECTED]>
 arch/powerpc/boot/flatdevtree.c |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index d00fbd9..b732644 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -891,28 +891,27 @@ int ft_set_prop(struct ft_cxt *cxt, const void *phandle, 
const char *propname,
        struct ft_atom atom;
        void *node;
        char *p, *next;
-       int nextra, depth;
+       int nextra;
        node = ft_node_ph2node(cxt, phandle);
        if (node == NULL)
                return -1;
-       depth = 0;
-       p = node;
+       next = ft_next(cxt, node, &atom);
+       if (atom.tag != OF_DT_BEGIN_NODE)
+               /* phandle didn't point to a node */
+               return -1;
+       p = next;
        while ((next = ft_next(cxt, p, &atom)) != NULL) {
                switch (atom.tag) {
-               case OF_DT_BEGIN_NODE:
-                       ++depth;
-                       break;
+               case OF_DT_BEGIN_NODE: /* properties must go before subnodes */
                case OF_DT_END_NODE:
-                       if (--depth > 0)
-                               break;
                        /* haven't found the property, insert here */
                        cxt->p = p;
                        return ft_prop(cxt, propname, buf, buflen);
                case OF_DT_PROP:
-                       if ((depth != 1) || strcmp(, propname))
+                       if (strcmp(, propname))
                        /* found an existing property, overwrite it */
                        nextra = _ALIGN(buflen, 4) - _ALIGN(atom.size, 4);
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at

Reply via email to