media: v4l2-compat-ioctl32.c: refactor compat ioctl32 logic
[pandora-kernel.git] / drivers / of / fdt.c
index 65200af..a84c03c 100644 (file)
@@ -388,6 +388,10 @@ static void __unflatten_device_tree(struct boot_param_header *blob,
        /* Allocate memory for the expanded device tree */
        mem = (unsigned long)
                dt_alloc(size + 4, __alignof__(struct device_node));
+       if (!mem)
+               return;
+
+       memset((void *)mem, 0, size);
 
        ((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeef);
 
@@ -681,9 +685,14 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
        if (p != NULL && l > 0)
                strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
 
+       /*
+        * CONFIG_CMDLINE is meant to be a default in case nothing else
+        * managed to set the command line, unless CONFIG_CMDLINE_FORCE
+        * is set in which case we override whatever was found earlier.
+        */
 #ifdef CONFIG_CMDLINE
 #ifndef CONFIG_CMDLINE_FORCE
-       if (p == NULL || l == 0 || (l == 1 && (*p) == 0))
+       if (!((char *)data)[0])
 #endif
                strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
 #endif /* CONFIG_CMDLINE */
@@ -707,10 +716,8 @@ void __init unflatten_device_tree(void)
        __unflatten_device_tree(initial_boot_params, &allnodes,
                                early_init_dt_alloc_memory_arch);
 
-       /* Get pointer to OF "/chosen" node for use everywhere */
-       of_chosen = of_find_node_by_path("/chosen");
-       if (of_chosen == NULL)
-               of_chosen = of_find_node_by_path("/chosen@0");
+       /* Get pointer to "/chosen" and "/aliasas" nodes for use everywhere */
+       of_alias_scan(early_init_dt_alloc_memory_arch);
 }
 
 #endif /* CONFIG_OF_EARLY_FLATTREE */