fit-image: Fix endianess conversion

A helper function in fit_image.c was using our self defined portable
endianess conversion function, but was not including our endian header.
This lead to broken builds on some setups:
==========================
fit_image.c: In function 'fdt_getprop_u32':
fit_image.c:86:9: warning: implicit declaration of function 'be32toh'
                  [-Wimplicit-function-declaration]
   86 |  return be32toh(*(uint32_t *)prop->data);
      |         ^~~~~~~
/usr/bin/ld: /tmp/cczFroQN.o: in function `fdt_getprop_u32':
fit_image.c:(.text+0x1e0): undefined reference to `be32toh'
collect2: error: ld returned 1 exit status
==========================

Fix this by using the libfdt provided endianess conversion function,
and using an easier way to get the property on the way.

Signed-off-by: Andre Przywara <osp@andrep.de>
Reported-by: kaidokert
This commit is contained in:
Andre Przywara 2021-12-15 23:29:01 +00:00
parent 6a9bde9d34
commit fa80ab13cf

View File

@ -77,13 +77,13 @@ static int fit_parse_arch(const char *value)
static uint32_t fdt_getprop_u32(const void *fdt, int node, const char *name)
{
const struct fdt_property *prop;
const fdt32_t *val;
prop = fdt_get_property(fdt, node, name, NULL);
if (!prop)
val = fdt_getprop(fdt, node, name, NULL);
if (!val)
return ~0U;
return be32toh(*(uint32_t *)prop->data);
return fdt32_to_cpu(*val);
}
static const char *fdt_getprop_str(const void *fdt, int node, const char *name)