]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
dm: ofnode: use fdt32_t for DT property value to fix sparse warning
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Thu, 22 Jun 2017 08:57:50 +0000 (17:57 +0900)
committerSimon Glass <sjg@chromium.org>
Tue, 11 Jul 2017 16:08:20 +0000 (10:08 -0600)
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>
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/core/ofnode.c

index be6447daa17b85fb4220e2e1e6c6998158c868d1..fd068b06ef3c3a6d2f1c3035746fb6fcf68a4690 100644 (file)
@@ -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),
@@ -487,7 +487,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;