Skip to content

Commit

Permalink
of/flattree: Merge early_init_dt_check_for_initrd()
Browse files Browse the repository at this point in the history
Merge common code between PowerPC and Microblaze

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>
  • Loading branch information
Grant Likely committed Dec 10, 2009
1 parent 2be09cb commit f7b3a83
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 62 deletions.
32 changes: 0 additions & 32 deletions arch/microblaze/kernel/prom.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,38 +113,6 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
return 0;
}

#ifdef CONFIG_BLK_DEV_INITRD
static void __init early_init_dt_check_for_initrd(unsigned long node)
{
unsigned long l;
u32 *prop;

pr_debug("Looking for initrd properties... ");

prop = of_get_flat_dt_prop(node, "linux,initrd-start", &l);
if (prop) {
initrd_start = (unsigned long)
__va((u32)of_read_ulong(prop, l/4));

prop = of_get_flat_dt_prop(node, "linux,initrd-end", &l);
if (prop) {
initrd_end = (unsigned long)
__va((u32)of_read_ulong(prop, 1/4));
initrd_below_start_ok = 1;
} else {
initrd_start = 0;
}
}

pr_debug("initrd_start=0x%lx initrd_end=0x%lx\n",
initrd_start, initrd_end);
}
#else
static inline void early_init_dt_check_for_initrd(unsigned long node)
{
}
#endif /* CONFIG_BLK_DEV_INITRD */

static int __init early_init_dt_scan_chosen(unsigned long node,
const char *uname, int depth, void *data)
{
Expand Down
30 changes: 0 additions & 30 deletions arch/powerpc/kernel/prom.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,36 +373,6 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
return 0;
}

#ifdef CONFIG_BLK_DEV_INITRD
static void __init early_init_dt_check_for_initrd(unsigned long node)
{
unsigned long l;
u32 *prop;

DBG("Looking for initrd properties... ");

prop = of_get_flat_dt_prop(node, "linux,initrd-start", &l);
if (prop) {
initrd_start = (unsigned long)__va(of_read_ulong(prop, l/4));

prop = of_get_flat_dt_prop(node, "linux,initrd-end", &l);
if (prop) {
initrd_end = (unsigned long)
__va(of_read_ulong(prop, l/4));
initrd_below_start_ok = 1;
} else {
initrd_start = 0;
}
}

DBG("initrd_start=0x%lx initrd_end=0x%lx\n", initrd_start, initrd_end);
}
#else
static inline void early_init_dt_check_for_initrd(unsigned long node)
{
}
#endif /* CONFIG_BLK_DEV_INITRD */

static int __init early_init_dt_scan_chosen(unsigned long node,
const char *uname, int depth, void *data)
{
Expand Down
37 changes: 37 additions & 0 deletions drivers/of/fdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <linux/kernel.h>
#include <linux/lmb.h>
#include <linux/initrd.h>
#include <linux/of.h>
#include <linux/of_fdt.h>

Expand Down Expand Up @@ -369,6 +370,42 @@ unsigned long __init unflatten_dt_node(unsigned long mem,
return mem;
}

#ifdef CONFIG_BLK_DEV_INITRD
/**
* early_init_dt_check_for_initrd - Decode initrd location from flat tree
* @node: reference to node containing initrd location ('chosen')
*/
void __init early_init_dt_check_for_initrd(unsigned long node)
{
unsigned long len;
u32 *prop;

pr_debug("Looking for initrd properties... ");

prop = of_get_flat_dt_prop(node, "linux,initrd-start", &len);
if (prop) {
initrd_start = (unsigned long)
__va(of_read_ulong(prop, len/4));

prop = of_get_flat_dt_prop(node, "linux,initrd-end", &len);
if (prop) {
initrd_end = (unsigned long)
__va(of_read_ulong(prop, len/4));
initrd_below_start_ok = 1;
} else {
initrd_start = 0;
}
}

pr_debug("initrd_start=0x%lx initrd_end=0x%lx\n",
initrd_start, initrd_end);
}
#else
inline void early_init_dt_check_for_initrd(unsigned long node)
{
}
#endif /* CONFIG_BLK_DEV_INITRD */

/**
* unflatten_device_tree - create tree of device_nodes from flat blob
*
Expand Down
1 change: 1 addition & 0 deletions include/linux/of_fdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ extern void *of_get_flat_dt_prop(unsigned long node, const char *name,
unsigned long *size);
extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
extern unsigned long of_get_flat_dt_root(void);
extern void early_init_dt_check_for_initrd(unsigned long node);

/* Other Prototypes */
extern void finish_device_tree(void);
Expand Down

0 comments on commit f7b3a83

Please sign in to comment.