linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [resend] Make the kernel accept ePAPR style phandle information
@ 2010-02-01  4:52 David Gibson
  2010-02-01 10:00 ` Wolfram Sang
  2010-02-01 21:20 ` Grant Likely
  0 siblings, 2 replies; 3+ messages in thread
From: David Gibson @ 2010-02-01  4:52 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev, devicetree-discuss

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.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

Index: working-2.6/drivers/of/fdt.c
===================================================================
--- working-2.6.orig/drivers/of/fdt.c	2010-02-01 15:51:44.000000000 +1100
+++ working-2.6/drivers/of/fdt.c	2010-02-01 15:51:46.458557615 +1100
@@ -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;

-- 
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [resend] Make the kernel accept ePAPR style phandle information
  2010-02-01  4:52 [resend] Make the kernel accept ePAPR style phandle information David Gibson
@ 2010-02-01 10:00 ` Wolfram Sang
  2010-02-01 21:20 ` Grant Likely
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2010-02-01 10:00 UTC (permalink / raw)
  To: Grant Likely, linuxppc-dev, devicetree-discuss

[-- Attachment #1: Type: text/plain, Size: 2410 bytes --]

On Mon, Feb 01, 2010 at 03:52:42PM +1100, David Gibson wrote:
> 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.
> 
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> 
> Index: working-2.6/drivers/of/fdt.c
> ===================================================================
> --- working-2.6.orig/drivers/of/fdt.c	2010-02-01 15:51:44.000000000 +1100
> +++ working-2.6/drivers/of/fdt.c	2010-02-01 15:51:46.458557615 +1100
> @@ -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.


> +			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;
> 
> -- 
> 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
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [resend] Make the kernel accept ePAPR style phandle information
  2010-02-01  4:52 [resend] Make the kernel accept ePAPR style phandle information David Gibson
  2010-02-01 10:00 ` Wolfram Sang
@ 2010-02-01 21:20 ` Grant Likely
  1 sibling, 0 replies; 3+ messages in thread
From: Grant Likely @ 2010-02-01 21:20 UTC (permalink / raw)
  To: Grant Likely, linuxppc-dev, devicetree-discuss

On Sun, Jan 31, 2010 at 9:52 PM, David Gibson
<david@gibson.dropbear.id.au> wrote:
> 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". =A0The ePAPR spec -
> not being Linux specific - instead requires phandles to be encoded in
> a property named simply "phandle". =A0This patch makes the kernel accept
> either form when unflattening the device tree.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

Applied, thanks.

g.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-02-01 21:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-01  4:52 [resend] Make the kernel accept ePAPR style phandle information David Gibson
2010-02-01 10:00 ` Wolfram Sang
2010-02-01 21:20 ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).