diff mbox

dm: ofnode: use fdt32_t for DT property value to fix sparse warning

Message ID 1498121870-22893-1-git-send-email-yamada.masahiro@socionext.com
State Accepted
Commit 8c9eaadaaad888e0cd77512553d0d02d476b4dde
Headers show

Commit Message

Masahiro Yamada June 22, 2017, 8:57 a.m. UTC
DTB is encoded in big endian.  When we retrieve property values,
we need to use fdt32_to_cpu (aka be32_to_cpu) for endian conversion.
This is a bit error-prone, but sparse is useful to detect endian
mismatch.

We need to use (fdt32_t *) instead of (u32 *) for a pointer of a
property value.  Otherwise sparse warns "cast to restricted __be32".

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 drivers/core/ofnode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Simon Glass July 6, 2017, 4:49 a.m. UTC | #1
On 22 June 2017 at 02:57, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
> DTB is encoded in big endian.  When we retrieve property values,
> we need to use fdt32_to_cpu (aka be32_to_cpu) for endian conversion.
> This is a bit error-prone, but sparse is useful to detect endian
> mismatch.
>
> We need to use (fdt32_t *) instead of (u32 *) for a pointer of a
> property value.  Otherwise sparse warns "cast to restricted __be32".
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
>  drivers/core/ofnode.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Simon Glass July 6, 2017, 5:36 p.m. UTC | #2
On 22 June 2017 at 02:57, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
> DTB is encoded in big endian.  When we retrieve property values,
> we need to use fdt32_to_cpu (aka be32_to_cpu) for endian conversion.
> This is a bit error-prone, but sparse is useful to detect endian
> mismatch.
>
> We need to use (fdt32_t *) instead of (u32 *) for a pointer of a
> property value.  Otherwise sparse warns "cast to restricted __be32".
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
>  drivers/core/ofnode.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-dm, thanks!
diff mbox

Patch

diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 5a3e1d452fbb..0ad0add7cb18 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -23,7 +23,7 @@  int ofnode_read_u32(ofnode node, const char *propname, u32 *outp)
 	if (ofnode_is_np(node)) {
 		return of_read_u32(ofnode_to_np(node), propname, outp);
 	} else {
-		const int *cell;
+		const fdt32_t *cell;
 		int len;
 
 		cell = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node),
@@ -477,7 +477,7 @@  const uint8_t *ofnode_read_u8_array_ptr(ofnode node, const char *propname,
 int ofnode_read_pci_addr(ofnode node, enum fdt_pci_space type,
 			 const char *propname, struct fdt_pci_addr *addr)
 {
-	const u32 *cell;
+	const fdt32_t *cell;
 	int len;
 	int ret = -ENOENT;