Skip to contentSkip to conversation

More OF merge patches

PATCH In review Grant Likely 5 participants 21 messages Nov 5, 2009 – Nov 10, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover More OF merge patches

Round 2. Here is my 2nd set of merging OF code between PowerPC and Microblaze (no SPARC changes this time). Compile tested on ppc, microblaze and sparc. Boot tested on MPC5200 powerpc platform.

I've also pushed this series out to the test-devicetree branch on my git server if anyone cares to pull and test:

git://git.secretlab.ca/git/linux-2.6 test-devicetree

This is based on the next-devicetree branch which contains the first round of patches and is being pulled into linux-next.

Cheers,
g.

---

Grant Likely (11):
of/flattree: Merge early_init_dt_check_for_initrd()
of: remove special case definition of of_read_ulong()
of: merge prom_{add,remove,modify}_property of/flattree: Merge unflatten_device_tree of/flattree: Merge unflatten_dt_node
of/flattree: Merge of_flat_dt_is_compatible of/flattree: merge of_get_flat_dt_prop
of/flattree: remove __init annotations from the header file of/flattree: merge of_get_flat_dt_root
of/flattree: merge of_scan_flat_dt
of/flattree: merge find_flat_dt_string and initial_boot_params

 arch/microblaze/Kconfig            |    1 
 arch/microblaze/include/asm/prom.h |    1 
 arch/microblaze/kernel/prom.c      |  531 ------------------------------------
 arch/powerpc/Kconfig               |    1 
 arch/powerpc/kernel/prom.c         |  534 ------------------------------------
 drivers/of/Kconfig                 |    4 
 drivers/of/Makefile                |    1 
 drivers/of/base.c                  |  116 ++++++++
 drivers/of/fdt.c                   |  458 +++++++++++++++++++++++++++++++
 include/linux/of.h                 |   10 -
 include/linux/of_fdt.h             |   21 +
 11 files changed, 598 insertions(+), 1080 deletions(-)
 create mode 100644 drivers/of/fdt.c
#1 lore raw

PATCH 1/11 of/flattree: merge find_flat_dt_string and initial_boot_params

Merge common code between Microblaze and PowerPC. Also move instance of
---

 arch/microblaze/Kconfig       |    1 +
 arch/microblaze/kernel/prom.c |    8 --------
 arch/powerpc/Kconfig          |    1 +
 arch/powerpc/kernel/prom.c    |   12 ------------
 drivers/of/Kconfig            |    4 ++++
 drivers/of/Makefile           |    1 +
 drivers/of/fdt.c              |   21 +++++++++++++++++++++
 include/linux/of_fdt.h        |    4 ++++
 8 files changed, 32 insertions(+), 20 deletions(-)
 create mode 100644 drivers/of/fdt.c
arch/microblaze/Kconfig +1 -0
index bbd8327..f39c927 100644
@@ -111,6 +111,7 @@ config CMDLINE_FORCE
 
 config OF
 	def_bool y
+	select OF_FLATTREE
 
 config PROC_DEVICETREE
 	bool "Support for device tree in /proc"
arch/microblaze/kernel/prom.c +0 -8
index b817df1..06d620a 100644
@@ -47,17 +47,9 @@ static int __initdata dt_root_size_cells;
 
 typedef u32 cell_t;
 
-static struct boot_param_header *initial_boot_params;
-
 /* export that to outside world */
 struct device_node *of_chosen;
 
-static inline char *find_flat_dt_string(u32 offset)
-{
-	return ((char *)initial_boot_params) +
-		initial_boot_params->off_dt_strings + offset;
-}
-
 /**
  * This function is used to scan the flattened device-tree, it is
  * used to extract the memory informations at boot before we can
arch/powerpc/Kconfig +1 -0
index 10a0a54..5f6eed9 100644
@@ -163,6 +163,7 @@ config PPC_OF
 
 config OF
 	def_bool y
+	select OF_FLATTREE
 
 config PPC_UDBG_16550
 	bool
arch/powerpc/kernel/prom.c +0 -12
index 4ec3008..fccf7e4 100644
@@ -73,12 +73,6 @@ unsigned long tce_alloc_start, tce_alloc_end;
 
 typedef u32 cell_t;
 
-#if 0
-static struct boot_param_header *initial_boot_params __initdata;
-#else
-struct boot_param_header *initial_boot_params;
-#endif
-
 extern struct device_node *allnodes;	/* temporary while merging */
 
 extern rwlock_t devtree_lock;	/* temporary while merging */
@@ -86,12 +80,6 @@ extern rwlock_t devtree_lock;	/* temporary while merging */
 /* export that to outside world */
 struct device_node *of_chosen;
 
-static inline char *find_flat_dt_string(u32 offset)
-{
-	return ((char *)initial_boot_params) +
-		initial_boot_params->off_dt_strings + offset;
-}
-
 /**
  * This function is used to scan the flattened device-tree, it is
  * used to extract the memory informations at boot before we can
drivers/of/Kconfig +4 -0
index d2fa27c..462825e 100644
@@ -1,3 +1,7 @@
+config OF_FLATTREE
+	bool
+	depends on OF
+
 config OF_DEVICE
 	def_bool y
 	depends on OF && (SPARC || PPC_OF || MICROBLAZE)
drivers/of/Makefile +1 -0
index bdfb5f5..f232cc9 100644
@@ -1,4 +1,5 @@
 obj-y = base.o
+obj-$(CONFIG_OF_FLATTREE) += fdt.o
 obj-$(CONFIG_OF_DEVICE) += device.o platform.o
 obj-$(CONFIG_OF_GPIO)   += gpio.o
 obj-$(CONFIG_OF_I2C)	+= of_i2c.o
drivers/of/fdt.c new file +21 -0
new file mode 100644
index 0000000..9faa9a5
@@ -0,0 +1,21 @@
+/*
+ * Functions for working with the Flattened Device Tree data format
+ *
+ * Copyright 2009 Benjamin Herrenschmidt, IBM Corp
+ * [email protected]
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ */
+
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+
+struct boot_param_header *initial_boot_params;
+
+char *find_flat_dt_string(u32 offset)
+{
+	return ((char *)initial_boot_params) +
+		initial_boot_params->off_dt_strings + offset;
+}
include/linux/of_fdt.h +4 -0
index 41d432b..d1a79f3 100644
@@ -57,7 +57,11 @@ struct boot_param_header {
 	u32	dt_struct_size;		/* size of the DT structure block */
 };
 
+/* TBD: Temporary export of fdt globals - remove when code fully merged */
+extern struct boot_param_header *initial_boot_params;
+
 /* For scanning the flat device-tree at boot time */
+extern char *find_flat_dt_string(u32 offset);
 extern int __init of_scan_flat_dt(int (*it)(unsigned long node,
 					    const char *uname, int depth,
 					    void *data),
#2 lore raw

Re: [PATCH 01/11] of/flattree: merge find_flat_dt_string and initial_boot_params

Quoted 4 lines · Grant Likely

Merge common code between Microblaze and PowerPC. Also move instance of
---

 arch/microblaze/Kconfig       |    1 +

Commit message cut off?

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

#3 lore raw

Re: [PATCH 01/11] of/flattree: merge find_flat_dt_string and initial_boot_params

Quoted 7 lines · Wolfram Sang
Quoted 4 lines · Grant Likely

Merge common code between Microblaze and PowerPC.  Also move instance of
---

 arch/microblaze/Kconfig       |    1 +

Commit message cut off?

No, I just never completed writing that log message. I don't know why. I'll fix before the next posting.

g.

Signature · 6 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw

PATCH 2/11 of/flattree: merge of_scan_flat_dt

In reply to Grant Likely

Merge common code between PowerPC and Microblaze
---

 arch/microblaze/kernel/prom.c |   61 --------------------------------------
 arch/powerpc/kernel/prom.c    |   61 --------------------------------------
 drivers/of/fdt.c              |   65 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 65 insertions(+), 122 deletions(-)
arch/microblaze/kernel/prom.c +0 -61
index 06d620a..0db8ee6 100644
@@ -50,67 +50,6 @@ typedef u32 cell_t;
 /* export that to outside world */
 struct device_node *of_chosen;
 
-/**
- * This function is used to scan the flattened device-tree, it is
- * used to extract the memory informations at boot before we can
- * unflatten the tree
- */
-int __init of_scan_flat_dt(int (*it)(unsigned long node,
-				     const char *uname, int depth,
-				     void *data),
-			   void *data)
-{
-	unsigned long p = ((unsigned long)initial_boot_params) +
-		initial_boot_params->off_dt_struct;
-	int rc = 0;
-	int depth = -1;
-
-	do {
-		u32 tag = *((u32 *)p);
-		char *pathp;
-
-		p += 4;
-		if (tag == OF_DT_END_NODE) {
-			depth--;
-			continue;
-		}
-		if (tag == OF_DT_NOP)
-			continue;
-		if (tag == OF_DT_END)
-			break;
-		if (tag == OF_DT_PROP) {
-			u32 sz = *((u32 *)p);
-			p += 8;
-			if (initial_boot_params->version < 0x10)
-				p = _ALIGN(p, sz >= 8 ? 8 : 4);
-			p += sz;
-			p = _ALIGN(p, 4);
-			continue;
-		}
-		if (tag != OF_DT_BEGIN_NODE) {
-			printk(KERN_WARNING "Invalid tag %x scanning flattened"
-				" device tree !\n", tag);
-			return -EINVAL;
-		}
-		depth++;
-		pathp = (char *)p;
-		p = _ALIGN(p + strlen(pathp) + 1, 4);
-		if ((*pathp) == '/') {
-			char *lp, *np;
-			for (lp = NULL, np = pathp; *np; np++)
-				if ((*np) == '/')
-					lp = np+1;
-			if (lp != NULL)
-				pathp = lp;
-		}
-		rc = it(p, pathp, depth, data);
-		if (rc != 0)
-			break;
-	} while (1);
-
-	return rc;
-}
-
 unsigned long __init of_get_flat_dt_root(void)
 {
 	unsigned long p = ((unsigned long)initial_boot_params) +
arch/powerpc/kernel/prom.c +0 -61

67 lines not on this page · raw message

drivers/of/fdt.c +65 -0

68 lines not on this page · raw message

#5 lore raw

Re: [PATCH 02/11] of/flattree: merge of_scan_flat_dt

Quoted 1 line · Grant Likely

Merge common code between PowerPC and Microblaze

Just minor fixes in nanodoc.

drivers/of/fdt.c char *find_flat_dt_string(u32 offset) · line 24

Quoted 11 lines
drivers/of/fdt.c +3 -0
index 9faa9a5..7c3c13c 100644
@@ -19,3 +19,68 @@ char *find_flat_dt_string(u32 offset)
 	return ((char *)initial_boot_params) +
 		initial_boot_params->off_dt_strings + offset;
 }
+
+/**
+ * of_scan_flat_dt - scan flattend tree blob and call callback on each.

flattened

drivers/of/fdt.c char *find_flat_dt_string(u32 offset) · line 29

Quoted 5 lines
drivers/of/fdt.c +5 -0
+ * @it: callback function
+ * @data: context data pointer
+ *
+ * This function is used to scan the flattened device-tree, it is
+ * used to extract the memory informations at boot before we can

I am not a native speaker, yet I have been taught there is no "informations".

Quoted 2 lines
drivers/of/fdt.c +2 -0
+ * unflatten the tree
+ */
Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#6 lore raw

PATCH 3/11 of/flattree: merge of_get_flat_dt_root

In reply to Grant Likely

Merge common code between PowerPC and MicroBlaze

---

 arch/microblaze/kernel/prom.c |   12 ------------
 arch/powerpc/kernel/prom.c    |   12 ------------
 drivers/of/fdt.c              |   16 ++++++++++++++++
 3 files changed, 16 insertions(+), 24 deletions(-)
arch/microblaze/kernel/prom.c +0 -12
index 0db8ee6..7eb6f8b 100644
@@ -50,18 +50,6 @@ typedef u32 cell_t;
 /* export that to outside world */
 struct device_node *of_chosen;
 
-unsigned long __init of_get_flat_dt_root(void)
-{
-	unsigned long p = ((unsigned long)initial_boot_params) +
-		initial_boot_params->off_dt_struct;
-
-	while (*((u32 *)p) == OF_DT_NOP)
-		p += 4;
-	BUG_ON(*((u32 *)p) != OF_DT_BEGIN_NODE);
-	p += 4;
-	return _ALIGN(p + strlen((char *)p) + 1, 4);
-}
-
 /**
  * This function can be used within scan_flattened_dt callback to get
  * access to properties
arch/powerpc/kernel/prom.c +0 -12
index 14a07b9..b5d5f85 100644
@@ -80,18 +80,6 @@ extern rwlock_t devtree_lock;	/* temporary while merging */
 /* export that to outside world */
 struct device_node *of_chosen;
 
-unsigned long __init of_get_flat_dt_root(void)
-{
-	unsigned long p = ((unsigned long)initial_boot_params) +
-		initial_boot_params->off_dt_struct;
-
-	while(*((u32 *)p) == OF_DT_NOP)
-		p += 4;
-	BUG_ON (*((u32 *)p) != OF_DT_BEGIN_NODE);
-	p += 4;
-	return _ALIGN(p + strlen((char *)p) + 1, 4);
-}
-
 /**
  * This  function can be used within scan_flattened_dt callback to get
  * access to properties
drivers/of/fdt.c +16 -0
index 7c3c13c..a6e869e 100644
@@ -84,3 +84,19 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
 
 	return rc;
 }
+
+/**
+ * of_get_flat_dt_root - find the root node in the flat blob
+ */
+unsigned long __init of_get_flat_dt_root(void)
+{
+	unsigned long p = ((unsigned long)initial_boot_params) +
+		initial_boot_params->off_dt_struct;
+
+	while (*((u32 *)p) == OF_DT_NOP)
+		p += 4;
+	BUG_ON(*((u32 *)p) != OF_DT_BEGIN_NODE);
+	p += 4;
+	return _ALIGN(p + strlen((char *)p) + 1, 4);
+}
+
#7 lore raw

PATCH 4/11 of/flattree: remove __init annotations from the header file

In reply to Grant Likely

__init annotation belongs in the .c file, not the header.

---

 include/linux/of_fdt.h |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)
include/linux/of_fdt.h +7 -9
index d1a79f3..81231e0 100644
@@ -62,15 +62,13 @@ extern struct boot_param_header *initial_boot_params;
 
 /* For scanning the flat device-tree at boot time */
 extern char *find_flat_dt_string(u32 offset);
-extern int __init of_scan_flat_dt(int (*it)(unsigned long node,
-					    const char *uname, int depth,
-					    void *data),
-				  void *data);
-extern void __init *of_get_flat_dt_prop(unsigned long node, const char *name,
-					unsigned long *size);
-extern int __init of_flat_dt_is_compatible(unsigned long node,
-					   const char *name);
-extern unsigned long __init of_get_flat_dt_root(void);
+extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname,
+				     int depth, void *data),
+			   void *data);
+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);
 
 /* Other Prototypes */
 extern void finish_device_tree(void);
#8 lore raw

PATCH 5/11 of/flattree: merge of_get_flat_dt_prop

In reply to Grant Likely

Merge common code between PowerPC and Microblaze

---

 arch/microblaze/kernel/prom.c |   42 ----------------------------------------
 arch/powerpc/kernel/prom.c    |   42 ----------------------------------------
 drivers/of/fdt.c              |   43 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+), 84 deletions(-)
arch/microblaze/kernel/prom.c +0 -42
index 7eb6f8b..d75c625 100644
@@ -50,48 +50,6 @@ typedef u32 cell_t;
 /* export that to outside world */
 struct device_node *of_chosen;
 
-/**
- * This function can be used within scan_flattened_dt callback to get
- * access to properties
- */
-void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
-				unsigned long *size)
-{
-	unsigned long p = node;
-
-	do {
-		u32 tag = *((u32 *)p);
-		u32 sz, noff;
-		const char *nstr;
-
-		p += 4;
-		if (tag == OF_DT_NOP)
-			continue;
-		if (tag != OF_DT_PROP)
-			return NULL;
-
-		sz = *((u32 *)p);
-		noff = *((u32 *)(p + 4));
-		p += 8;
-		if (initial_boot_params->version < 0x10)
-			p = _ALIGN(p, sz >= 8 ? 8 : 4);
-
-		nstr = find_flat_dt_string(noff);
-		if (nstr == NULL) {
-			printk(KERN_WARNING "Can't find property index"
-				" name !\n");
-			return NULL;
-		}
-		if (strcmp(name, nstr) == 0) {
-			if (size)
-				*size = sz;
-			return (void *)p;
-		}
-		p += sz;
-		p = _ALIGN(p, 4);
-	} while (1);
-}
-
 int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)
 {
 	const char *cp;
arch/powerpc/kernel/prom.c +0 -42

48 lines not on this page · raw message

drivers/of/fdt.c +43 -0

46 lines not on this page · raw message

#9 lore raw

Re: [PATCH 05/11] of/flattree: merge of_get_flat_dt_prop

Quoted 3 lines · Grant Likely

Merge common code between PowerPC and Microblaze

nanodoc comment again

drivers/of/fdt.c unsigned long __init of_get_flat_dt_root(void) · line 106

Quoted 12 lines
drivers/of/fdt.c +4 -0
index a6e869e..7a51343 100644
@@ -100,3 +100,46 @@ unsigned long __init of_get_flat_dt_root(void)
 	return _ALIGN(p + strlen((char *)p) + 1, 4);
 }
 
+/**
+ * of_get_flat_dt_prop - Given a node in the flat blob, return the property pointer
+ *
+ * This  function can be used within scan_flattened_dt callback to get

double space

Quoted 2 lines
drivers/of/fdt.c +2 -0
+ * access to properties
+ */
Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#10 lore raw

PATCH 6/11 of/flattree: Merge of_flat_dt_is_compatible

In reply to Grant Likely

Merge common code between PowerPC and Microblaze

---

 arch/microblaze/kernel/prom.c |   19 -------------------
 arch/powerpc/kernel/prom.c    |   19 -------------------
 drivers/of/fdt.c              |   24 ++++++++++++++++++++++++
 3 files changed, 24 insertions(+), 38 deletions(-)
arch/microblaze/kernel/prom.c +0 -19
index d75c625..eb27bd3 100644
@@ -50,25 +50,6 @@ typedef u32 cell_t;
 /* export that to outside world */
 struct device_node *of_chosen;
 
-int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)
-{
-	const char *cp;
-	unsigned long cplen, l;
-
-	cp = of_get_flat_dt_prop(node, "compatible", &cplen);
-	if (cp == NULL)
-		return 0;
-	while (cplen > 0) {
-		if (strncasecmp(cp, compat, strlen(compat)) == 0)
-			return 1;
-		l = strlen(cp) + 1;
-		cp += l;
-		cplen -= l;
-	}
-
-	return 0;
-}
-
 static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size,
 					unsigned long align)
 {
arch/powerpc/kernel/prom.c +0 -19
index cd0a2bf..413e608 100644
@@ -80,25 +80,6 @@ extern rwlock_t devtree_lock;	/* temporary while merging */
 /* export that to outside world */
 struct device_node *of_chosen;
 
-int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)
-{
-	const char* cp;
-	unsigned long cplen, l;
-
-	cp = of_get_flat_dt_prop(node, "compatible", &cplen);
-	if (cp == NULL)
-		return 0;
-	while (cplen > 0) {
-		if (strncasecmp(cp, compat, strlen(compat)) == 0)
-			return 1;
-		l = strlen(cp) + 1;
-		cp += l;
-		cplen -= l;
-	}
-
-	return 0;
-}
-
 static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size,
 				       unsigned long align)
 {
drivers/of/fdt.c +24 -0
index 7a51343..01a7f5f 100644
@@ -143,3 +143,27 @@ void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
 	} while (1);
 }
 
+/**
+ * of_flat_dt_is_compatible - Return true if given node has compat in compatible list
+ * @node: node to test
+ * @compat: compatible string to compare with compatible list.
+ */
+int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)
+{
+	const char *cp;
+	unsigned long cplen, l;
+
+	cp = of_get_flat_dt_prop(node, "compatible", &cplen);
+	if (cp == NULL)
+		return 0;
+	while (cplen > 0) {
+		if (strncasecmp(cp, compat, strlen(compat)) == 0)
+			return 1;
+		l = strlen(cp) + 1;
+		cp += l;
+		cplen -= l;
+	}
+
+	return 0;
+}
+
#11 lore raw

PATCH 7/11 of/flattree: Merge unflatten_dt_node

In reply to Grant Likely

Merge common code between PowerPC and MicroBlaze

---

 arch/microblaze/kernel/prom.c |  195 ----------------------------------------
 arch/powerpc/kernel/prom.c    |  194 ----------------------------------------
 drivers/of/fdt.c              |  200 +++++++++++++++++++++++++++++++++++++++++
 include/linux/of_fdt.h        |    4 +
 4 files changed, 204 insertions(+), 389 deletions(-)
arch/microblaze/kernel/prom.c +0 -195
index eb27bd3..021770a 100644
@@ -50,201 +50,6 @@ typedef u32 cell_t;
 /* export that to outside world */
 struct device_node *of_chosen;
 
-static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size,
-					unsigned long align)
-{
-	void *res;
-
-	*mem = _ALIGN(*mem, align);
-	res = (void *)*mem;
-	*mem += size;
-
-	return res;
-}
-
-static unsigned long __init unflatten_dt_node(unsigned long mem,
-					unsigned long *p,
-					struct device_node *dad,
-					struct device_node ***allnextpp,
-					unsigned long fpsize)
-{
-	struct device_node *np;
-	struct property *pp, **prev_pp = NULL;
-	char *pathp;
-	u32 tag;
-	unsigned int l, allocl;
-	int has_name = 0;
-	int new_format = 0;
-
-	tag = *((u32 *)(*p));
-	if (tag != OF_DT_BEGIN_NODE) {
-		printk("Weird tag at start of node: %x\n", tag);
-		return mem;
-	}
-	*p += 4;
-	pathp = (char *)*p;
-	l = allocl = strlen(pathp) + 1;
-	*p = _ALIGN(*p + l, 4);
-
-	/* version 0x10 has a more compact unit name here instead of the full
-	 * path. we accumulate the full path size using "fpsize", we'll rebuild
-	 * it later. We detect this because the first character of the name is
-	 * not '/'.
-	 */
-	if ((*pathp) != '/') {
-		new_format = 1;
-		if (fpsize == 0) {
-			/* root node: special case. fpsize accounts for path
-			 * plus terminating zero. root node only has '/', so
-			 * fpsize should be 2, but we want to avoid the first
-			 * level nodes to have two '/' so we use fpsize 1 here
-			 */
-			fpsize = 1;
-			allocl = 2;
-		} else {
-			/* account for '/' and path size minus terminal 0
-			 * already in 'l'
-			 */
-			fpsize += l;
-			allocl = fpsize;
-		}
-	}
-
-	np = unflatten_dt_alloc(&mem, sizeof(struct device_node) + allocl,
-				__alignof__(struct device_node));
-	if (allnextpp) {
-		memset(np, 0, sizeof(*np));
-		np->full_name = ((char *)np) + sizeof(struct device_node);
-		if (new_format) {
-			char *p2 = np->full_name;
-			/* rebuild full path for new format */
-			if (dad && dad->parent) {
-				strcpy(p2, dad->full_name);
-#ifdef DEBUG
-				if ((strlen(p2) + l + 1) != allocl) {
-					pr_debug("%s: p: %d, l: %d, a: %d\n",
-						pathp, (int)strlen(p2),
-						l, allocl);
-				}
-#endif
-				p2 += strlen(p2);
-			}
-			*(p2++) = '/';
-			memcpy(p2, pathp, l);
-		} else
-			memcpy(np->full_name, pathp, l);
-		prev_pp = &np->properties;
-		**allnextpp = np;
-		*allnextpp = &np->allnext;
-		if (dad != NULL) {
-			np->parent = dad;
-			/* we temporarily use the next field as `last_child'*/
-			if (dad->next == NULL)
-				dad->child = np;
-			else
-				dad->next->sibling = np;
-			dad->next = np;
-		}
-		kref_init(&np->kref);
-	}
-	while (1) {
-		u32 sz, noff;
-		char *pname;
-
-		tag = *((u32 *)(*p));
-		if (tag == OF_DT_NOP) {
-			*p += 4;
-			continue;
-		}
-		if (tag != OF_DT_PROP)
-			break;
-		*p += 4;
-		sz = *((u32 *)(*p));
-		noff = *((u32 *)((*p) + 4));
-		*p += 8;
-		if (initial_boot_params->version < 0x10)
-			*p = _ALIGN(*p, sz >= 8 ? 8 : 4);
-
-		pname = find_flat_dt_string(noff);
-		if (pname == NULL) {
-			printk(KERN_INFO
-				"Can't find property name in list !\n");
-			break;
-		}
-		if (strcmp(pname, "name") == 0)
-			has_name = 1;
-		l = strlen(pname) + 1;
-		pp = unflatten_dt_alloc(&mem, sizeof(struct property),
-					__alignof__(struct property));
-		if (allnextpp) {
-			if (strcmp(pname, "linux,phandle") == 0) {
-				np->node = *((u32 *)*p);
-				if (np->linux_phandle == 0)
-					np->linux_phandle = np->node;
-			}
-			if (strcmp(pname, "ibm,phandle") == 0)
-				np->linux_phandle = *((u32 *)*p);
-			pp->name = pname;
-			pp->length = sz;
-			pp->value = (void *)*p;
-			*prev_pp = pp;
-			prev_pp = &pp->next;
-		}
-		*p = _ALIGN((*p) + sz, 4);
-	}
-	/* with version 0x10 we may not have the name property, recreate
-	 * it here from the unit name if absent
-	 */
-	if (!has_name) {
-		char *p1 = pathp, *ps = pathp, *pa = NULL;
-		int sz;
-
-		while (*p1) {
-			if ((*p1) == '@')
-				pa = p1;
-			if ((*p1) == '/')
-				ps = p1 + 1;
-			p1++;
-		}
-		if (pa < ps)
-			pa = p1;
-		sz = (pa - ps) + 1;
-		pp = unflatten_dt_alloc(&mem, sizeof(struct property) + sz,
-					__alignof__(struct property));
-		if (allnextpp) {
-			pp->name = "name";
-			pp->length = sz;
-			pp->value = pp + 1;
-			*prev_pp = pp;
-			prev_pp = &pp->next;
-			memcpy(pp->value, ps, sz - 1);
-			((char *)pp->value)[sz - 1] = 0;
-			pr_debug("fixed up name for %s -> %s\n", pathp,
-				(char *)pp->value);
-		}
-	}
-	if (allnextpp) {
-		*prev_pp = NULL;
-		np->name = of_get_property(np, "name", NULL);
-		np->type = of_get_property(np, "device_type", NULL);
-
-		if (!np->name)
-			np->name = "<NULL>";
-		if (!np->type)
-			np->type = "<NULL>";
-	}
-	while (tag == OF_DT_BEGIN_NODE) {
-		mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize);
-		tag = *((u32 *)(*p));
-	}
-	if (tag != OF_DT_END_NODE) {
-		printk(KERN_INFO "Weird tag at end of node: %x\n", tag);
-		return mem;
-	}
-	*p += 4;
-	return mem;
-}
-
 /**
  * unflattens the device-tree passed by the firmware, creating the
  * tree of struct device_node. It also fills the "name" and "type"
arch/powerpc/kernel/prom.c +0 -194

200 lines not on this page · raw message

drivers/of/fdt.c +200 -0

203 lines not on this page · raw message

include/linux/of_fdt.h +4 -0
index 81231e0..ace9068 100644
@@ -69,6 +69,10 @@ 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 unsigned long unflatten_dt_node(unsigned long mem, unsigned long *p,
+					struct device_node *dad,
+					struct device_node ***allnextpp,
+					unsigned long fpsize);
 
 /* Other Prototypes */
 extern void finish_device_tree(void);
#12 lore raw

Re: [PATCH 07/11] of/flattree: Merge unflatten_dt_node

Quoted 3 lines · Grant Likely

Merge common code between PowerPC and MicroBlaze

[...]

Quoted 34 lines
drivers/of/fdt.c +26 -0
index 01a7f5f..df1ac8d 100644
@@ -167,3 +167,203 @@ int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)
 	return 0;
 }
 
+static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size,
+				       unsigned long align)
+{
+	void *res;
+
+	*mem = _ALIGN(*mem, align);
+	res = (void *)*mem;
+	*mem += size;
+
+	return res;
+}
+
+/**
+ * unflatten_dt_node - Alloc and populate a device_node from the flat tree
+ * @p: pointer to node in flat tree
+ * @dad: Parent struct device_node
+ * @allnextpp: pointer to ->allnext from last allocated device_node
+ * @fpsize: Size of the node path up at the current depth.
+ */
+unsigned long __init unflatten_dt_node(unsigned long mem,
+					unsigned long *p,
+					struct device_node *dad,
+					struct device_node ***allnextpp,
+					unsigned long fpsize)
+{
+	struct device_node *np;

drivers/of/fdt.c int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) · line 205

Quoted 10 lines
drivers/of/fdt.c +10 -0
+	struct property *pp, **prev_pp = NULL;
+	char *pathp;
+	u32 tag;
+	unsigned int l, allocl;
+	int has_name = 0;
+	int new_format = 0;
+
+	tag = *((u32 *)(*p));
+	if (tag != OF_DT_BEGIN_NODE) {
+		printk("Weird tag at start of node: %x\n", tag);

Loglevel missing -> pr_info?

Quoted 149 lines
drivers/of/fdt.c +149 -0
+		return mem;
+	}
+	*p += 4;
+	pathp = (char *)*p;
+	l = allocl = strlen(pathp) + 1;
+	*p = _ALIGN(*p + l, 4);
+
+	/* version 0x10 has a more compact unit name here instead of the full
+	 * path. we accumulate the full path size using "fpsize", we'll rebuild
+	 * it later. We detect this because the first character of the name is
+	 * not '/'.
+	 */
+	if ((*pathp) != '/') {
+		new_format = 1;
+		if (fpsize == 0) {
+			/* root node: special case. fpsize accounts for path
+			 * plus terminating zero. root node only has '/', so
+			 * fpsize should be 2, but we want to avoid the first
+			 * level nodes to have two '/' so we use fpsize 1 here
+			 */
+			fpsize = 1;
+			allocl = 2;
+		} else {
+			/* account for '/' and path size minus terminal 0
+			 * already in 'l'
+			 */
+			fpsize += l;
+			allocl = fpsize;
+		}
+	}
+
+	np = unflatten_dt_alloc(&mem, sizeof(struct device_node) + allocl,
+				__alignof__(struct device_node));
+	if (allnextpp) {
+		memset(np, 0, sizeof(*np));
+		np->full_name = ((char *)np) + sizeof(struct device_node);
+		if (new_format) {
+			char *fn = np->full_name;
+			/* rebuild full path for new format */
+			if (dad && dad->parent) {
+				strcpy(fn, dad->full_name);
+#ifdef DEBUG
+				if ((strlen(fn) + l + 1) != allocl) {
+					pr_debug("%s: p: %d, l: %d, a: %d\n",
+						pathp, (int)strlen(fn),
+						l, allocl);
+				}
+#endif
+				fn += strlen(fn);
+			}
+			*(fn++) = '/';
+			memcpy(fn, pathp, l);
+		} else
+			memcpy(np->full_name, pathp, l);
+		prev_pp = &np->properties;
+		**allnextpp = np;
+		*allnextpp = &np->allnext;
+		if (dad != NULL) {
+			np->parent = dad;
+			/* we temporarily use the next field as `last_child'*/
+			if (dad->next == NULL)
+				dad->child = np;
+			else
+				dad->next->sibling = np;
+			dad->next = np;
+		}
+		kref_init(&np->kref);
+	}
+	while (1) {
+		u32 sz, noff;
+		char *pname;
+
+		tag = *((u32 *)(*p));
+		if (tag == OF_DT_NOP) {
+			*p += 4;
+			continue;
+		}
+		if (tag != OF_DT_PROP)
+			break;
+		*p += 4;
+		sz = *((u32 *)(*p));
+		noff = *((u32 *)((*p) + 4));
+		*p += 8;
+		if (initial_boot_params->version < 0x10)
+			*p = _ALIGN(*p, sz >= 8 ? 8 : 4);
+
+		pname = find_flat_dt_string(noff);
+		if (pname == NULL) {
+			pr_info("Can't find property name in list !\n");
+			break;
+		}
+		if (strcmp(pname, "name") == 0)
+			has_name = 1;
+		l = strlen(pname) + 1;
+		pp = unflatten_dt_alloc(&mem, sizeof(struct property),
+					__alignof__(struct property));
+		if (allnextpp) {
+			if (strcmp(pname, "linux,phandle") == 0) {
+				np->node = *((u32 *)*p);
+				if (np->linux_phandle == 0)
+					np->linux_phandle = np->node;
+			}
+			if (strcmp(pname, "ibm,phandle") == 0)
+				np->linux_phandle = *((u32 *)*p);
+			pp->name = pname;
+			pp->length = sz;
+			pp->value = (void *)*p;
+			*prev_pp = pp;
+			prev_pp = &pp->next;
+		}
+		*p = _ALIGN((*p) + sz, 4);
+	}
+	/* with version 0x10 we may not have the name property, recreate
+	 * it here from the unit name if absent
+	 */
+	if (!has_name) {
+		char *p1 = pathp, *ps = pathp, *pa = NULL;
+		int sz;
+
+		while (*p1) {
+			if ((*p1) == '@')
+				pa = p1;
+			if ((*p1) == '/')
+				ps = p1 + 1;
+			p1++;
+		}
+		if (pa < ps)
+			pa = p1;
+		sz = (pa - ps) + 1;
+		pp = unflatten_dt_alloc(&mem, sizeof(struct property) + sz,
+					__alignof__(struct property));
+		if (allnextpp) {
+			pp->name = "name";
+			pp->length = sz;
+			pp->value = pp + 1;
+			*prev_pp = pp;
+			prev_pp = &pp->next;
+			memcpy(pp->value, ps, sz - 1);
+			((char *)pp->value)[sz - 1] = 0;
+			pr_debug("fixed up name for %s -> %s\n", pathp,
+				(char *)pp->value);
+		}
+	}
+	if (allnextpp) {
+		*prev_pp = NULL;
+		np->name = of_get_property(np, "name", NULL);
+		np->type = of_get_property(np, "device_type", NULL);
+
+		if (!np->name)

drivers/of/fdt.c int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) · line 364

Quoted 10 lines
drivers/of/fdt.c +10 -0
+			np->name = "<NULL>";
+		if (!np->type)
+			np->type = "<NULL>";
+	}
+	while (tag == OF_DT_BEGIN_NODE) {
+		mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize);
+		tag = *((u32 *)(*p));
+	}
+	if (tag != OF_DT_END_NODE) {
+		printk("Weird tag at end of node: %x\n", tag);

Ditto (microblaze had KERN_INFO, too).

Quoted 25 lines
drivers/of/fdt.c +5 -0
+		return mem;
+	}
+	*p += 4;
+	return mem;
+}
include/linux/of_fdt.h +4 -0
index 81231e0..ace9068 100644
@@ -69,6 +69,10 @@ 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 unsigned long unflatten_dt_node(unsigned long mem, unsigned long *p,
+					struct device_node *dad,
+					struct device_node ***allnextpp,
+					unsigned long fpsize);
 
 /* Other Prototypes */
 extern void finish_device_tree(void);

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

#13 lore raw

PATCH 8/11 of/flattree: Merge unflatten_device_tree

In reply to Grant Likely

Merge common code between PowerPC and MicroBlaze

---

 arch/microblaze/include/asm/prom.h |    1 -
 arch/microblaze/kernel/prom.c      |   49 ----------------------------------
 arch/powerpc/kernel/prom.c         |   50 -----------------------------------
 drivers/of/fdt.c                   |   52 ++++++++++++++++++++++++++++++++++++
 include/linux/of.h                 |    3 ++
 include/linux/of_fdt.h             |    4 ---
 6 files changed, 55 insertions(+), 104 deletions(-)
arch/microblaze/include/asm/prom.h +0 -1
index ef3ec1d..07d1063 100644
@@ -37,7 +37,6 @@ extern struct device_node *of_chosen;
 
 #define HAVE_ARCH_DEVTREE_FIXUPS
 
-extern struct device_node *allnodes;	/* temporary while merging */
 extern rwlock_t devtree_lock;	/* temporary while merging */
 
 /* For updating the device tree at runtime */
arch/microblaze/kernel/prom.c +0 -49

55 lines not on this page · raw message

arch/powerpc/kernel/prom.c +0 -50

62 lines not on this page · raw message

drivers/of/fdt.c +52 -0

61 lines not on this page · raw message

include/linux/of.h +3 -0
index e7facd8..bec2157 100644
@@ -63,6 +63,9 @@ struct device_node {
 #endif
 };
 
+/* Pointer for first entry in chain of all nodes. */
+extern struct device_node *allnodes;
+
 static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
 {
 	return test_bit(flag, &n->_flags);
include/linux/of_fdt.h +0 -4
index ace9068..81231e0 100644
@@ -69,10 +69,6 @@ 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 unsigned long unflatten_dt_node(unsigned long mem, unsigned long *p,
-					struct device_node *dad,
-					struct device_node ***allnextpp,
-					unsigned long fpsize);
 
 /* Other Prototypes */
 extern void finish_device_tree(void);
#14 lore raw

PATCH 9/11 of: merge prom_{add,remove,modify}_property

In reply to Grant Likely

Merge common code between PowerPC and MicroBlaze

---

 arch/microblaze/kernel/prom.c |  113 ----------------------------------------
 arch/powerpc/kernel/prom.c    |  114 ----------------------------------------
 drivers/of/base.c             |  116 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 116 insertions(+), 227 deletions(-)
arch/microblaze/kernel/prom.c +0 -113
index 901d538..a38e373 100644
@@ -606,119 +606,6 @@ out_unlock:
 	write_unlock_irqrestore(&devtree_lock, flags);
 }
 
-/*
- * Add a property to a node
- */
-int prom_add_property(struct device_node *np, struct property *prop)
-{
-	struct property **next;
-	unsigned long flags;
-
-	prop->next = NULL;
-	write_lock_irqsave(&devtree_lock, flags);
-	next = &np->properties;
-	while (*next) {
-		if (strcmp(prop->name, (*next)->name) == 0) {
-			/* duplicate ! don't insert it */
-			write_unlock_irqrestore(&devtree_lock, flags);
-			return -1;
-		}
-		next = &(*next)->next;
-	}
-	*next = prop;
-	write_unlock_irqrestore(&devtree_lock, flags);
-
-#ifdef CONFIG_PROC_DEVICETREE
-	/* try to add to proc as well if it was initialized */
-	if (np->pde)
-		proc_device_tree_add_prop(np->pde, prop);
-#endif /* CONFIG_PROC_DEVICETREE */
-
-	return 0;
-}
-
-/*
- * Remove a property from a node.  Note that we don't actually
- * remove it, since we have given out who-knows-how-many pointers
- * to the data using get-property.  Instead we just move the property
- * to the "dead properties" list, so it won't be found any more.
- */
-int prom_remove_property(struct device_node *np, struct property *prop)
-{
-	struct property **next;
-	unsigned long flags;
-	int found = 0;
-
-	write_lock_irqsave(&devtree_lock, flags);
-	next = &np->properties;
-	while (*next) {
-		if (*next == prop) {
-			/* found the node */
-			*next = prop->next;
-			prop->next = np->deadprops;
-			np->deadprops = prop;
-			found = 1;
-			break;
-		}
-		next = &(*next)->next;
-	}
-	write_unlock_irqrestore(&devtree_lock, flags);
-
-	if (!found)
-		return -ENODEV;
-
-#ifdef CONFIG_PROC_DEVICETREE
-	/* try to remove the proc node as well */
-	if (np->pde)
-		proc_device_tree_remove_prop(np->pde, prop);
-#endif /* CONFIG_PROC_DEVICETREE */
-
-	return 0;
-}
-
-/*
- * Update a property in a node.  Note that we don't actually
- * remove it, since we have given out who-knows-how-many pointers
- * to the data using get-property.  Instead we just move the property
- * to the "dead properties" list, and add the new property to the
- * property list
- */
-int prom_update_property(struct device_node *np,
-			 struct property *newprop,
-			 struct property *oldprop)
-{
-	struct property **next;
-	unsigned long flags;
-	int found = 0;
-
-	write_lock_irqsave(&devtree_lock, flags);
-	next = &np->properties;
-	while (*next) {
-		if (*next == oldprop) {
-			/* found the node */
-			newprop->next = oldprop->next;
-			*next = newprop;
-			oldprop->next = np->deadprops;
-			np->deadprops = oldprop;
-			found = 1;
-			break;
-		}
-		next = &(*next)->next;
-	}
-	write_unlock_irqrestore(&devtree_lock, flags);
-
-	if (!found)
-		return -ENODEV;
-
-#ifdef CONFIG_PROC_DEVICETREE
-	/* try to add to proc as well if it was initialized */
-	if (np->pde)
-		proc_device_tree_update_prop(np->pde, newprop, oldprop);
-#endif /* CONFIG_PROC_DEVICETREE */
-
-	return 0;
-}
-
 #if defined(CONFIG_DEBUG_FS) && defined(DEBUG)
 static struct debugfs_blob_wrapper flat_dt_blob;
 
arch/powerpc/kernel/prom.c +0 -114

120 lines not on this page · raw message

drivers/of/base.c +116 -0

119 lines not on this page · raw message

#15 lore raw

Re: [PATCH 09/11] of: merge prom_{add,remove,modify}_property

Quoted 10 lines · Grant Likely

Merge common code between PowerPC and MicroBlaze

---

 arch/microblaze/kernel/prom.c |  113 ----------------------------------------
 arch/powerpc/kernel/prom.c    |  114 ----------------------------------------
 drivers/of/base.c             |  116 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 116 insertions(+), 227 deletions(-)

Should the prom_{add,remove,update}_property routines belong in base.c or of_dynamic.c (patches coming soon for of_dynamic.c)?

My original patch set put these routines in of_dynamic.c and renamed them to of_{add,remove,update}_property since they are part of the of code.

-Nathan Fontenot

#16 lore raw

Re: [PATCH 09/11] of: merge prom_{add,remove,modify}_property

Quoted 16 lines · Nathan Fontenot
Quoted 6 lines · Grant Likely

Merge common code between PowerPC and MicroBlaze

---

Quoted 8 lines

 arch/microblaze/kernel/prom.c |  113
----------------------------------------
 arch/powerpc/kernel/prom.c    |  114
----------------------------------------
 drivers/of/base.c             |  116
+++++++++++++++++++++++++++++++++++++++++

 3 files changed, 116 insertions(+), 227 deletions(-)
Quoted 5 lines

Should the prom_{add,remove,update}_property routines belong in base.c or of_dynamic.c (patches coming soon for of_dynamic.c)?
My original patch set put these routines in of_dynamic.c and renamed them to of_{add,remove,update}_property since they are part of the of code.

First stage for me is to go through the rather mechanical process of merging common code. As much as possible I'm not changing any APIs, and I don't have enough background on the of_dynamic stuff to make a call about where it should ultimately live. The goal of the first stage is simply to eliminate duplicated code. Rename of functions to of_ is potentially risky, so I'm deferring those changes until after all the code is merged.

Feel free to make changes on top of what I'm doing. Keep each one small to reduce the risk of conflict. I'll pick up the ones that make sense.

Cheers,
g.

Signature · 6 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#17 lore raw

PATCH 10/11 of: remove special case definition of of_read_ulong()

In reply to Grant Likely

Special case of of_read_ulong() was defined for PPC32 to toss away all but the last 32 bits when a large number value was read, and the 'normal' version for ppc64 just #defined of_read_ulong to of_read_number which causes compiler warnings on MicroBlaze and other 32 bit architectures because it returns a u64 instead of a ulong.

This patch fixes the problem by defining a common implementation of of_read_ulong() that works everywhere.

---

 include/linux/of.h |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
include/linux/of.h +2 -5
index bec2157..d4c014a 100644
@@ -113,14 +113,11 @@ static inline u64 of_read_number(const u32 *cell, int size)
 }
 
 /* Like of_read_number, but we want an unsigned long result */
-#ifdef CONFIG_PPC32
 static inline unsigned long of_read_ulong(const u32 *cell, int size)
 {
-	return cell[size-1];
+	/* toss away upper bits if unsigned long is smaller than u64 */
+	return of_read_number(cell, size);
 }
-#else
-#define of_read_ulong(cell, size)	of_read_number(cell, size)
-#endif
 
 #include <asm/prom.h>
 
#18 lore raw

PATCH 11/11 of/flattree: Merge early_init_dt_check_for_initrd()

In reply to Grant Likely

Merge common code between PowerPC and Microblaze

---

 arch/microblaze/kernel/prom.c |   32 --------------------------------
 arch/powerpc/kernel/prom.c    |   30 ------------------------------
 drivers/of/fdt.c              |   37 +++++++++++++++++++++++++++++++++++++
 include/linux/of_fdt.h        |    1 +
 4 files changed, 38 insertions(+), 62 deletions(-)
arch/microblaze/kernel/prom.c +0 -32
index a38e373..7959495 100644
@@ -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)
 {
arch/powerpc/kernel/prom.c +0 -30
index 7f88566..1ecd6c6 100644
@@ -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)
 {
drivers/of/fdt.c +37 -0
index ad3a2b6..3c58f10 100644
@@ -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>
 
@@ -370,6 +371,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
  *
include/linux/of_fdt.h +1 -0
index 81231e0..ec2db82 100644
@@ -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);
Reviewed-by on the v1 series
#19 lore raw
In reply to Grant Likely
Quoted 2 lines · Grant Likely

I've also pushed this series out to the test-devicetree branch on my git server if anyone cares to pull and test:

I did :) Works fine on my phyCORE-IO (MPC5200B). If you pick up my comments:

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

Tested-by on the v1 series
#20 lore raw
In reply to Grant Likely

Hi Grant,

Quoted 3 lines · Grant Likely

Round 2. Here is my 2nd set of merging OF code between PowerPC and Microblaze (no SPARC changes this time). Compile tested on ppc, microblaze and sparc. Boot tested on MPC5200 powerpc platform.

I tested your test-device-tree branch - boot tested on ml505 for MMU and noMMU kernels.
I expect that you will add these patches to next branch. I test it every day - if is any problem with Microblaze, I will let you know.

Thanks for this work,
Michal

Quoted 48 lines

I've also pushed this series out to the test-devicetree branch on my git server if anyone cares to pull and test:

git://git.secretlab.ca/git/linux-2.6 test-devicetree

This is based on the next-devicetree branch which contains the first round of patches and is being pulled into linux-next.

Cheers,
g.

---

Grant Likely (11):
of/flattree: Merge early_init_dt_check_for_initrd()
of: remove special case definition of of_read_ulong()
of: merge prom_{add,remove,modify}_property of/flattree: Merge unflatten_device_tree of/flattree: Merge unflatten_dt_node
of/flattree: Merge of_flat_dt_is_compatible of/flattree: merge of_get_flat_dt_prop
of/flattree: remove __init annotations from the header file of/flattree: merge of_get_flat_dt_root
of/flattree: merge of_scan_flat_dt
of/flattree: merge find_flat_dt_string and initial_boot_params

 arch/microblaze/Kconfig            |    1 
 arch/microblaze/include/asm/prom.h |    1 
 arch/microblaze/kernel/prom.c      |  531 ------------------------------------
 arch/powerpc/Kconfig               |    1 
 arch/powerpc/kernel/prom.c         |  534 ------------------------------------
 drivers/of/Kconfig                 |    4 
 drivers/of/Makefile                |    1 
 drivers/of/base.c                  |  116 ++++++++
 drivers/of/fdt.c                   |  458 +++++++++++++++++++++++++++++++
 include/linux/of.h                 |   10 -
 include/linux/of_fdt.h             |   21 +
 11 files changed, 598 insertions(+), 1080 deletions(-)
 create mode 100644 drivers/of/fdt.c

___________________________
microblaze-uclinux mailing list
[email protected]
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/

Signature · 3 lines
Michal Simek, Ing. (M.Eng)
PetaLogix - Linux Solutions for a Reconfigurable World
w: www.petalogix.com p: +61-7-30090663,+42-0-721842854 f: +61-7-30090663