Skip to contentSkip to conversation

Make the kernel accept ePAPR style phandle information

PATCH RESEND Applied David Gibson 3 participants 3 messages Feb 1, 2010 Device tree

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 Make the kernel accept ePAPR style phandle information

Grant, I've updated this for your current test-devicetree branch. Please apply.

Currently when processing flattened device trees, the kernel expects the phandle in a property called "linux,phandle". The ePAPR spec - not being Linux specific - instead requires phandles to be encoded in a property named simply "phandle". This patch makes the kernel accept either form when unflattening the device tree.

drivers/of/fdt.c +10 -1
Index: working-2.6/drivers/of/fdt.c
===================================================================
@@ -310,10 +310,19 @@ unsigned long __init unflatten_dt_node(u
 		pp = unflatten_dt_alloc(&mem, sizeof(struct property),
 					__alignof__(struct property));
 		if (allnextpp) {
-			if (strcmp(pname, "linux,phandle") == 0) {
+			/* We accept flattened tree phandles either in
+			 * ePAPR-style "phandle" properties, or the
+			 * legacy "linux,phandle" properties.  If both
+			 * appear and have different values, things
+			 * will get weird.  Don't do that. */
+			if ((strcmp(pname, "phandle") == 0)
+			    || (strcmp(pname, "linux,phandle") == 0)) {
 				if (np->phandle == 0)
 					np->phandle = *((u32 *)*p);
 			}
+			/* And we process the "ibm,phandle" property
+			 * used in pSeries dynamic device tree
+			 * stuff */
 			if (strcmp(pname, "ibm,phandle") == 0)
 				np->phandle = *((u32 *)*p);
 			pp->name = pname;
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#1 lore raw
Quoted 16 lines · David Gibson

Grant, I've updated this for your current test-devicetree branch. Please apply.

Currently when processing flattened device trees, the kernel expects the phandle in a property called "linux,phandle". The ePAPR spec - not being Linux specific - instead requires phandles to be encoded in a property named simply "phandle". This patch makes the kernel accept either form when unflattening the device tree.

Index: working-2.6/drivers/of/fdt.c
===================================================================

drivers/of/fdt.c unsigned long __init unflatten_dt_node(u · line 317

Quoted 9 lines
drivers/of/fdt.c +5 -1
@@ -310,10 +310,19 @@ unsigned long __init unflatten_dt_node(u
 		pp = unflatten_dt_alloc(&mem, sizeof(struct property),
 					__alignof__(struct property));
 		if (allnextpp) {
-			if (strcmp(pname, "linux,phandle") == 0) {
+			/* We accept flattened tree phandles either in
+			 * ePAPR-style "phandle" properties, or the
+			 * legacy "linux,phandle" properties.  If both
+			 * appear and have different values, things
+			 * will get weird.  Don't do that. */

I don't want to be just pedantic, I really think the preferred way of multi-line comments

/*
* foo
* bar
*/

will help readability a lot here.

Quoted 21 lines
drivers/of/fdt.c +5 -0
+			if ((strcmp(pname, "phandle") == 0)
+			    || (strcmp(pname, "linux,phandle") == 0)) {
 				if (np->phandle == 0)
 					np->phandle = *((u32 *)*p);
 			}
+			/* And we process the "ibm,phandle" property
+			 * used in pSeries dynamic device tree
+			 * stuff */
 			if (strcmp(pname, "ibm,phandle") == 0)
 				np->phandle = *((u32 *)*p);
 			pp->name = pname;
Signature · 9 lines
-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
_______________________________________________
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

Applied
#2 lore raw
In reply to David Gibson
Quoted 10 lines · David Gibson

Grant, I've updated this for your current test-devicetree branch. Please apply.

Currently when processing flattened device trees, the kernel expects the phandle in a property called "linux,phandle".  The ePAPR spec - not being Linux specific - instead requires phandles to be encoded in a property named simply "phandle".  This patch makes the kernel accept either form when unflattening the device tree.

Applied, thanks.

g.