diff options
author | Simon Glass <sjg@chromium.org> | 2014-07-30 03:59:03 -0600 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2014-08-09 11:17:04 -0400 |
commit | 0596d35d80f5090440bd9a2a2beaacb268ff59c0 (patch) | |
tree | ae3d87ad5ca521d3f9f2f714fb9c0afe68e4c905 /lib/libfdt/fdt_addresses.c | |
parent | 5bf58ccc8ebd5270f64a20c4c54c98a96acbd7ed (diff) | |
download | u-boot-imx-0596d35d80f5090440bd9a2a2beaacb268ff59c0.zip u-boot-imx-0596d35d80f5090440bd9a2a2beaacb268ff59c0.tar.gz u-boot-imx-0596d35d80f5090440bd9a2a2beaacb268ff59c0.tar.bz2 |
fdt: Sync up with libfdt
This brings in changes up to commit f9e91a48 in the libfdt repo.
Mostly this is whitespace/minor changes. But there are a few new
features:
- fdt_size_cells() and fdt_address_cells()
- fdt_resize()
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib/libfdt/fdt_addresses.c')
-rw-r--r-- | lib/libfdt/fdt_addresses.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/lib/libfdt/fdt_addresses.c b/lib/libfdt/fdt_addresses.c new file mode 100644 index 0000000..76054d9 --- /dev/null +++ b/lib/libfdt/fdt_addresses.c @@ -0,0 +1,55 @@ +/* + * libfdt - Flat Device Tree manipulation + * Copyright (C) 2014 David Gibson <david@gibson.dropbear.id.au> + * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause + */ +#include "libfdt_env.h" + +#ifndef USE_HOSTCC +#include <fdt.h> +#include <libfdt.h> +#else +#include "fdt_host.h" +#endif + +#include "libfdt_internal.h" + +int fdt_address_cells(const void *fdt, int nodeoffset) +{ + const fdt32_t *ac; + int val; + int len; + + ac = fdt_getprop(fdt, nodeoffset, "#address-cells", &len); + if (!ac) + return 2; + + if (len != sizeof(*ac)) + return -FDT_ERR_BADNCELLS; + + val = fdt32_to_cpu(*ac); + if ((val <= 0) || (val > FDT_MAX_NCELLS)) + return -FDT_ERR_BADNCELLS; + + return val; +} + +int fdt_size_cells(const void *fdt, int nodeoffset) +{ + const fdt32_t *sc; + int val; + int len; + + sc = fdt_getprop(fdt, nodeoffset, "#size-cells", &len); + if (!sc) + return 2; + + if (len != sizeof(*sc)) + return -FDT_ERR_BADNCELLS; + + val = fdt32_to_cpu(*sc); + if ((val < 0) || (val > FDT_MAX_NCELLS)) + return -FDT_ERR_BADNCELLS; + + return val; +} |