[U-Boot] [PATCH 19/32] include/fdt.h: sparse fixes

Kim Phillips kim.phillips at freescale.com
Wed Oct 17 02:28:35 CEST 2012


fix endianness warnings such as these:

cmd_fdt.c:479:29: warning: cast to restricted __be32
cmd_fdt.c:482:41: warning: cast to restricted __be32
cmd_fdt.c:486:29: warning: cast to restricted __be32
cmd_fdt.c:489:41: warning: cast to restricted __be32
cmd_fdt.c:776:41: warning: cast to restricted __be32
cmd_fdt.c:777:36: warning: cast to restricted __be32
cmd_fdt.c:101:35: warning: cast to restricted __be32
cmd_fdt.c:104:46: warning: cast to restricted __be32
cmd_fdt.c:154:31: warning: cast to restricted __be32
cmd_fdt.c:157:35: warning: cast to restricted __be32
cmd_fdt.c:160:46: warning: cast to restricted __be32
cmd_fdt.c:331:31: warning: cast to restricted __be32
cmd_fdt.c:332:46: warning: cast to restricted __be32
cmd_fdt.c:333:53: warning: cast to restricted __be32
cmd_fdt.c:334:24: warning: cast to restricted __be32
cmd_fdt.c:336:24: warning: cast to restricted __be32
cmd_fdt.c:338:24: warning: cast to restricted __be32
cmd_fdt.c:340:24: warning: cast to restricted __be32
cmd_fdt.c:343:24: warning: cast to restricted __be32
cmd_fdt.c:346:33: warning: cast to restricted __be32
cmd_fdt.c:349:33: warning: cast to restricted __be32
cmd_fdt.c:352:33: warning: cast to restricted __be32
include/libfdt.h:169:1: warning: incorrect type in assignment (different base types)
include/libfdt.h:169:1:    expected unsigned int [unsigned] [usertype] boot_cpuid_phys
include/libfdt.h:169:1:    got restricted __be32 [usertype] <noident>

by annotating fdt header integers big endian.

Also address the following problems for files in lib/libfdt/:

fdt.c:108:15: warning: cast to restricted __be32
fdt.c:128:27: warning: cast to restricted __be32
fdt_ro.c:341:16: warning: cast to restricted __be32
fdt_rw.c:374:17: warning: incorrect type in assignment (different base types)
fdt_rw.c:374:17:    expected unsigned int [unsigned] [usertype] <noident>
fdt_rw.c:374:17:    got restricted __be32 [usertype] <noident>
include/libfdt.h:1156:13: warning: incorrect type in assignment (different base types)
include/libfdt.h:1156:13:    expected unsigned int [unsigned] [usertype] val
include/libfdt.h:1156:13:    got restricted __be32 [usertype] <noident>
fdt_sw.c:164:13: warning: incorrect type in assignment (different base types)
fdt_sw.c:164:13:    expected unsigned int [unsigned] [usertype] <noident>
fdt_sw.c:164:13:    got restricted __be32 [usertype] <noident>
fdt_sw.c:227:14: warning: incorrect type in assignment (different base types)
fdt_sw.c:227:14:    expected unsigned int [unsigned] [usertype] <noident>
fdt_sw.c:227:14:    got restricted __be32 [usertype] <noident>
fdt_wip.c:84:20: warning: incorrect type in assignment (different base types)
fdt_wip.c:84:20:    expected unsigned int [unsigned] [usertype] <noident>
fdt_wip.c:84:20:    got restricted __be32 [usertype] <noident>

the changes in include/fdt_support.h fix these problems in
arch/powerpc/cpu/mpc8xxx/fdt.c:

fdt.c:57:6: warning: symbol 'ft_fixup_num_cores' was not declared. Should it be static?
fdt.c:331:6: warning: symbol 'ft_srio_setup' was not declared. Should it be static?

Signed-off-by: Kim Phillips <kim.phillips at freescale.com>
---
 include/fdt.h         | 33 +++++++++++++++++----------------
 include/fdt_support.h |  2 ++
 include/libfdt.h      |  4 ++--
 lib/libfdt/fdt.c      |  2 +-
 lib/libfdt/fdt_ro.c   |  2 +-
 lib/libfdt/fdt_rw.c   |  4 ++--
 lib/libfdt/fdt_sw.c   |  4 ++--
 lib/libfdt/fdt_wip.c  |  2 +-
 8 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/include/fdt.h b/include/fdt.h
index c51212e..1b7f044 100644
--- a/include/fdt.h
+++ b/include/fdt.h
@@ -2,40 +2,41 @@
 #define _FDT_H
 
 #ifndef __ASSEMBLY__
+#include <asm/byteorder.h>
 
 struct fdt_header {
-	uint32_t magic;			 /* magic word FDT_MAGIC */
-	uint32_t totalsize;		 /* total size of DT block */
-	uint32_t off_dt_struct;		 /* offset to structure */
-	uint32_t off_dt_strings;	 /* offset to strings */
-	uint32_t off_mem_rsvmap;	 /* offset to memory reserve map */
-	uint32_t version;		 /* format version */
-	uint32_t last_comp_version;	 /* last compatible version */
+	__be32 magic;			 /* magic word FDT_MAGIC */
+	__be32 totalsize;		 /* total size of DT block */
+	__be32 off_dt_struct;		 /* offset to structure */
+	__be32 off_dt_strings;	 /* offset to strings */
+	__be32 off_mem_rsvmap;	 /* offset to memory reserve map */
+	__be32 version;		 /* format version */
+	__be32 last_comp_version;	 /* last compatible version */
 
 	/* version 2 fields below */
-	uint32_t boot_cpuid_phys;	 /* Which physical CPU id we're
+	__be32 boot_cpuid_phys;	 /* Which physical CPU id we're
 					    booting on */
 	/* version 3 fields below */
-	uint32_t size_dt_strings;	 /* size of the strings block */
+	__be32 size_dt_strings;	 /* size of the strings block */
 
 	/* version 17 fields below */
-	uint32_t size_dt_struct;	 /* size of the structure block */
+	__be32 size_dt_struct;	 /* size of the structure block */
 };
 
 struct fdt_reserve_entry {
-	uint64_t address;
-	uint64_t size;
+	__be64 address;
+	__be64 size;
 };
 
 struct fdt_node_header {
-	uint32_t tag;
+	__be32 tag;
 	char name[0];
 };
 
 struct fdt_property {
-	uint32_t tag;
-	uint32_t len;
-	uint32_t nameoff;
+	__be32 tag;
+	__be32 len;
+	__be32 nameoff;
 	char data[0];
 };
 
diff --git a/include/fdt_support.h b/include/fdt_support.h
index 2e18d82..399b73f 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -81,7 +81,9 @@ int fdt_pci_dma_ranges(void *blob, int phb_off, struct pci_controller *hose);
 #ifdef CONFIG_OF_BOARD_SETUP
 void ft_board_setup(void *blob, bd_t *bd);
 void ft_cpu_setup(void *blob, bd_t *bd);
+void ft_fixup_num_cores(void *blob);
 void ft_pci_setup(void *blob, bd_t *bd);
+void ft_srio_setup(void *blob);
 #endif
 
 void set_working_fdt_addr(void *addr);
diff --git a/include/libfdt.h b/include/libfdt.h
index 4589c5f..ab98d23 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -1153,8 +1153,8 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
 static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
 				  uint32_t val)
 {
-	val = cpu_to_fdt32(val);
-	return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val));
+	__be32 tmp = cpu_to_fdt32(val);
+	return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
 }
 
 /**
diff --git a/lib/libfdt/fdt.c b/lib/libfdt/fdt.c
index 4157b21..5a82c60 100644
--- a/lib/libfdt/fdt.c
+++ b/lib/libfdt/fdt.c
@@ -96,7 +96,7 @@ const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
 
 uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
 {
-	const uint32_t *tagp, *lenp;
+	const __be32 *tagp, *lenp;
 	uint32_t tag;
 	int offset = startoffset;
 	const char *p;
diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
index 1933010..4e3d87a 100644
--- a/lib/libfdt/fdt_ro.c
+++ b/lib/libfdt/fdt_ro.c
@@ -326,7 +326,7 @@ const void *fdt_getprop(const void *fdt, int nodeoffset,
 
 uint32_t fdt_get_phandle(const void *fdt, int nodeoffset)
 {
-	const uint32_t *php;
+	const __be32 *php;
 	int len;
 
 	/* FIXME: This is a bit sub-optimal, since we potentially scan
diff --git a/lib/libfdt/fdt_rw.c b/lib/libfdt/fdt_rw.c
index 5ed23d6..688b817 100644
--- a/lib/libfdt/fdt_rw.c
+++ b/lib/libfdt/fdt_rw.c
@@ -343,7 +343,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
 	int nodelen;
 	int err;
 	uint32_t tag;
-	uint32_t *endtag;
+	__be32 *endtag;
 
 	FDT_RW_CHECK_HEADER(fdt);
 
@@ -370,7 +370,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
 	nh->tag = cpu_to_fdt32(FDT_BEGIN_NODE);
 	memset(nh->name, 0, FDT_TAGALIGN(namelen+1));
 	memcpy(nh->name, name, namelen);
-	endtag = (uint32_t *)((char *)nh + nodelen - FDT_TAGSIZE);
+	endtag = (__be32 *)((char *)nh + nodelen - FDT_TAGSIZE);
 	*endtag = cpu_to_fdt32(FDT_END_NODE);
 
 	return offset;
diff --git a/lib/libfdt/fdt_sw.c b/lib/libfdt/fdt_sw.c
index 55ebebf..5ce91ba 100644
--- a/lib/libfdt/fdt_sw.c
+++ b/lib/libfdt/fdt_sw.c
@@ -153,7 +153,7 @@ int fdt_begin_node(void *fdt, const char *name)
 
 int fdt_end_node(void *fdt)
 {
-	uint32_t *en;
+	__be32 *en;
 
 	FDT_SW_CHECK_HEADER(fdt);
 
@@ -213,7 +213,7 @@ int fdt_property(void *fdt, const char *name, const void *val, int len)
 int fdt_finish(void *fdt)
 {
 	char *p = (char *)fdt;
-	uint32_t *end;
+	__be32 *end;
 	int oldstroffset, newstroffset;
 	uint32_t tag;
 	int offset, nextoffset;
diff --git a/lib/libfdt/fdt_wip.c b/lib/libfdt/fdt_wip.c
index e373677..dc1e14c 100644
--- a/lib/libfdt/fdt_wip.c
+++ b/lib/libfdt/fdt_wip.c
@@ -78,7 +78,7 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
 
 static void _fdt_nop_region(void *start, int len)
 {
-	uint32_t *p;
+	__be32 *p;
 
 	for (p = start; (char *)p < ((char *)start + len); p++)
 		*p = cpu_to_fdt32(FDT_NOP);
-- 
1.7.12.3




More information about the U-Boot mailing list