Merge branch 'work.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[linux-2.6-block.git] / drivers / of / unittest.c
index 84427384654d567cee169b54b7bd8661a94fe717..cccde756b51097d4c762b6e41ea1770d5118466e 100644 (file)
@@ -1116,15 +1116,22 @@ static void update_node_properties(struct device_node *np,
        for (prop = np->properties; prop != NULL; prop = save_next) {
                save_next = prop->next;
                ret = of_add_property(dup, prop);
-               if (ret)
+               if (ret) {
+                       if (ret == -EEXIST && !strcmp(prop->name, "name"))
+                               continue;
                        pr_err("unittest internal error: unable to add testdata property %pOF/%s",
                               np, prop->name);
+               }
        }
 }
 
 /**
  *     attach_node_and_children - attaches nodes
- *     and its children to live tree
+ *     and its children to live tree.
+ *     CAUTION: misleading function name - if node @np already exists in
+ *     the live tree then children of @np are *not* attached to the live
+ *     tree.  This works for the current test devicetree nodes because such
+ *     nodes do not have child nodes.
  *
  *     @np:    Node to attach to live tree
  */
@@ -2234,7 +2241,13 @@ static struct device_node *overlay_base_root;
 
 static void * __init dt_alloc_memory(u64 size, u64 align)
 {
-       return memblock_alloc(size, align);
+       void *ptr = memblock_alloc(size, align);
+
+       if (!ptr)
+               panic("%s: Failed to allocate %llu bytes align=0x%llx\n",
+                     __func__, size, align);
+
+       return ptr;
 }
 
 /*
@@ -2514,6 +2527,10 @@ static int __init of_unittest(void)
        int res;
 
        /* adding data for unittest */
+
+       if (IS_ENABLED(CONFIG_UML))
+               unittest_unflatten_overlay_base();
+
        res = unittest_data_add();
        if (res)
                return res;