Commit 86e03221 authored by Grant Likely's avatar Grant Likely

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: default avatarGrant Likely <grant.likely@secretlab.ca>
Tested-by: default avatarWolfram Sang <w.sang@pengutronix.de>
Acked-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 0f0b56c3
...@@ -108,49 +108,9 @@ static int __init early_init_dt_scan_cpus(unsigned long node, ...@@ -108,49 +108,9 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
return 0; return 0;
} }
static int __init early_init_dt_scan_chosen(unsigned long node, void __init early_init_dt_scan_chosen_arch(unsigned long node)
const char *uname, int depth, void *data)
{ {
unsigned long l; /* No Microblaze specific code here */
char *p;
pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname);
if (depth != 1 ||
(strcmp(uname, "chosen") != 0 &&
strcmp(uname, "chosen@0") != 0))
return 0;
#ifdef CONFIG_KEXEC
lprop = (u64 *)of_get_flat_dt_prop(node,
"linux,crashkernel-base", NULL);
if (lprop)
crashk_res.start = *lprop;
lprop = (u64 *)of_get_flat_dt_prop(node,
"linux,crashkernel-size", NULL);
if (lprop)
crashk_res.end = crashk_res.start + *lprop - 1;
#endif
early_init_dt_check_for_initrd(node);
/* Retreive command line */
p = of_get_flat_dt_prop(node, "bootargs", &l);
if (p != NULL && l > 0)
strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));
#ifdef CONFIG_CMDLINE
#ifndef CONFIG_CMDLINE_FORCE
if (p == NULL || l == 0 || (l == 1 && (*p) == 0))
#endif
strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
#endif /* CONFIG_CMDLINE */
pr_debug("Command line is: %s\n", cmd_line);
/* break now */
return 1;
} }
static int __init early_init_dt_scan_memory(unsigned long node, static int __init early_init_dt_scan_memory(unsigned long node,
......
...@@ -367,18 +367,9 @@ static int __init early_init_dt_scan_cpus(unsigned long node, ...@@ -367,18 +367,9 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
return 0; return 0;
} }
static int __init early_init_dt_scan_chosen(unsigned long node, void __init early_init_dt_scan_chosen_arch(unsigned long node)
const char *uname, int depth, void *data)
{ {
unsigned long *lprop; unsigned long *lprop;
unsigned long l;
char *p;
DBG("search \"chosen\", depth: %d, uname: %s\n", depth, uname);
if (depth != 1 ||
(strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0))
return 0;
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
/* check if iommu is forced on or off */ /* check if iommu is forced on or off */
...@@ -411,23 +402,6 @@ static int __init early_init_dt_scan_chosen(unsigned long node, ...@@ -411,23 +402,6 @@ static int __init early_init_dt_scan_chosen(unsigned long node,
if (lprop) if (lprop)
crashk_res.end = crashk_res.start + *lprop - 1; crashk_res.end = crashk_res.start + *lprop - 1;
#endif #endif
early_init_dt_check_for_initrd(node);
/* Retreive command line */
p = of_get_flat_dt_prop(node, "bootargs", &l);
if (p != NULL && l > 0)
strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));
#ifdef CONFIG_CMDLINE
if (p == NULL || l == 0 || (l == 1 && (*p) == 0))
strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
#endif /* CONFIG_CMDLINE */
DBG("Command line is: %s\n", cmd_line);
/* break now */
return 1;
} }
#ifdef CONFIG_PPC_PSERIES #ifdef CONFIG_PPC_PSERIES
......
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_fdt.h> #include <linux/of_fdt.h>
#ifdef CONFIG_PPC
#include <asm/machdep.h>
#endif /* CONFIG_PPC */
int __initdata dt_root_addr_cells; int __initdata dt_root_addr_cells;
int __initdata dt_root_size_cells; int __initdata dt_root_size_cells;
...@@ -440,6 +444,40 @@ u64 __init dt_mem_next_cell(int s, u32 **cellp) ...@@ -440,6 +444,40 @@ u64 __init dt_mem_next_cell(int s, u32 **cellp)
return of_read_number(p, s); return of_read_number(p, s);
} }
int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
int depth, void *data)
{
unsigned long l;
char *p;
pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname);
if (depth != 1 ||
(strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0))
return 0;
early_init_dt_check_for_initrd(node);
/* Retreive command line */
p = of_get_flat_dt_prop(node, "bootargs", &l);
if (p != NULL && l > 0)
strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));
#ifdef CONFIG_CMDLINE
#ifndef CONFIG_CMDLINE_FORCE
if (p == NULL || l == 0 || (l == 1 && (*p) == 0))
#endif
strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
#endif /* CONFIG_CMDLINE */
early_init_dt_scan_chosen_arch(node);
pr_debug("Command line is: %s\n", cmd_line);
/* break now */
return 1;
}
/** /**
* unflatten_device_tree - create tree of device_nodes from flat blob * unflatten_device_tree - create tree of device_nodes from flat blob
* *
......
...@@ -71,6 +71,9 @@ extern void *of_get_flat_dt_prop(unsigned long node, const char *name, ...@@ -71,6 +71,9 @@ extern void *of_get_flat_dt_prop(unsigned long node, const char *name,
unsigned long *size); unsigned long *size);
extern int of_flat_dt_is_compatible(unsigned long node, const char *name); extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
extern unsigned long of_get_flat_dt_root(void); extern unsigned long of_get_flat_dt_root(void);
extern void early_init_dt_scan_chosen_arch(unsigned long node);
extern int early_init_dt_scan_chosen(unsigned long node, const char *uname,
int depth, void *data);
extern void early_init_dt_check_for_initrd(unsigned long node); extern void early_init_dt_check_for_initrd(unsigned long node);
extern u64 dt_mem_next_cell(int s, u32 **cellp); extern u64 dt_mem_next_cell(int s, u32 **cellp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment