zImage: atags_to_fdt: fix __be32 and __be64 types
PATCH 1/1 zImage: atags_to_fdt: fix __be32 and __be64 types
Change types of some the uint32_t to __be32 or __be64 to avoid the following sparse warnings:
arch/arm/boot/compressed/atags_to_fdt.c:66:29: warning: cast to restricted __be32 arch/arm/boot/compressed/atags_to_fdt.c:66:29: warning: cast to restricted __be32 arch/arm/boot/compressed/atags_to_fdt.c:66:29: warning: cast to restricted __be32 arch/arm/boot/compressed/atags_to_fdt.c:66:29: warning: cast to restricted __be32 arch/arm/boot/compressed/atags_to_fdt.c:66:29: warning: cast to restricted __be32 arch/arm/boot/compressed/atags_to_fdt.c:66:29: warning: cast to restricted __be32 arch/arm/boot/compressed/atags_to_fdt.c:182:60: warning: incorrect type in assignment (different base types)arch/arm/boot/compressed/atags_to_fdt.c:182:60: expected unsigned long long [usertype]arch/arm/boot/compressed/atags_to_fdt.c:182:60: got restricted __be64 [usertype]arch/arm/boot/compressed/atags_to_fdt.c:184:60: warning: incorrect type in assignment (different base types)arch/arm/boot/compressed/atags_to_fdt.c:184:60: expected unsigned long long [usertype]arch/arm/boot/compressed/atags_to_fdt.c:184:60: got restricted __be64 [usertype]arch/arm/boot/compressed/atags_to_fdt.c:187:62: warning: incorrect type in assignment (different base types)arch/arm/boot/compressed/atags_to_fdt.c:187:62: expected unsigned intarch/arm/boot/compressed/atags_to_fdt.c:187:62: got restricted __be32 [usertype]arch/arm/boot/compressed/atags_to_fdt.c:189:62: warning: incorrect type in assignment (different base types)arch/arm/boot/compressed/atags_to_fdt.c:189:62: expected unsigned intarch/arm/boot/compressed/atags_to_fdt.c:189:62: got restricted __be32 [usertype]
---
Cc: Russell King <[email protected]>
Cc: [email protected]
--- arch/arm/boot/compressed/atags_to_fdt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/arm/boot/compressed/atags_to_fdt.c +6 -6
@@ -60,7 +60,7 @@ static uint32_t get_cell_size(const void *fdt) {int len;uint32_t cell_size =1 ; -const uint32_t *size_len =getprop (fdt,"/" ,"#size-cells" , &len); +const __be32 *size_len =getprop (fdt,"/" ,"#size-cells" , &len);if (size_len) cell_size =fdt32_to_cpu (*size_len);
@@ -129,7 +129,7 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)struct tag *atag = atag_list;/* In the case of 64 bits memory size, need to reserve 2 cells for * address and size for each bank */ -uint32_t mem_reg_property[2 *2 *NR_BANKS ]; +__be32 mem_reg_property[2 *2 *NR_BANKS ];int memcount =0 ;int ret, memsize;
@@ -138,7 +138,7 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)return 1 ;/* if we get a DTB here we're done already */ -if (*(u32 *)atag_list ==fdt32_to_cpu (FDT_MAGIC )) +if (*(u32 *)atag_list ==fdt32_to_cpu ((fdt32_t )FDT_MAGIC ))return 0 ;/* validate the ATAG */
@@ -177,8 +177,8 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)/* if memsize is 2, that means that * each data needs 2 cells of 32 bits, * so the data are 64 bits */ -uint64_t *mem_reg_prop64 = - (uint64_t *)mem_reg_property; +__be64 *mem_reg_prop64 = + (__be64 *)mem_reg_property; mem_reg_prop64[memcount++] =cpu_to_fdt64 (atag->u.mem.start); mem_reg_prop64[memcount++] =
@@ -207,7 +207,7 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space) }if (memcount) { -setprop (fdt,"/memory" ,"reg" , mem_reg_property, +setprop (fdt,"/memory" ,"reg" , (uint32_t *)mem_reg_property,4 * memcount * memsize); }
Signature · 7 lines
2.23.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Russell King - ARM Linux admin
maintainerQuoted 73 lines · Ben Dooks
Change types of some the
uint32_tto__be32or__be64to avoid the following sparse warnings:
arch/arm/boot/compressed/atags_to_fdt.c:66:29: warning: cast to restricted__be32arch/arm/boot/compressed/atags_to_fdt.c:66:29: warning: cast to restricted__be32arch/arm/boot/compressed/atags_to_fdt.c:66:29: warning: cast to restricted__be32arch/arm/boot/compressed/atags_to_fdt.c:66:29: warning: cast to restricted__be32arch/arm/boot/compressed/atags_to_fdt.c:66:29: warning: cast to restricted__be32arch/arm/boot/compressed/atags_to_fdt.c:66:29: warning: cast to restricted__be32arch/arm/boot/compressed/atags_to_fdt.c:182:60: warning: incorrect type in assignment (different base types)arch/arm/boot/compressed/atags_to_fdt.c:182:60: expected unsigned long long [usertype]arch/arm/boot/compressed/atags_to_fdt.c:182:60: got restricted__be64[usertype]arch/arm/boot/compressed/atags_to_fdt.c:184:60: warning: incorrect type in assignment (different base types)arch/arm/boot/compressed/atags_to_fdt.c:184:60: expected unsigned long long [usertype]arch/arm/boot/compressed/atags_to_fdt.c:184:60: got restricted__be64[usertype]arch/arm/boot/compressed/atags_to_fdt.c:187:62: warning: incorrect type in assignment (different base types)arch/arm/boot/compressed/atags_to_fdt.c:187:62: expected unsigned intarch/arm/boot/compressed/atags_to_fdt.c:187:62: got restricted__be32[usertype]arch/arm/boot/compressed/atags_to_fdt.c:189:62: warning: incorrect type in assignment (different base types)arch/arm/boot/compressed/atags_to_fdt.c:189:62: expected unsigned intarch/arm/boot/compressed/atags_to_fdt.c:189:62: got restricted__be32[usertype]Signed-off-by Ben Dooks <[email protected]>---
Cc: Russell King <[email protected]>
Cc: [email protected]--- arch/arm/boot/compressed/atags_to_fdt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)arch/arm/boot/compressed/atags_to_fdt.c +5
-5@@ -60,7 +60,7 @@ static uint32_t get_cell_size(const void *fdt) {int len;uint32_t cell_size =1 ; -const uint32_t *size_len =getprop (fdt,"/" ,"#size-cells" , &len); +const __be32 *size_len =getprop (fdt,"/" ,"#size-cells" , &len);if (size_len) cell_size =fdt32_to_cpu (*size_len);@@ -129,7 +129,7 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)struct tag *atag = atag_list;/* In the case of 64 bits memory size, need to reserve 2 cells for * address and size for each bank */ -uint32_t mem_reg_property[2 *2 *NR_BANKS ]; +__be32 mem_reg_property[2 *2 *NR_BANKS ];int memcount =0 ;int ret, memsize;@@ -138,7 +138,7 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)return 1 ;/* if we get a DTB here we're done already */ -if (*(u32 *)atag_list ==fdt32_to_cpu (FDT_MAGIC )) +if (*(u32 *)atag_list ==fdt32_to_cpu ((fdt32_t )FDT_MAGIC ))return 0 ;/* validate the ATAG */ @@ -177,8 +177,8 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)/* if memsize is 2, that means that * each data needs 2 cells of 32 bits, * so the data are 64 bits */ -uint64_t *mem_reg_prop64 = - (uint64_t *)mem_reg_property; +__be64 *mem_reg_prop64 = + (__be64 *)mem_reg_property; mem_reg_prop64[memcount++] =cpu_to_fdt64 (atag->u.mem.start); mem_reg_prop64[memcount++] =
arch/arm/boot/compressed/atags_to_fdt.c int atags_to_fdt(void *atag_list, void *fdt, int total_space) · line 210
Quoted 5 lines
arch/arm/boot/compressed/atags_to_fdt.c +1
-1@@ -207,7 +207,7 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space) }if (memcount) { - setprop(fdt, "/memory", "reg", mem_reg_property, + setprop(fdt, "/memory", "reg", (uint32_t *)mem_reg_property,
I'm not sure this is an improvement.
fdt_setprop() takes a const void pointer as its 4th argument:
int fdt_setprop(void *fdt, int nodeoffset, const char *name,
const void *val, int len)
setprop() could also do the same, since setprop() is just as flexible as fdt_setprop() itself. Then you don't need this cast.
Quoted 7 lines
arch/arm/boot/compressed/atags_to_fdt.c +0
-04 * memcount * memsize); }Signature · 1 line
2.23.0
Signature · 8 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 82 lines · Russell King - ARM Linux admin
Quoted 73 lines · Ben Dooks
Change types of some the
uint32_tto__be32or__be64to avoid the following sparse warnings:
arch/arm/boot/compressed/atags_to_fdt.c:66:29: warning: cast to restricted__be32arch/arm/boot/compressed/atags_to_fdt.c:66:29: warning: cast to restricted__be32arch/arm/boot/compressed/atags_to_fdt.c:66:29: warning: cast to restricted__be32arch/arm/boot/compressed/atags_to_fdt.c:66:29: warning: cast to restricted__be32arch/arm/boot/compressed/atags_to_fdt.c:66:29: warning: cast to restricted__be32arch/arm/boot/compressed/atags_to_fdt.c:66:29: warning: cast to restricted__be32arch/arm/boot/compressed/atags_to_fdt.c:182:60: warning: incorrect type in assignment (different base types)arch/arm/boot/compressed/atags_to_fdt.c:182:60: expected unsigned long long [usertype]arch/arm/boot/compressed/atags_to_fdt.c:182:60: got restricted__be64[usertype]arch/arm/boot/compressed/atags_to_fdt.c:184:60: warning: incorrect type in assignment (different base types)arch/arm/boot/compressed/atags_to_fdt.c:184:60: expected unsigned long long [usertype]arch/arm/boot/compressed/atags_to_fdt.c:184:60: got restricted__be64[usertype]arch/arm/boot/compressed/atags_to_fdt.c:187:62: warning: incorrect type in assignment (different base types)arch/arm/boot/compressed/atags_to_fdt.c:187:62: expected unsigned intarch/arm/boot/compressed/atags_to_fdt.c:187:62: got restricted__be32[usertype]arch/arm/boot/compressed/atags_to_fdt.c:189:62: warning: incorrect type in assignment (different base types)arch/arm/boot/compressed/atags_to_fdt.c:189:62: expected unsigned intarch/arm/boot/compressed/atags_to_fdt.c:189:62: got restricted__be32[usertype]Signed-off-by Ben Dooks <[email protected]>---
Cc: Russell King <[email protected]>
Cc: [email protected]--- arch/arm/boot/compressed/atags_to_fdt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)arch/arm/boot/compressed/atags_to_fdt.c +5
-5@@ -60,7 +60,7 @@ static uint32_t get_cell_size(const void *fdt) {int len;uint32_t cell_size =1 ; -const uint32_t *size_len =getprop (fdt,"/" ,"#size-cells" , &len); +const __be32 *size_len =getprop (fdt,"/" ,"#size-cells" , &len);if (size_len) cell_size =fdt32_to_cpu (*size_len);@@ -129,7 +129,7 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)struct tag *atag = atag_list;/* In the case of 64 bits memory size, need to reserve 2 cells for * address and size for each bank */ -uint32_t mem_reg_property[2 *2 *NR_BANKS ]; +__be32 mem_reg_property[2 *2 *NR_BANKS ];int memcount =0 ;int ret, memsize;@@ -138,7 +138,7 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)return 1 ;/* if we get a DTB here we're done already */ -if (*(u32 *)atag_list ==fdt32_to_cpu (FDT_MAGIC )) +if (*(u32 *)atag_list ==fdt32_to_cpu ((fdt32_t )FDT_MAGIC ))return 0 ;/* validate the ATAG */ @@ -177,8 +177,8 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)/* if memsize is 2, that means that * each data needs 2 cells of 32 bits, * so the data are 64 bits */ -uint64_t *mem_reg_prop64 = - (uint64_t *)mem_reg_property; +__be64 *mem_reg_prop64 = + (__be64 *)mem_reg_property; mem_reg_prop64[memcount++] =cpu_to_fdt64 (atag->u.mem.start); mem_reg_prop64[memcount++] =arch/arm/boot/compressed/atags_to_fdt.c int atags_to_fdt(void *atag_list, void *fdt, int total_space) · line 210
Quoted 5 lines
arch/arm/boot/compressed/atags_to_fdt.c +1
-1@@ -207,7 +207,7 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space) }if (memcount) { - setprop(fdt, "/memory", "reg", mem_reg_property, + setprop(fdt, "/memory", "reg", (uint32_t *)mem_reg_property,I'm not sure this is an improvement.
Quoted 7 lines
fdt_setprop()takes a const void pointer as its 4th argument:int fdt_setprop(void *fdt, int nodeoffset, const char *name,
const void *val, int len)
setprop()could also do the same, sincesetprop()is just as flexible asfdt_setprop()itself. Then you don't need this cast.
ok, thank you for pointing this out, I will go and sort this out.
Quoted 8 lines
Quoted 7 lines
arch/arm/boot/compressed/atags_to_fdt.c +0
-04 * memcount * memsize); }Signature · 1 line
2.23.0
Signature · 9 lines
Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius https://www.codethink.co.uk/privacy.html _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel