aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of/fdt.c
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2009-12-11 01:42:21 -0500
committerGrant Likely <grant.likely@secretlab.ca>2009-12-11 01:42:21 -0500
commit86e032213424958b45564d0cc96b3316641a49d3 (patch)
tree34b9f5ddd49180a558a325b9ccb47140f5cc7cbd /drivers/of/fdt.c
parent0f0b56c3f2df4a083fc9e934266e5bab1710e286 (diff)
of/flattree: merge early_init_dt_scan_chosen()
Merge common code between PowerPC and Microblaze. This patch splits the arch-specific stuff out into a new function, early_init_dt_scan_chosen_arch(). Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Tested-by: Wolfram Sang <w.sang@pengutronix.de> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'drivers/of/fdt.c')
-rw-r--r--drivers/of/fdt.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index ebce509b0886..616a4767a950 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -15,6 +15,10 @@
15#include <linux/of.h> 15#include <linux/of.h>
16#include <linux/of_fdt.h> 16#include <linux/of_fdt.h>
17 17
18#ifdef CONFIG_PPC
19#include <asm/machdep.h>
20#endif /* CONFIG_PPC */
21
18int __initdata dt_root_addr_cells; 22int __initdata dt_root_addr_cells;
19int __initdata dt_root_size_cells; 23int __initdata dt_root_size_cells;
20 24
@@ -440,6 +444,40 @@ u64 __init dt_mem_next_cell(int s, u32 **cellp)
440 return of_read_number(p, s); 444 return of_read_number(p, s);
441} 445}
442 446
447int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
448 int depth, void *data)
449{
450 unsigned long l;
451 char *p;
452
453 pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname);
454
455 if (depth != 1 ||
456 (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0))
457 return 0;
458
459 early_init_dt_check_for_initrd(node);
460
461 /* Retreive command line */
462 p = of_get_flat_dt_prop(node, "bootargs", &l);
463 if (p != NULL && l > 0)
464 strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));
465
466#ifdef CONFIG_CMDLINE
467#ifndef CONFIG_CMDLINE_FORCE
468 if (p == NULL || l == 0 || (l == 1 && (*p) == 0))
469#endif
470 strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
471#endif /* CONFIG_CMDLINE */
472
473 early_init_dt_scan_chosen_arch(node);
474
475 pr_debug("Command line is: %s\n", cmd_line);
476
477 /* break now */
478 return 1;
479}
480
443/** 481/**
444 * unflatten_device_tree - create tree of device_nodes from flat blob 482 * unflatten_device_tree - create tree of device_nodes from flat blob
445 * 483 *