* [PATCH] zImage: atags_to_fdt: fix __be32 and __be64 types
@ 2019-10-10 10:53 Ben Dooks
2019-10-10 10:56 ` Ben Dooks
2019-10-10 16:21 ` Russell King - ARM Linux admin
0 siblings, 2 replies; 7+ messages in thread
From: Ben Dooks @ 2019-10-10 10:53 UTC (permalink / raw)
To: linux-kernel; +Cc: Ben Dooks, Russell King, linux-arm-kernel
There are some sparse warnings about type conversion in
the atags_to_fdt.c code, due to __be32 and __be64, so
fix the following:
- Change _be32 and __be64 where appropriate
- Change setprop() to take a 'void *'
- Change incorrect fdt32_to_cpu() on FDT_MAGIC
Fixes 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:141:34: warning: cast to restricted __be32
arch/arm/boot/compressed/atags_to_fdt.c:141:34: warning: cast to restricted __be32
arch/arm/boot/compressed/atags_to_fdt.c:141:34: warning: cast to restricted __be32
arch/arm/boot/compressed/atags_to_fdt.c:141:34: warning: cast to restricted __be32
arch/arm/boot/compressed/atags_to_fdt.c:141:34: warning: cast to restricted __be32
arch/arm/boot/compressed/atags_to_fdt.c:141:34: 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 int
arch/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 int
arch/arm/boot/compressed/atags_to_fdt.c:189:62: got restricted __be32 [usertype]
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
KernelVersion: 5.4-rc2
---
Cc: Russell King <linux@armlinux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Changes since v1:
- Fix setprop() type to void *
- Fix ftd32_to_cpu on FDT_MAGIC
---
arch/arm/boot/compressed/atags_to_fdt.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c
index 330cd3c2eae5..cd889f19c8a3 100644
--- a/arch/arm/boot/compressed/atags_to_fdt.c
+++ b/arch/arm/boot/compressed/atags_to_fdt.c
@@ -19,7 +19,7 @@ static int node_offset(void *fdt, const char *node_path)
}
static int setprop(void *fdt, const char *node_path, const char *property,
- uint32_t *val_array, int size)
+ void *val_array, int size)
{
int offset = node_offset(fdt, node_path);
if (offset < 0)
@@ -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 (*(__be32 *)atag_list == cpu_to_fdt32(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);
}
--
2.23.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] zImage: atags_to_fdt: fix __be32 and __be64 types
2019-10-10 10:53 [PATCH] zImage: atags_to_fdt: fix __be32 and __be64 types Ben Dooks
@ 2019-10-10 10:56 ` Ben Dooks
2019-10-10 16:21 ` Russell King - ARM Linux admin
1 sibling, 0 replies; 7+ messages in thread
From: Ben Dooks @ 2019-10-10 10:56 UTC (permalink / raw)
To: linux-kernel; +Cc: Russell King, linux-arm-kernel
On 10/10/2019 11:53, Ben Dooks wrote:
> There are some sparse warnings about type conversion in
> the atags_to_fdt.c code, due to __be32 and __be64, so
> fix the following:
>
> - Change _be32 and __be64 where appropriate
> - Change setprop() to take a 'void *'
> - Change incorrect fdt32_to_cpu() on FDT_MAGIC
>
> Fixes 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:141:34: warning: cast to restricted __be32
> arch/arm/boot/compressed/atags_to_fdt.c:141:34: warning: cast to restricted __be32
> arch/arm/boot/compressed/atags_to_fdt.c:141:34: warning: cast to restricted __be32
> arch/arm/boot/compressed/atags_to_fdt.c:141:34: warning: cast to restricted __be32
> arch/arm/boot/compressed/atags_to_fdt.c:141:34: warning: cast to restricted __be32
> arch/arm/boot/compressed/atags_to_fdt.c:141:34: 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 int
> arch/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 int
> arch/arm/boot/compressed/atags_to_fdt.c:189:62: got restricted __be32 [usertype]
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
> KernelVersion: 5.4-rc2
> ---
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: linux-arm-kernel@lists.infradead.org
>
> Changes since v1:
> - Fix setprop() type to void *
> - Fix ftd32_to_cpu on FDT_MAGIC
> ---
> arch/arm/boot/compressed/atags_to_fdt.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c
> index 330cd3c2eae5..cd889f19c8a3 100644
> --- a/arch/arm/boot/compressed/atags_to_fdt.c
> +++ b/arch/arm/boot/compressed/atags_to_fdt.c
> @@ -19,7 +19,7 @@ static int node_offset(void *fdt, const char *node_path)
> }
>
> static int setprop(void *fdt, const char *node_path, const char *property,
> - uint32_t *val_array, int size)
> + void *val_array, int size)
> {
> int offset = node_offset(fdt, node_path);
> if (offset < 0)
> @@ -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 (*(__be32 *)atag_list == cpu_to_fdt32(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,
grr, forgot to fix this.
> 4 * memcount * memsize);
> }
>
>
--
Ben Dooks http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
https://www.codethink.co.uk/privacy.html
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] zImage: atags_to_fdt: fix __be32 and __be64 types
2019-10-10 10:53 [PATCH] zImage: atags_to_fdt: fix __be32 and __be64 types Ben Dooks
2019-10-10 10:56 ` Ben Dooks
@ 2019-10-10 16:21 ` Russell King - ARM Linux admin
2019-10-11 10:21 ` Ben Dooks
1 sibling, 1 reply; 7+ messages in thread
From: Russell King - ARM Linux admin @ 2019-10-10 16:21 UTC (permalink / raw)
To: Ben Dooks; +Cc: linux-kernel, linux-arm-kernel
On Thu, Oct 10, 2019 at 11:53:57AM +0100, Ben Dooks wrote:
> There are some sparse warnings about type conversion in
> the atags_to_fdt.c code, due to __be32 and __be64, so
> fix the following:
>
> - Change _be32 and __be64 where appropriate
> - Change setprop() to take a 'void *'
> - Change incorrect fdt32_to_cpu() on FDT_MAGIC
>
> Fixes 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:141:34: warning: cast to restricted __be32
> arch/arm/boot/compressed/atags_to_fdt.c:141:34: warning: cast to restricted __be32
> arch/arm/boot/compressed/atags_to_fdt.c:141:34: warning: cast to restricted __be32
> arch/arm/boot/compressed/atags_to_fdt.c:141:34: warning: cast to restricted __be32
> arch/arm/boot/compressed/atags_to_fdt.c:141:34: warning: cast to restricted __be32
> arch/arm/boot/compressed/atags_to_fdt.c:141:34: 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 int
> arch/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 int
> arch/arm/boot/compressed/atags_to_fdt.c:189:62: got restricted __be32 [usertype]
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
> KernelVersion: 5.4-rc2
> ---
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: linux-arm-kernel@lists.infradead.org
>
> Changes since v1:
> - Fix setprop() type to void *
> - Fix ftd32_to_cpu on FDT_MAGIC
> ---
> arch/arm/boot/compressed/atags_to_fdt.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c
> index 330cd3c2eae5..cd889f19c8a3 100644
> --- a/arch/arm/boot/compressed/atags_to_fdt.c
> +++ b/arch/arm/boot/compressed/atags_to_fdt.c
> @@ -19,7 +19,7 @@ static int node_offset(void *fdt, const char *node_path)
> }
>
> static int setprop(void *fdt, const char *node_path, const char *property,
> - uint32_t *val_array, int size)
> + void *val_array, int size)
> {
> int offset = node_offset(fdt, node_path);
> if (offset < 0)
> @@ -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 (*(__be32 *)atag_list == cpu_to_fdt32(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,
As setprop() now takes a void pointer argument, do you need this cast?
> 4 * memcount * memsize);
> }
>
> --
> 2.23.0
>
>
--
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
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] zImage: atags_to_fdt: fix __be32 and __be64 types
2019-10-10 16:21 ` Russell King - ARM Linux admin
@ 2019-10-11 10:21 ` Ben Dooks
0 siblings, 0 replies; 7+ messages in thread
From: Ben Dooks @ 2019-10-11 10:21 UTC (permalink / raw)
To: Russell King - ARM Linux admin; +Cc: linux-kernel, linux-arm-kernel
On 10/10/2019 17:21, Russell King - ARM Linux admin wrote:
> On Thu, Oct 10, 2019 at 11:53:57AM +0100, Ben Dooks wrote:
>> There are some sparse warnings about type conversion in
>> the atags_to_fdt.c code, due to __be32 and __be64, so
>> fix the following:
>>
>> - Change _be32 and __be64 where appropriate
>> - Change setprop() to take a 'void *'
>> - Change incorrect fdt32_to_cpu() on FDT_MAGIC
>>
>> Fixes 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:141:34: warning: cast to restricted __be32
>> arch/arm/boot/compressed/atags_to_fdt.c:141:34: warning: cast to restricted __be32
>> arch/arm/boot/compressed/atags_to_fdt.c:141:34: warning: cast to restricted __be32
>> arch/arm/boot/compressed/atags_to_fdt.c:141:34: warning: cast to restricted __be32
>> arch/arm/boot/compressed/atags_to_fdt.c:141:34: warning: cast to restricted __be32
>> arch/arm/boot/compressed/atags_to_fdt.c:141:34: 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 int
>> arch/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 int
>> arch/arm/boot/compressed/atags_to_fdt.c:189:62: got restricted __be32 [usertype]
>>
>> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
>> ---
>> KernelVersion: 5.4-rc2
>> ---
>> Cc: Russell King <linux@armlinux.org.uk>
>> Cc: linux-arm-kernel@lists.infradead.org
>>
>> Changes since v1:
>> - Fix setprop() type to void *
>> - Fix ftd32_to_cpu on FDT_MAGIC
>> ---
>> arch/arm/boot/compressed/atags_to_fdt.c | 14 +++++++-------
>> 1 file changed, 7 insertions(+), 7 deletions(-)
>>
>> diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c
>> index 330cd3c2eae5..cd889f19c8a3 100644
>> --- a/arch/arm/boot/compressed/atags_to_fdt.c
>> +++ b/arch/arm/boot/compressed/atags_to_fdt.c
>> @@ -19,7 +19,7 @@ static int node_offset(void *fdt, const char *node_path)
>> }
>>
>> static int setprop(void *fdt, const char *node_path, const char *property,
>> - uint32_t *val_array, int size)
>> + void *val_array, int size)
>> {
>> int offset = node_offset(fdt, node_path);
>> if (offset < 0)
>> @@ -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 (*(__be32 *)atag_list == cpu_to_fdt32(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,
>
> As setprop() now takes a void pointer argument, do you need this cast?
Yes, sorry noticed this just after I sent the v2 so fixed v3.
--
Ben Dooks http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
https://www.codethink.co.uk/privacy.html
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] zImage: atags_to_fdt: fix __be32 and __be64 types
@ 2019-10-09 16:01 Ben Dooks
2019-10-09 16:24 ` Russell King - ARM Linux admin
0 siblings, 1 reply; 7+ messages in thread
From: Ben Dooks @ 2019-10-09 16:01 UTC (permalink / raw)
To: linux-kernel; +Cc: Ben Dooks, Russell King, linux-arm-kernel
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 int
arch/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 int
arch/arm/boot/compressed/atags_to_fdt.c:189:62: got restricted __be32 [usertype]
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
Cc: Russell King <linux@armlinux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
---
arch/arm/boot/compressed/atags_to_fdt.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c
index 330cd3c2eae5..13407d0243b9 100644
--- a/arch/arm/boot/compressed/atags_to_fdt.c
+++ b/arch/arm/boot/compressed/atags_to_fdt.c
@@ -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);
}
--
2.23.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] zImage: atags_to_fdt: fix __be32 and __be64 types
2019-10-09 16:01 Ben Dooks
@ 2019-10-09 16:24 ` Russell King - ARM Linux admin
2019-10-10 8:06 ` Ben Dooks
0 siblings, 1 reply; 7+ messages in thread
From: Russell King - ARM Linux admin @ 2019-10-09 16:24 UTC (permalink / raw)
To: Ben Dooks; +Cc: linux-kernel, linux-arm-kernel
On Wed, Oct 09, 2019 at 05:01:53PM +0100, Ben Dooks wrote:
> 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 int
> arch/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 int
> arch/arm/boot/compressed/atags_to_fdt.c:189:62: got restricted __be32 [usertype]
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: linux-arm-kernel@lists.infradead.org
> ---
> arch/arm/boot/compressed/atags_to_fdt.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c
> index 330cd3c2eae5..13407d0243b9 100644
> --- a/arch/arm/boot/compressed/atags_to_fdt.c
> +++ b/arch/arm/boot/compressed/atags_to_fdt.c
> @@ -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,
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.
> 4 * memcount * memsize);
> }
>
> --
> 2.23.0
>
>
--
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
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] zImage: atags_to_fdt: fix __be32 and __be64 types
2019-10-09 16:24 ` Russell King - ARM Linux admin
@ 2019-10-10 8:06 ` Ben Dooks
0 siblings, 0 replies; 7+ messages in thread
From: Ben Dooks @ 2019-10-10 8:06 UTC (permalink / raw)
To: Russell King - ARM Linux admin; +Cc: linux-kernel, linux-arm-kernel
On 09/10/2019 17:24, Russell King - ARM Linux admin wrote:
> On Wed, Oct 09, 2019 at 05:01:53PM +0100, Ben Dooks wrote:
>> 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 int
>> arch/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 int
>> arch/arm/boot/compressed/atags_to_fdt.c:189:62: got restricted __be32 [usertype]
>>
>> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
>> ---
>> Cc: Russell King <linux@armlinux.org.uk>
>> Cc: linux-arm-kernel@lists.infradead.org
>> ---
>> arch/arm/boot/compressed/atags_to_fdt.c | 12 ++++++------
>> 1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c
>> index 330cd3c2eae5..13407d0243b9 100644
>> --- a/arch/arm/boot/compressed/atags_to_fdt.c
>> +++ b/arch/arm/boot/compressed/atags_to_fdt.c
>> @@ -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,
>
> 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.
ok, thank you for pointing this out, I will go and sort this out.
>> 4 * memcount * memsize);
>> }
>>
>> --
>> 2.23.0
>>
>>
>
--
Ben Dooks http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
https://www.codethink.co.uk/privacy.html
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-10-11 10:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-10 10:53 [PATCH] zImage: atags_to_fdt: fix __be32 and __be64 types Ben Dooks
2019-10-10 10:56 ` Ben Dooks
2019-10-10 16:21 ` Russell King - ARM Linux admin
2019-10-11 10:21 ` Ben Dooks
-- strict thread matches above, loose matches on Subject: below --
2019-10-09 16:01 Ben Dooks
2019-10-09 16:24 ` Russell King - ARM Linux admin
2019-10-10 8:06 ` Ben Dooks
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.