return 0;
 }
 
-int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
-                                    int depth, void *data)
+int __init early_init_dt_scan_chosen(char *cmdline)
 {
-       int l;
+       int l, node;
        const char *p;
        const void *rng_seed;
+       const void *fdt = initial_boot_params;
 
-       pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname);
-
-       if (depth != 1 || !data ||
-           (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0))
-               return 0;
+       node = fdt_path_offset(fdt, "/chosen");
+       if (node < 0)
+               node = fdt_path_offset(fdt, "/chosen@0");
+       if (node < 0)
+               return -ENOENT;
 
        early_init_dt_check_for_initrd(node);
        early_init_dt_check_for_elfcorehdr(node);
        /* Retrieve command line */
        p = of_get_flat_dt_prop(node, "bootargs", &l);
        if (p != NULL && l > 0)
-               strlcpy(data, p, min(l, COMMAND_LINE_SIZE));
+               strlcpy(cmdline, p, min(l, COMMAND_LINE_SIZE));
 
        /*
         * CONFIG_CMDLINE is meant to be a default in case nothing else
         */
 #ifdef CONFIG_CMDLINE
 #if defined(CONFIG_CMDLINE_EXTEND)
-       strlcat(data, " ", COMMAND_LINE_SIZE);
-       strlcat(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+       strlcat(cmdline, " ", COMMAND_LINE_SIZE);
+       strlcat(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
 #elif defined(CONFIG_CMDLINE_FORCE)
-       strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+       strlcpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
 #else
        /* No arguments from boot loader, use kernel's  cmdl*/
-       if (!((char *)data)[0])
-               strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+       if (!((char *)cmdline)[0])
+               strlcpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
 #endif
 #endif /* CONFIG_CMDLINE */
 
-       pr_debug("Command line is: %s\n", (char *)data);
+       pr_debug("Command line is: %s\n", (char *)cmdline);
 
        rng_seed = of_get_flat_dt_prop(node, "rng-seed", &l);
        if (rng_seed && l > 0) {
                                fdt_totalsize(initial_boot_params));
        }
 
-       /* break now */
-       return 1;
+       return 0;
 }
 
 #ifndef MIN_MEMBLOCK_ADDR
 
 void __init early_init_dt_scan_nodes(void)
 {
-       int rc = 0;
+       int rc;
 
        /* Initialize {size,address}-cells info */
        of_scan_flat_dt(early_init_dt_scan_root, NULL);
 
        /* Retrieve various information from the /chosen node */
-       rc = of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line);
-       if (!rc)
+       rc = early_init_dt_scan_chosen(boot_command_line);
+       if (rc)
                pr_warn("No chosen node found, continuing without\n");
 
        /* Setup memory, calling early_init_dt_add_memory_arch */