aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2009-11-23 21:44:23 -0500
committerGrant Likely <grant.likely@secretlab.ca>2009-11-23 21:44:23 -0500
commit819d2819303654c6829d572e698e2d0021c08599 (patch)
tree8e98224edfc837a630625b9e05c74121c7fa9b3f
parentc8cb7a59842c0b512b44f6f818cdb0b5a3ddc89e (diff)
of/flattree: merge of_get_flat_dt_root
Merge common code between PowerPC and MicroBlaze Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Reviewed-by: Wolfram Sang <w.sang@pengutronix.de> Tested-by: Michal Simek <monstr@monstr.eu>
-rw-r--r--arch/microblaze/kernel/prom.c12
-rw-r--r--arch/powerpc/kernel/prom.c12
-rw-r--r--drivers/of/fdt.c16
3 files changed, 16 insertions, 24 deletions
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index 0db8ee64ffe6..7eb6f8bdb81a 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -50,18 +50,6 @@ typedef u32 cell_t;
50/* export that to outside world */ 50/* export that to outside world */
51struct device_node *of_chosen; 51struct device_node *of_chosen;
52 52
53unsigned long __init of_get_flat_dt_root(void)
54{
55 unsigned long p = ((unsigned long)initial_boot_params) +
56 initial_boot_params->off_dt_struct;
57
58 while (*((u32 *)p) == OF_DT_NOP)
59 p += 4;
60 BUG_ON(*((u32 *)p) != OF_DT_BEGIN_NODE);
61 p += 4;
62 return _ALIGN(p + strlen((char *)p) + 1, 4);
63}
64
65/** 53/**
66 * This function can be used within scan_flattened_dt callback to get 54 * This function can be used within scan_flattened_dt callback to get
67 * access to properties 55 * access to properties
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 14a07b9e00d1..b5d5f85e9c2c 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -80,18 +80,6 @@ extern rwlock_t devtree_lock; /* temporary while merging */
80/* export that to outside world */ 80/* export that to outside world */
81struct device_node *of_chosen; 81struct device_node *of_chosen;
82 82
83unsigned long __init of_get_flat_dt_root(void)
84{
85 unsigned long p = ((unsigned long)initial_boot_params) +
86 initial_boot_params->off_dt_struct;
87
88 while(*((u32 *)p) == OF_DT_NOP)
89 p += 4;
90 BUG_ON (*((u32 *)p) != OF_DT_BEGIN_NODE);
91 p += 4;
92 return _ALIGN(p + strlen((char *)p) + 1, 4);
93}
94
95/** 83/**
96 * This function can be used within scan_flattened_dt callback to get 84 * This function can be used within scan_flattened_dt callback to get
97 * access to properties 85 * access to properties
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index dd9057cb7aa7..f41d739aa2f7 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -83,3 +83,19 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
83 83
84 return rc; 84 return rc;
85} 85}
86
87/**
88 * of_get_flat_dt_root - find the root node in the flat blob
89 */
90unsigned long __init of_get_flat_dt_root(void)
91{
92 unsigned long p = ((unsigned long)initial_boot_params) +
93 initial_boot_params->off_dt_struct;
94
95 while (*((u32 *)p) == OF_DT_NOP)
96 p += 4;
97 BUG_ON(*((u32 *)p) != OF_DT_BEGIN_NODE);
98 p += 4;
99 return _ALIGN(p + strlen((char *)p) + 1, 4);
100}
101