devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] of/flattree: Use common ALIGN() macro instead of arch specific _ALIGN
@ 2010-07-14 23:31 Grant Likely
  2010-07-14 23:31 ` [PATCH 2/3] of/flattree: Fix crash when device tree absent Grant Likely
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Grant Likely @ 2010-07-14 23:31 UTC (permalink / raw)
  To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
  Cc: jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw

There's no reason to use the powerpc-specific _ALIGN macro in the fdt
code.  Replace it with ALIGN() from kernel.h

Signed-off-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
---
 arch/microblaze/include/asm/page.h |    7 -------
 drivers/of/fdt.c                   |   20 ++++++++++----------
 2 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/arch/microblaze/include/asm/page.h b/arch/microblaze/include/asm/page.h
index 464ff32..2fd4761 100644
--- a/arch/microblaze/include/asm/page.h
+++ b/arch/microblaze/include/asm/page.h
@@ -39,13 +39,6 @@
 #define PAGE_UP(addr)	(((addr)+((PAGE_SIZE)-1))&(~((PAGE_SIZE)-1)))
 #define PAGE_DOWN(addr)	((addr)&(~((PAGE_SIZE)-1)))
 
-/* align addr on a size boundary - adjust address up/down if needed */
-#define _ALIGN_UP(addr, size)	(((addr)+((size)-1))&(~((size)-1)))
-#define _ALIGN_DOWN(addr, size)	((addr)&(~((size)-1)))
-
-/* align addr on a size boundary - adjust address up if needed */
-#define _ALIGN(addr, size)	_ALIGN_UP(addr, size)
-
 #ifndef CONFIG_MMU
 /*
  * PAGE_OFFSET -- the first address of the first page of memory. When not
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index b6987bb..d61fda8 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -69,9 +69,9 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
 			u32 sz = be32_to_cpup((__be32 *)p);
 			p += 8;
 			if (be32_to_cpu(initial_boot_params->version) < 0x10)
-				p = _ALIGN(p, sz >= 8 ? 8 : 4);
+				p = ALIGN(p, sz >= 8 ? 8 : 4);
 			p += sz;
-			p = _ALIGN(p, 4);
+			p = ALIGN(p, 4);
 			continue;
 		}
 		if (tag != OF_DT_BEGIN_NODE) {
@@ -80,7 +80,7 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
 		}
 		depth++;
 		pathp = (char *)p;
-		p = _ALIGN(p + strlen(pathp) + 1, 4);
+		p = ALIGN(p + strlen(pathp) + 1, 4);
 		if ((*pathp) == '/') {
 			char *lp, *np;
 			for (lp = NULL, np = pathp; *np; np++)
@@ -109,7 +109,7 @@ unsigned long __init of_get_flat_dt_root(void)
 		p += 4;
 	BUG_ON(be32_to_cpup((__be32 *)p) != OF_DT_BEGIN_NODE);
 	p += 4;
-	return _ALIGN(p + strlen((char *)p) + 1, 4);
+	return ALIGN(p + strlen((char *)p) + 1, 4);
 }
 
 /**
@@ -138,7 +138,7 @@ void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
 		noff = be32_to_cpup((__be32 *)(p + 4));
 		p += 8;
 		if (be32_to_cpu(initial_boot_params->version) < 0x10)
-			p = _ALIGN(p, sz >= 8 ? 8 : 4);
+			p = ALIGN(p, sz >= 8 ? 8 : 4);
 
 		nstr = find_flat_dt_string(noff);
 		if (nstr == NULL) {
@@ -151,7 +151,7 @@ void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
 			return (void *)p;
 		}
 		p += sz;
-		p = _ALIGN(p, 4);
+		p = ALIGN(p, 4);
 	} while (1);
 }
 
@@ -184,7 +184,7 @@ static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size,
 {
 	void *res;
 
-	*mem = _ALIGN(*mem, align);
+	*mem = ALIGN(*mem, align);
 	res = (void *)*mem;
 	*mem += size;
 
@@ -220,7 +220,7 @@ unsigned long __init unflatten_dt_node(unsigned long mem,
 	*p += 4;
 	pathp = (char *)*p;
 	l = allocl = strlen(pathp) + 1;
-	*p = _ALIGN(*p + l, 4);
+	*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
@@ -299,7 +299,7 @@ unsigned long __init unflatten_dt_node(unsigned long mem,
 		noff = be32_to_cpup((__be32 *)((*p) + 4));
 		*p += 8;
 		if (be32_to_cpu(initial_boot_params->version) < 0x10)
-			*p = _ALIGN(*p, sz >= 8 ? 8 : 4);
+			*p = ALIGN(*p, sz >= 8 ? 8 : 4);
 
 		pname = find_flat_dt_string(noff);
 		if (pname == NULL) {
@@ -333,7 +333,7 @@ unsigned long __init unflatten_dt_node(unsigned long mem,
 			*prev_pp = pp;
 			prev_pp = &pp->next;
 		}
-		*p = _ALIGN((*p) + sz, 4);
+		*p = ALIGN((*p) + sz, 4);
 	}
 	/* with version 0x10 we may not have the name property, recreate
 	 * it here from the unit name if absent

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

* [PATCH 2/3] of/flattree: Fix crash when device tree absent
  2010-07-14 23:31 [PATCH 1/3] of/flattree: Use common ALIGN() macro instead of arch specific _ALIGN Grant Likely
@ 2010-07-14 23:31 ` Grant Likely
  2010-07-15  1:11   ` Jeremy Kerr
  2010-07-19  0:04   ` Benjamin Herrenschmidt
  2010-07-14 23:31 ` [PATCH 3/3] of: Remove unused of_find_device_by_phandle() Grant Likely
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 11+ messages in thread
From: Grant Likely @ 2010-07-14 23:31 UTC (permalink / raw)
  To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
  Cc: jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw

This patch fixes the condition where device tree support is compiled
in, but no device tree was proved by firmware.  It makes
of_platform_bus_probe() explicitly check for a NULL device tree
pointer, and adds an error message if the device tree was unable
to be flattened.

Signed-off-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
---
 drivers/of/fdt.c      |    2 ++
 drivers/of/platform.c |    2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index d61fda8..66401bc 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -94,6 +94,8 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
 			break;
 	} while (1);
 
+	if (rc)
+		pr_err("Failed to unflatten device tree blob.  rc=%i\n", rc);
 	return rc;
 }
 
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index f0ca906..9bc6999 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -674,6 +674,8 @@ int of_platform_bus_probe(struct device_node *root,
 		root = of_find_node_by_path("/");
 	else
 		of_node_get(root);
+	if (root == NULL)
+		return -EINVAL;
 
 	pr_debug("of_platform_bus_probe()\n");
 	pr_debug(" starting at: %s\n", root->full_name);

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

* [PATCH 3/3] of: Remove unused of_find_device_by_phandle()
  2010-07-14 23:31 [PATCH 1/3] of/flattree: Use common ALIGN() macro instead of arch specific _ALIGN Grant Likely
  2010-07-14 23:31 ` [PATCH 2/3] of/flattree: Fix crash when device tree absent Grant Likely
@ 2010-07-14 23:31 ` Grant Likely
  2010-07-19  0:06   ` Benjamin Herrenschmidt
  2010-07-15  1:12 ` [PATCH 1/3] of/flattree: Use common ALIGN() macro instead of arch specific _ALIGN Jeremy Kerr
  2010-07-19  0:03 ` Benjamin Herrenschmidt
  3 siblings, 1 reply; 11+ messages in thread
From: Grant Likely @ 2010-07-14 23:31 UTC (permalink / raw)
  To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
  Cc: jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw

Signed-off-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
---
 arch/microblaze/include/asm/of_platform.h |    2 --
 arch/microblaze/kernel/of_platform.c      |   18 ------------------
 arch/powerpc/include/asm/of_platform.h    |    2 --
 arch/powerpc/kernel/of_platform.c         |   19 -------------------
 4 files changed, 0 insertions(+), 41 deletions(-)

diff --git a/arch/microblaze/include/asm/of_platform.h b/arch/microblaze/include/asm/of_platform.h
index 625003f..353d8f6 100644
--- a/arch/microblaze/include/asm/of_platform.h
+++ b/arch/microblaze/include/asm/of_platform.h
@@ -14,8 +14,6 @@
 /* This is just here during the transition */
 #include <linux/of_platform.h>
 
-extern struct of_device *of_find_device_by_phandle(phandle ph);
-
 extern void of_instantiate_rtc(void);
 
 #endif /* _ASM_MICROBLAZE_OF_PLATFORM_H */
diff --git a/arch/microblaze/kernel/of_platform.c b/arch/microblaze/kernel/of_platform.c
index 33212bb..80c9c49 100644
--- a/arch/microblaze/kernel/of_platform.c
+++ b/arch/microblaze/kernel/of_platform.c
@@ -63,21 +63,3 @@ struct of_device *of_find_device_by_node(struct device_node *np)
 	return NULL;
 }
 EXPORT_SYMBOL(of_find_device_by_node);
-
-static int of_dev_phandle_match(struct device *dev, void *data)
-{
-	phandle *ph = data;
-	return to_of_device(dev)->dev.of_node->phandle == *ph;
-}
-
-struct of_device *of_find_device_by_phandle(phandle ph)
-{
-	struct device *dev;
-
-	dev = bus_find_device(&platform_bus_type,
-			      NULL, &ph, of_dev_phandle_match);
-	if (dev)
-		return to_of_device(dev);
-	return NULL;
-}
-EXPORT_SYMBOL(of_find_device_by_phandle);
diff --git a/arch/powerpc/include/asm/of_platform.h b/arch/powerpc/include/asm/of_platform.h
index b37d2dc..d506aa6 100644
--- a/arch/powerpc/include/asm/of_platform.h
+++ b/arch/powerpc/include/asm/of_platform.h
@@ -11,8 +11,6 @@
  *
  */
 
-extern struct of_device *of_find_device_by_phandle(phandle ph);
-
 extern void of_instantiate_rtc(void);
 
 #endif	/* _ASM_POWERPC_OF_PLATFORM_H */
diff --git a/arch/powerpc/kernel/of_platform.c b/arch/powerpc/kernel/of_platform.c
index a3d7154..b093d4b 100644
--- a/arch/powerpc/kernel/of_platform.c
+++ b/arch/powerpc/kernel/of_platform.c
@@ -68,25 +68,6 @@ struct of_device *of_find_device_by_node(struct device_node *np)
 }
 EXPORT_SYMBOL(of_find_device_by_node);
 
-static int of_dev_phandle_match(struct device *dev, void *data)
-{
-	phandle *ph = data;
-	return to_of_device(dev)->dev.of_node->phandle == *ph;
-}
-
-struct of_device *of_find_device_by_phandle(phandle ph)
-{
-	struct device *dev;
-
-	dev = bus_find_device(&platform_bus_type,
-			      NULL, &ph, of_dev_phandle_match);
-	if (dev)
-		return to_of_device(dev);
-	return NULL;
-}
-EXPORT_SYMBOL(of_find_device_by_phandle);
-
-
 #ifdef CONFIG_PPC_OF_PLATFORM_PCI
 
 /* The probing of PCI controllers from of_platform is currently

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

* Re: [PATCH 2/3] of/flattree: Fix crash when device tree absent
  2010-07-14 23:31 ` [PATCH 2/3] of/flattree: Fix crash when device tree absent Grant Likely
@ 2010-07-15  1:11   ` Jeremy Kerr
       [not found]     ` <1279156262.15089.68.camel-353AF/3W9ll+urZeOPWqwQ@public.gmane.org>
  2010-07-19  0:04   ` Benjamin Herrenschmidt
  1 sibling, 1 reply; 11+ messages in thread
From: Jeremy Kerr @ 2010-07-15  1:11 UTC (permalink / raw)
  To: Grant Likely; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

Hi Grant,

> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index d61fda8..66401bc 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -94,6 +94,8 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
>  			break;
>  	} while (1);
>  
> +	if (rc)
> +		pr_err("Failed to unflatten device tree blob.  rc=%i\n", rc);
>  	return rc;
>  }

rc == 1 is perfectly valid - it indicates that the iterator callback
stopped the scan early.

How about we just check for the presence of OF_DT_HEADER instead?

Cheers,

Jeremy

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

* Re: [PATCH 1/3] of/flattree: Use common ALIGN() macro instead of arch specific _ALIGN
  2010-07-14 23:31 [PATCH 1/3] of/flattree: Use common ALIGN() macro instead of arch specific _ALIGN Grant Likely
  2010-07-14 23:31 ` [PATCH 2/3] of/flattree: Fix crash when device tree absent Grant Likely
  2010-07-14 23:31 ` [PATCH 3/3] of: Remove unused of_find_device_by_phandle() Grant Likely
@ 2010-07-15  1:12 ` Jeremy Kerr
  2010-07-19  0:03 ` Benjamin Herrenschmidt
  3 siblings, 0 replies; 11+ messages in thread
From: Jeremy Kerr @ 2010-07-15  1:12 UTC (permalink / raw)
  To: Grant Likely; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

Hi Grant,

> There's no reason to use the powerpc-specific _ALIGN macro in the fdt
> code.  Replace it with ALIGN() from kernel.h
> 

Been using this for a while, looks good.

Acked-By: Jeremy Kerr <jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>

Cheers,


Jeremy

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

* Re: [PATCH 2/3] of/flattree: Fix crash when device tree absent
       [not found]     ` <1279156262.15089.68.camel-353AF/3W9ll+urZeOPWqwQ@public.gmane.org>
@ 2010-07-15  6:15       ` Grant Likely
       [not found]         ` <AANLkTikD3ZhhVg4PTuG5Zkc38oW1I6yaQyKqcv9rAaoR-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: Grant Likely @ 2010-07-15  6:15 UTC (permalink / raw)
  To: Jeremy Kerr; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

On Wed, Jul 14, 2010 at 7:11 PM, Jeremy Kerr <jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org> wrote:
> Hi Grant,
>
>> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
>> index d61fda8..66401bc 100644
>> --- a/drivers/of/fdt.c
>> +++ b/drivers/of/fdt.c
>> @@ -94,6 +94,8 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
>>                       break;
>>       } while (1);
>>
>> +     if (rc)
>> +             pr_err("Failed to unflatten device tree blob.  rc=%i\n", rc);
>>       return rc;
>>  }
>
> rc == 1 is perfectly valid - it indicates that the iterator callback
> stopped the scan early.

This was just an informational output anyway.  I'll just drop this hunk.

> How about we just check for the presence of OF_DT_HEADER instead?

Probably a good idea.  We'll need more robust dtb pointer checking
with ARM.  I'll do that in a separate patch.

g.

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

* Re: [PATCH 2/3] of/flattree: Fix crash when device tree absent
       [not found]         ` <AANLkTikD3ZhhVg4PTuG5Zkc38oW1I6yaQyKqcv9rAaoR-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2010-07-15  7:26           ` Jeremy Kerr
  0 siblings, 0 replies; 11+ messages in thread
From: Jeremy Kerr @ 2010-07-15  7:26 UTC (permalink / raw)
  To: Grant Likely; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

Hi Grant,

> Probably a good idea.  We'll need more robust dtb pointer checking
> with ARM.  I'll do that in a separate patch.

I do some checking in the boot path already, so we're safe from getting
inital_boot_params set to something bogus anyway.

http://kernel.ubuntu.com/git?p=jk/dt/linux-2.6.git;a=commitdiff;h=c973251ad8d36f777b1c4c8e2cb99d37bf577cf0#patch2

Cheers,


Jeremy

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

* Re: [PATCH 1/3] of/flattree: Use common ALIGN() macro instead of arch specific _ALIGN
  2010-07-14 23:31 [PATCH 1/3] of/flattree: Use common ALIGN() macro instead of arch specific _ALIGN Grant Likely
                   ` (2 preceding siblings ...)
  2010-07-15  1:12 ` [PATCH 1/3] of/flattree: Use common ALIGN() macro instead of arch specific _ALIGN Jeremy Kerr
@ 2010-07-19  0:03 ` Benjamin Herrenschmidt
  3 siblings, 0 replies; 11+ messages in thread
From: Benjamin Herrenschmidt @ 2010-07-19  0:03 UTC (permalink / raw)
  To: Grant Likely
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw

On Wed, 2010-07-14 at 17:31 -0600, Grant Likely wrote:
> There's no reason to use the powerpc-specific _ALIGN macro in the fdt
> code.  Replace it with ALIGN() from kernel.h
> 
> Signed-off-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>

Acked-by: Benjamin Herrenschmidt <benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>

> ---
>  arch/microblaze/include/asm/page.h |    7 -------
>  drivers/of/fdt.c                   |   20 ++++++++++----------
>  2 files changed, 10 insertions(+), 17 deletions(-)
> 
> diff --git a/arch/microblaze/include/asm/page.h b/arch/microblaze/include/asm/page.h
> index 464ff32..2fd4761 100644
> --- a/arch/microblaze/include/asm/page.h
> +++ b/arch/microblaze/include/asm/page.h
> @@ -39,13 +39,6 @@
>  #define PAGE_UP(addr)	(((addr)+((PAGE_SIZE)-1))&(~((PAGE_SIZE)-1)))
>  #define PAGE_DOWN(addr)	((addr)&(~((PAGE_SIZE)-1)))
>  
> -/* align addr on a size boundary - adjust address up/down if needed */
> -#define _ALIGN_UP(addr, size)	(((addr)+((size)-1))&(~((size)-1)))
> -#define _ALIGN_DOWN(addr, size)	((addr)&(~((size)-1)))
> -
> -/* align addr on a size boundary - adjust address up if needed */
> -#define _ALIGN(addr, size)	_ALIGN_UP(addr, size)
> -
>  #ifndef CONFIG_MMU
>  /*
>   * PAGE_OFFSET -- the first address of the first page of memory. When not
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index b6987bb..d61fda8 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -69,9 +69,9 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
>  			u32 sz = be32_to_cpup((__be32 *)p);
>  			p += 8;
>  			if (be32_to_cpu(initial_boot_params->version) < 0x10)
> -				p = _ALIGN(p, sz >= 8 ? 8 : 4);
> +				p = ALIGN(p, sz >= 8 ? 8 : 4);
>  			p += sz;
> -			p = _ALIGN(p, 4);
> +			p = ALIGN(p, 4);
>  			continue;
>  		}
>  		if (tag != OF_DT_BEGIN_NODE) {
> @@ -80,7 +80,7 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
>  		}
>  		depth++;
>  		pathp = (char *)p;
> -		p = _ALIGN(p + strlen(pathp) + 1, 4);
> +		p = ALIGN(p + strlen(pathp) + 1, 4);
>  		if ((*pathp) == '/') {
>  			char *lp, *np;
>  			for (lp = NULL, np = pathp; *np; np++)
> @@ -109,7 +109,7 @@ unsigned long __init of_get_flat_dt_root(void)
>  		p += 4;
>  	BUG_ON(be32_to_cpup((__be32 *)p) != OF_DT_BEGIN_NODE);
>  	p += 4;
> -	return _ALIGN(p + strlen((char *)p) + 1, 4);
> +	return ALIGN(p + strlen((char *)p) + 1, 4);
>  }
>  
>  /**
> @@ -138,7 +138,7 @@ void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
>  		noff = be32_to_cpup((__be32 *)(p + 4));
>  		p += 8;
>  		if (be32_to_cpu(initial_boot_params->version) < 0x10)
> -			p = _ALIGN(p, sz >= 8 ? 8 : 4);
> +			p = ALIGN(p, sz >= 8 ? 8 : 4);
>  
>  		nstr = find_flat_dt_string(noff);
>  		if (nstr == NULL) {
> @@ -151,7 +151,7 @@ void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
>  			return (void *)p;
>  		}
>  		p += sz;
> -		p = _ALIGN(p, 4);
> +		p = ALIGN(p, 4);
>  	} while (1);
>  }
>  
> @@ -184,7 +184,7 @@ static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size,
>  {
>  	void *res;
>  
> -	*mem = _ALIGN(*mem, align);
> +	*mem = ALIGN(*mem, align);
>  	res = (void *)*mem;
>  	*mem += size;
>  
> @@ -220,7 +220,7 @@ unsigned long __init unflatten_dt_node(unsigned long mem,
>  	*p += 4;
>  	pathp = (char *)*p;
>  	l = allocl = strlen(pathp) + 1;
> -	*p = _ALIGN(*p + l, 4);
> +	*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
> @@ -299,7 +299,7 @@ unsigned long __init unflatten_dt_node(unsigned long mem,
>  		noff = be32_to_cpup((__be32 *)((*p) + 4));
>  		*p += 8;
>  		if (be32_to_cpu(initial_boot_params->version) < 0x10)
> -			*p = _ALIGN(*p, sz >= 8 ? 8 : 4);
> +			*p = ALIGN(*p, sz >= 8 ? 8 : 4);
>  
>  		pname = find_flat_dt_string(noff);
>  		if (pname == NULL) {
> @@ -333,7 +333,7 @@ unsigned long __init unflatten_dt_node(unsigned long mem,
>  			*prev_pp = pp;
>  			prev_pp = &pp->next;
>  		}
> -		*p = _ALIGN((*p) + sz, 4);
> +		*p = ALIGN((*p) + sz, 4);
>  	}
>  	/* with version 0x10 we may not have the name property, recreate
>  	 * it here from the unit name if absent

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

* Re: [PATCH 2/3] of/flattree: Fix crash when device tree absent
  2010-07-14 23:31 ` [PATCH 2/3] of/flattree: Fix crash when device tree absent Grant Likely
  2010-07-15  1:11   ` Jeremy Kerr
@ 2010-07-19  0:04   ` Benjamin Herrenschmidt
  2010-07-19  4:37     ` Grant Likely
  1 sibling, 1 reply; 11+ messages in thread
From: Benjamin Herrenschmidt @ 2010-07-19  0:04 UTC (permalink / raw)
  To: Grant Likely
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw

On Wed, 2010-07-14 at 17:31 -0600, Grant Likely wrote:
> This patch fixes the condition where device tree support is compiled
> in, but no device tree was proved by firmware.  It makes
> of_platform_bus_probe() explicitly check for a NULL device tree
> pointer, and adds an error message if the device tree was unable
> to be flattened.
> 
> Signed-off-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>

Not sure about the message..

> ---
>  drivers/of/fdt.c      |    2 ++
>  drivers/of/platform.c |    2 ++
>  2 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index d61fda8..66401bc 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -94,6 +94,8 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
>  			break;
>  	} while (1);
>  
> +	if (rc)
> +		pr_err("Failed to unflatten device tree blob.  rc=%i\n", rc);
>  	return rc;
>  }

This is of_scan_flat_dt() ... might be better using something like

"Failed to scan the flat device-tree (error %d)". Might also want to
rate limit it to 1.

> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> index f0ca906..9bc6999 100644
> --- a/drivers/of/platform.c
> +++ b/drivers/of/platform.c
> @@ -674,6 +674,8 @@ int of_platform_bus_probe(struct device_node *root,
>  		root = of_find_node_by_path("/");
>  	else
>  		of_node_get(root);
> +	if (root == NULL)
> +		return -EINVAL;
>  
>  	pr_debug("of_platform_bus_probe()\n");
>  	pr_debug(" starting at: %s\n", root->full_name);

Cheers,
Ben.

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

* Re: [PATCH 3/3] of: Remove unused of_find_device_by_phandle()
  2010-07-14 23:31 ` [PATCH 3/3] of: Remove unused of_find_device_by_phandle() Grant Likely
@ 2010-07-19  0:06   ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 11+ messages in thread
From: Benjamin Herrenschmidt @ 2010-07-19  0:06 UTC (permalink / raw)
  To: Grant Likely
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw

On Wed, 2010-07-14 at 17:31 -0600, Grant Likely wrote:
> Signed-off-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>

Acked-by: Benjamin Herrenschmidt <benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>

> ---
>  arch/microblaze/include/asm/of_platform.h |    2 --
>  arch/microblaze/kernel/of_platform.c      |   18 ------------------
>  arch/powerpc/include/asm/of_platform.h    |    2 --
>  arch/powerpc/kernel/of_platform.c         |   19 -------------------
>  4 files changed, 0 insertions(+), 41 deletions(-)
> 
> diff --git a/arch/microblaze/include/asm/of_platform.h b/arch/microblaze/include/asm/of_platform.h
> index 625003f..353d8f6 100644
> --- a/arch/microblaze/include/asm/of_platform.h
> +++ b/arch/microblaze/include/asm/of_platform.h
> @@ -14,8 +14,6 @@
>  /* This is just here during the transition */
>  #include <linux/of_platform.h>
>  
> -extern struct of_device *of_find_device_by_phandle(phandle ph);
> -
>  extern void of_instantiate_rtc(void);
>  
>  #endif /* _ASM_MICROBLAZE_OF_PLATFORM_H */
> diff --git a/arch/microblaze/kernel/of_platform.c b/arch/microblaze/kernel/of_platform.c
> index 33212bb..80c9c49 100644
> --- a/arch/microblaze/kernel/of_platform.c
> +++ b/arch/microblaze/kernel/of_platform.c
> @@ -63,21 +63,3 @@ struct of_device *of_find_device_by_node(struct device_node *np)
>  	return NULL;
>  }
>  EXPORT_SYMBOL(of_find_device_by_node);
> -
> -static int of_dev_phandle_match(struct device *dev, void *data)
> -{
> -	phandle *ph = data;
> -	return to_of_device(dev)->dev.of_node->phandle == *ph;
> -}
> -
> -struct of_device *of_find_device_by_phandle(phandle ph)
> -{
> -	struct device *dev;
> -
> -	dev = bus_find_device(&platform_bus_type,
> -			      NULL, &ph, of_dev_phandle_match);
> -	if (dev)
> -		return to_of_device(dev);
> -	return NULL;
> -}
> -EXPORT_SYMBOL(of_find_device_by_phandle);
> diff --git a/arch/powerpc/include/asm/of_platform.h b/arch/powerpc/include/asm/of_platform.h
> index b37d2dc..d506aa6 100644
> --- a/arch/powerpc/include/asm/of_platform.h
> +++ b/arch/powerpc/include/asm/of_platform.h
> @@ -11,8 +11,6 @@
>   *
>   */
>  
> -extern struct of_device *of_find_device_by_phandle(phandle ph);
> -
>  extern void of_instantiate_rtc(void);
>  
>  #endif	/* _ASM_POWERPC_OF_PLATFORM_H */
> diff --git a/arch/powerpc/kernel/of_platform.c b/arch/powerpc/kernel/of_platform.c
> index a3d7154..b093d4b 100644
> --- a/arch/powerpc/kernel/of_platform.c
> +++ b/arch/powerpc/kernel/of_platform.c
> @@ -68,25 +68,6 @@ struct of_device *of_find_device_by_node(struct device_node *np)
>  }
>  EXPORT_SYMBOL(of_find_device_by_node);
>  
> -static int of_dev_phandle_match(struct device *dev, void *data)
> -{
> -	phandle *ph = data;
> -	return to_of_device(dev)->dev.of_node->phandle == *ph;
> -}
> -
> -struct of_device *of_find_device_by_phandle(phandle ph)
> -{
> -	struct device *dev;
> -
> -	dev = bus_find_device(&platform_bus_type,
> -			      NULL, &ph, of_dev_phandle_match);
> -	if (dev)
> -		return to_of_device(dev);
> -	return NULL;
> -}
> -EXPORT_SYMBOL(of_find_device_by_phandle);
> -
> -
>  #ifdef CONFIG_PPC_OF_PLATFORM_PCI
>  
>  /* The probing of PCI controllers from of_platform is currently

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

* Re: [PATCH 2/3] of/flattree: Fix crash when device tree absent
  2010-07-19  0:04   ` Benjamin Herrenschmidt
@ 2010-07-19  4:37     ` Grant Likely
  0 siblings, 0 replies; 11+ messages in thread
From: Grant Likely @ 2010-07-19  4:37 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw

On Sun, Jul 18, 2010 at 6:04 PM, Benjamin Herrenschmidt
<benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org> wrote:
> On Wed, 2010-07-14 at 17:31 -0600, Grant Likely wrote:
>> This patch fixes the condition where device tree support is compiled
>> in, but no device tree was proved by firmware.  It makes
>> of_platform_bus_probe() explicitly check for a NULL device tree
>> pointer, and adds an error message if the device tree was unable
>> to be flattened.
>>
>> Signed-off-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
>
> Not sure about the message..

What do you mean?  On the draft ARM code, CONFIG_OF can be set, but no
device tree passed in.  As for the error message, I've removed that
from this patch (see below).

>
>> ---
>>  drivers/of/fdt.c      |    2 ++
>>  drivers/of/platform.c |    2 ++
>>  2 files changed, 4 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
>> index d61fda8..66401bc 100644
>> --- a/drivers/of/fdt.c
>> +++ b/drivers/of/fdt.c
>> @@ -94,6 +94,8 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
>>                       break;
>>       } while (1);
>>
>> +     if (rc)
>> +             pr_err("Failed to unflatten device tree blob.  rc=%i\n", rc);
>>       return rc;
>>  }
>
> This is of_scan_flat_dt() ... might be better using something like
>
> "Failed to scan the flat device-tree (error %d)". Might also want to
> rate limit it to 1.

I've dropped this hunk anyway.  IIRC, I added this message to the
unflatten function, but it looks to have gotten mangled during a
rebase.  Anyway, there is no need for it right now, so I'll just write
a separate patch later if that changes.

g.

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

end of thread, other threads:[~2010-07-19  4:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-14 23:31 [PATCH 1/3] of/flattree: Use common ALIGN() macro instead of arch specific _ALIGN Grant Likely
2010-07-14 23:31 ` [PATCH 2/3] of/flattree: Fix crash when device tree absent Grant Likely
2010-07-15  1:11   ` Jeremy Kerr
     [not found]     ` <1279156262.15089.68.camel-353AF/3W9ll+urZeOPWqwQ@public.gmane.org>
2010-07-15  6:15       ` Grant Likely
     [not found]         ` <AANLkTikD3ZhhVg4PTuG5Zkc38oW1I6yaQyKqcv9rAaoR-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-07-15  7:26           ` Jeremy Kerr
2010-07-19  0:04   ` Benjamin Herrenschmidt
2010-07-19  4:37     ` Grant Likely
2010-07-14 23:31 ` [PATCH 3/3] of: Remove unused of_find_device_by_phandle() Grant Likely
2010-07-19  0:06   ` Benjamin Herrenschmidt
2010-07-15  1:12 ` [PATCH 1/3] of/flattree: Use common ALIGN() macro instead of arch specific _ALIGN Jeremy Kerr
2010-07-19  0:03 ` Benjamin Herrenschmidt

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