diff options
| author | Grant Likely <grant.likely@secretlab.ca> | 2009-12-11 01:42:21 -0500 |
|---|---|---|
| committer | Grant Likely <grant.likely@secretlab.ca> | 2009-12-11 01:42:21 -0500 |
| commit | 86e032213424958b45564d0cc96b3316641a49d3 (patch) | |
| tree | 34b9f5ddd49180a558a325b9ccb47140f5cc7cbd | |
| parent | 0f0b56c3f2df4a083fc9e934266e5bab1710e286 (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>
| -rw-r--r-- | arch/microblaze/kernel/prom.c | 44 | ||||
| -rw-r--r-- | arch/powerpc/kernel/prom.c | 46 | ||||
| -rw-r--r-- | drivers/of/fdt.c | 38 | ||||
| -rw-r--r-- | include/linux/of_fdt.h | 3 |
4 files changed, 53 insertions, 78 deletions
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c index 50d8b09d5e3f..5505bcffd7dd 100644 --- a/arch/microblaze/kernel/prom.c +++ b/arch/microblaze/kernel/prom.c | |||
| @@ -108,49 +108,9 @@ static int __init early_init_dt_scan_cpus(unsigned long node, | |||
| 108 | return 0; | 108 | return 0; |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | static int __init early_init_dt_scan_chosen(unsigned long node, | 111 | void __init early_init_dt_scan_chosen_arch(unsigned long node) |
| 112 | const char *uname, int depth, void *data) | ||
| 113 | { | 112 | { |
| 114 | unsigned long l; | 113 | /* No Microblaze specific code here */ |
| 115 | char *p; | ||
| 116 | |||
| 117 | pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname); | ||
| 118 | |||
| 119 | if (depth != 1 || | ||
| 120 | (strcmp(uname, "chosen") != 0 && | ||
| 121 | strcmp(uname, "chosen@0") != 0)) | ||
| 122 | return 0; | ||
| 123 | |||
| 124 | #ifdef CONFIG_KEXEC | ||
| 125 | lprop = (u64 *)of_get_flat_dt_prop(node, | ||
| 126 | "linux,crashkernel-base", NULL); | ||
| 127 | if (lprop) | ||
| 128 | crashk_res.start = *lprop; | ||
| 129 | |||
| 130 | lprop = (u64 *)of_get_flat_dt_prop(node, | ||
| 131 | "linux,crashkernel-size", NULL); | ||
| 132 | if (lprop) | ||
| 133 | crashk_res.end = crashk_res.start + *lprop - 1; | ||
| 134 | #endif | ||
| 135 | |||
| 136 | early_init_dt_check_for_initrd(node); | ||
| 137 | |||
| 138 | /* Retreive command line */ | ||
| 139 | p = of_get_flat_dt_prop(node, "bootargs", &l); | ||
| 140 | if (p != NULL && l > 0) | ||
| 141 | strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE)); | ||
| 142 | |||
| 143 | #ifdef CONFIG_CMDLINE | ||
| 144 | #ifndef CONFIG_CMDLINE_FORCE | ||
| 145 | if (p == NULL || l == 0 || (l == 1 && (*p) == 0)) | ||
| 146 | #endif | ||
| 147 | strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); | ||
| 148 | #endif /* CONFIG_CMDLINE */ | ||
| 149 | |||
| 150 | pr_debug("Command line is: %s\n", cmd_line); | ||
| 151 | |||
| 152 | /* break now */ | ||
| 153 | return 1; | ||
| 154 | } | 114 | } |
| 155 | 115 | ||
| 156 | static int __init early_init_dt_scan_memory(unsigned long node, | 116 | static int __init early_init_dt_scan_memory(unsigned long node, |
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index 4e3181cded44..877fad9b3745 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c | |||
| @@ -367,18 +367,9 @@ static int __init early_init_dt_scan_cpus(unsigned long node, | |||
| 367 | return 0; | 367 | return 0; |
| 368 | } | 368 | } |
| 369 | 369 | ||
| 370 | static int __init early_init_dt_scan_chosen(unsigned long node, | 370 | void __init early_init_dt_scan_chosen_arch(unsigned long node) |
| 371 | const char *uname, int depth, void *data) | ||
| 372 | { | 371 | { |
| 373 | unsigned long *lprop; | 372 | unsigned long *lprop; |
| 374 | unsigned long l; | ||
| 375 | char *p; | ||
| 376 | |||
| 377 | DBG("search \"chosen\", depth: %d, uname: %s\n", depth, uname); | ||
| 378 | |||
| 379 | if (depth != 1 || | ||
| 380 | (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0)) | ||
| 381 | return 0; | ||
| 382 | 373 | ||
| 383 | #ifdef CONFIG_PPC64 | 374 | #ifdef CONFIG_PPC64 |
| 384 | /* check if iommu is forced on or off */ | 375 | /* check if iommu is forced on or off */ |
| @@ -389,17 +380,17 @@ static int __init early_init_dt_scan_chosen(unsigned long node, | |||
| 389 | #endif | 380 | #endif |
| 390 | 381 | ||
| 391 | /* mem=x on the command line is the preferred mechanism */ | 382 | /* mem=x on the command line is the preferred mechanism */ |
| 392 | lprop = of_get_flat_dt_prop(node, "linux,memory-limit", NULL); | 383 | lprop = of_get_flat_dt_prop(node, "linux,memory-limit", NULL); |
| 393 | if (lprop) | 384 | if (lprop) |
| 394 | memory_limit = *lprop; | 385 | memory_limit = *lprop; |
| 395 | 386 | ||
| 396 | #ifdef CONFIG_PPC64 | 387 | #ifdef CONFIG_PPC64 |
| 397 | lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-start", NULL); | 388 | lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-start", NULL); |
| 398 | if (lprop) | 389 | if (lprop) |
| 399 | tce_alloc_start = *lprop; | 390 | tce_alloc_start = *lprop; |
| 400 | lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-end", NULL); | 391 | lprop = of_get_flat_dt_prop(node, "linux,tce-alloc-end", NULL); |
| 401 | if (lprop) | 392 | if (lprop) |
| 402 | tce_alloc_end = *lprop; | 393 | tce_alloc_end = *lprop; |
| 403 | #endif | 394 | #endif |
| 404 | 395 | ||
| 405 | #ifdef CONFIG_KEXEC | 396 | #ifdef CONFIG_KEXEC |
| @@ -411,23 +402,6 @@ static int __init early_init_dt_scan_chosen(unsigned long node, | |||
| 411 | if (lprop) | 402 | if (lprop) |
| 412 | crashk_res.end = crashk_res.start + *lprop - 1; | 403 | crashk_res.end = crashk_res.start + *lprop - 1; |
| 413 | #endif | 404 | #endif |
| 414 | |||
| 415 | early_init_dt_check_for_initrd(node); | ||
| 416 | |||
| 417 | /* Retreive command line */ | ||
| 418 | p = of_get_flat_dt_prop(node, "bootargs", &l); | ||
| 419 | if (p != NULL && l > 0) | ||
| 420 | strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE)); | ||
| 421 | |||
| 422 | #ifdef CONFIG_CMDLINE | ||
| 423 | if (p == NULL || l == 0 || (l == 1 && (*p) == 0)) | ||
| 424 | strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); | ||
| 425 | #endif /* CONFIG_CMDLINE */ | ||
| 426 | |||
| 427 | DBG("Command line is: %s\n", cmd_line); | ||
| 428 | |||
| 429 | /* break now */ | ||
| 430 | return 1; | ||
| 431 | } | 405 | } |
| 432 | 406 | ||
| 433 | #ifdef CONFIG_PPC_PSERIES | 407 | #ifdef CONFIG_PPC_PSERIES |
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 | |||
| 18 | int __initdata dt_root_addr_cells; | 22 | int __initdata dt_root_addr_cells; |
| 19 | int __initdata dt_root_size_cells; | 23 | int __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 | ||
| 447 | int __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 | * |
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index d1a37e56031e..8118d4559dd5 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h | |||
| @@ -71,6 +71,9 @@ extern void *of_get_flat_dt_prop(unsigned long node, const char *name, | |||
| 71 | unsigned long *size); | 71 | unsigned long *size); |
| 72 | extern int of_flat_dt_is_compatible(unsigned long node, const char *name); | 72 | extern int of_flat_dt_is_compatible(unsigned long node, const char *name); |
| 73 | extern unsigned long of_get_flat_dt_root(void); | 73 | extern unsigned long of_get_flat_dt_root(void); |
| 74 | extern void early_init_dt_scan_chosen_arch(unsigned long node); | ||
| 75 | extern int early_init_dt_scan_chosen(unsigned long node, const char *uname, | ||
| 76 | int depth, void *data); | ||
| 74 | extern void early_init_dt_check_for_initrd(unsigned long node); | 77 | extern void early_init_dt_check_for_initrd(unsigned long node); |
| 75 | extern u64 dt_mem_next_cell(int s, u32 **cellp); | 78 | extern u64 dt_mem_next_cell(int s, u32 **cellp); |
| 76 | 79 | ||
