Various OF cleanups
cover Various OF cleanups
Here are some simple fixes to make the OF header files safe to include when CONFIG_OF is not set, and add some debug context messages.
Cheers,
g.
---
Grant Likely (3):
of: protect contents of of_platform.h and of_device.h 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_device.h | 2 ++ include/linux/of_fdt.h | 4 ++++ include/linux/of_platform.h | 2 ++ 4 files changed, 23 insertions(+), 0 deletions(-)
Signature · 1 line
Signature
PATCH 1/3 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/3 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 */ +static inline void define unflatten_device_tree(void) {}#endif /* CONFIG_OF_FLATTREE */ #endif /* __ASSEMBLY__ */
Re: [PATCH 2/3] of/flattree: Make unflatten_device_tree() safe to call from any arch
Hi Grant,
Quoted 3 lines · On Thu, 11 Mar 2010 10:32:03 -0700 Grant Likely…
- If
CONFIG_OF_FLATTREEis not set, then makeunflatten_device_tree()an empty #define.
"an empty static inline funtion."
include/linux/of_fdt.h extern int early_init_dt_scan_root(unsigned long node, const char *uname, · line 103
Quoted 10 lines
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 */ +static inline void define unflatten_device_tree(void) {}
^^^^^^
You need to remove that.
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/3] of/flattree: Make unflatten_device_tree() safe to call from any arch
Quoted 9 lines · Stephen Rothwell
Hi Grant,
Quoted 3 lines · On Thu, 11 Mar 2010 10:32:03 -0700 Grant Likely <[email protected]>…
- If
CONFIG_OF_FLATTREEis not set, then makeunflatten_device_tree()an empty #define."an empty static inline funtion."
Quoted 12 lines
include/linux/of_fdt.h extern int early_init_dt_scan_root(unsigned long node, const char *uname, · line 103
Quoted 10 lines
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 */ +static inline void define unflatten_device_tree(void) {}^^^^^^
You need to remove that.
Fixed. Thanks.
g.
PATCH 3/3 of: protect contents of of_platform.h and of_device.h
In reply to Grant LikelyOnly process contents of of_platform.h and of_device.h if CONFIG_OF_DEVICE is set.
---
include/linux/of_device.h | 2 ++ include/linux/of_platform.h | 2 ++ 2 files changed, 4 insertions(+), 0 deletions(-)
include/linux/of_device.h +2 -0
@@ -1,6 +1,7 @@#ifndef _LINUX_OF_DEVICE_H#define _LINUX_OF_DEVICE_H +#ifdef CONFIG_OF_DEVICE #include <linux/device.h> #include <linux/of.h> #include <linux/mod_devicetable.h>
@@ -26,5 +27,6 @@ static inline void of_device_free(struct of_device *dev)extern ssize_t of_device_get_modalias (struct of_device *ofdev,char *str,ssize_t len); +#endif /* CONFIG_OF_DEVICE */ #endif /* _LINUX_OF_DEVICE_H */
include/linux/of_platform.h +2 -0
@@ -11,6 +11,7 @@* */ +#ifdef CONFIG_OF_DEVICE #include <linux/module.h> #include <linux/device.h> #include <linux/mod_devicetable.h>
@@ -66,5 +67,6 @@ static inline void of_unregister_platform_driver(struct of_platform_driver *drv)extern struct of_device *of_find_device_by_node (struct device_node *np);extern int of_bus_type_init (struct bus_type *bus,const char *name); +#endif /* CONFIG_OF_DEVICE */ #endif /* _LINUX_OF_PLATFORM_H */