Make of_fdt conditionally compile gracefully
cover Make of_fdt conditionally compile gracefully
A couple more minor changes for cross-arch device tree support.
g.
---
Grant Likely (2):
of/flattree: Make unflatten_device_tree() safe to call from any arch of/flattree: make of_fdt.h safe to unconditionally include.
drivers/of/fdt.c | 15 +++++++++++++++ include/linux/of_fdt.h | 4 ++++ 2 files changed, 19 insertions(+), 0 deletions(-)
Signature · 1 line
Signature
PATCH 1/2 of/flattree: make of_fdt.h safe to unconditionally include.
If CONFIG_OF_FLATTREE is not set, then don't process the body of linux/of_fdt.h
---
include/linux/of_fdt.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/of_fdt.h +2 -0
@@ -57,6 +57,7 @@ struct boot_param_header {__be32 dt_struct_size;/* size of the DT structure block */ }; +#if defined(CONFIG_OF_FLATTREE )/* TBD: Temporary export of fdt globals - remove when code fully merged */ extern int __initdata dt_root_addr_cells;extern int __initdata dt_root_size_cells;
@@ -98,6 +99,7 @@ extern int early_init_dt_scan_root(unsigned long node, const char *uname,/* Other Prototypes */ extern void unflatten_device_tree (void );extern void early_init_devtree (void *); +#endif /* CONFIG_OF_FLATTREE */ #endif /* __ASSEMBLY__ */ #endif /* _LINUX_OF_FDT_H */
PATCH 2/2 of/flattree: Make unflatten_device_tree() safe to call from any arch
In reply to Grant LikelyThis patch makes unflatten_device_tree() safe to call from any arch setup code with the following changes:
- Make sure initial_boot_params actually points to a device tree blob before unflattening
- Make sure the initial_boot_params->magic field is correct
- If CONFIG_OF_FLATTREE is not set, then make unflatten_device_tree() an empty #define.
This patch also adds some additional debug output to the top of unflatten_device_tree().
---
drivers/of/fdt.c | 15 +++++++++++++++ include/linux/of_fdt.h | 2 ++ 2 files changed, 17 insertions(+), 0 deletions(-)
drivers/of/fdt.c +15 -0
@@ -553,6 +553,21 @@ void __init unflatten_device_tree(void)pr_debug (" -> unflatten_device_tree()\n" ); +if (!initial_boot_params) { +pr_debug ("No device tree pointer\n" ); +return ; + } + +pr_debug ("Unflattening device tree:\n" ); +pr_debug ("magic: %08x\n" ,be32_to_cpu (initial_boot_params->magic)); +pr_debug ("size: %08x\n" ,be32_to_cpu (initial_boot_params->totalsize)); +pr_debug ("version: %08x\n" ,be32_to_cpu (initial_boot_params->version)); + +if (be32_to_cpu (initial_boot_params->magic) !=OF_DT_HEADER ) { +pr_err ("Invalid device tree blob header\n" ); +return ; + } +/* First pass, scan for size */ start = ((unsigned long )initial_boot_params) +be32_to_cpu (initial_boot_params->off_dt_struct);
include/linux/of_fdt.h +2 -0
@@ -99,6 +99,8 @@ extern int early_init_dt_scan_root(unsigned long node, const char *uname,/* Other Prototypes */ extern void unflatten_device_tree (void );extern void early_init_devtree (void *); +#else /* CONFIG_OF_FLATTREE */ +#define unflatten_device_tree () do {} while(0)#endif /* CONFIG_OF_FLATTREE */ #endif /* __ASSEMBLY__ */
Re: [PATCH 2/2] of/flattree: Make unflatten_device_tree() safe to call from any arch
Hi Grant,
Quoted 3 lines · On Mon, 22 Feb 2010 08:50:59 -0700 Grant Likely…
- If
CONFIG_OF_FLATTREEis not set, then makeunflatten_device_tree()an empty #define.
Any reason not to make this a static inline?
Quoted 1 line
+#define
unflatten_device_tree()do {} while(0)
static inline void unflatten_device_tree(void) {}
Signature · 3 lines
Cheers, Stephen Rothwell [email protected] http://www.canb.auug.org.au/~sfr/
_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH 2/2] of/flattree: Make unflatten_device_tree() safe to call from any arch
Quoted 4 lines · Stephen Rothwell
Hi Grant,
Quoted 1 line · On Mon, 22 Feb 2010 08:50:59 -0700 Grant Likely <[email protected]>…
Quoted 8 lines
Quoted 2 lines
- If
CONFIG_OF_FLATTREEis not set, then makeunflatten_device_tree()an empty #define.Any reason not to make this a static inline?
Quoted 1 line
+#define
unflatten_device_tree()do {} while(0)static inline void
unflatten_device_tree(void){}
No reason, just wasn't thinking of that. I've changed this.
g.
Quoted 6 lines
--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.
Re: [PATCH 2/2] of/flattree: Make unflatten_device_tree() safe to call from any arch
Hi Grant,
Quoted 2 lines · On Mon, 22 Feb 2010 16:11:48 -0700 Grant Likely…
No reason, just wasn't thinking of that. I've changed this.
Thanks. Andrew Morton says that (unless there is a good reason) we should program the kernel in C not CPP.
Signature · 3 lines
Cheers, Stephen Rothwell [email protected] http://www.canb.auug.org.au/~sfr/
_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss