Commit b047d671dbf60beab9822349f794a0152b97ac31
Committed by
Tom Rini
1 parent
39b6d07fd7
Exists in
v2017.01-smarct4x
and in
40 other branches
lib, fdt: move fdtdec_get_int() out of lib/fdtdec.c
move fdtdec_get_int() out of lib/fdtdec.c into lib/fdtdec_common.c as this function is also used, if CONFIG_OF_CONTROL is not used. Poped up on the ids8313 board using signed FIT images, and activating CONFIG_SYS_GENERIC_BOARD. Without this patch it shows on boot: No valid FDT found - please append one to U-Boot binary, use u-boot-dtb.bin or define CONFIG_OF_EMBED. For sandbox, use -d <file.dtb> With this patch, it boots again with CONFIG_SYS_GENERIC_BOARD enabled. Signed-off-by: Heiko Schocher <hs@denx.de> Acked-by: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@ti.com>
Showing 4 changed files with 41 additions and 36 deletions Side-by-side Diff
lib/Makefile
... | ... | @@ -23,6 +23,8 @@ |
23 | 23 | obj-y += crc7.o |
24 | 24 | obj-y += crc8.o |
25 | 25 | obj-y += crc16.o |
26 | +obj-$(CONFIG_FIT) += fdtdec_common.o | |
27 | +obj-$(CONFIG_OF_CONTROL) += fdtdec_common.o | |
26 | 28 | obj-$(CONFIG_OF_CONTROL) += fdtdec.o |
27 | 29 | obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o |
28 | 30 | obj-$(CONFIG_GZIP) += gunzip.o |
lib/fdtdec.c
... | ... | @@ -111,24 +111,6 @@ |
111 | 111 | return fdtdec_get_addr_size(blob, node, prop_name, NULL); |
112 | 112 | } |
113 | 113 | |
114 | -s32 fdtdec_get_int(const void *blob, int node, const char *prop_name, | |
115 | - s32 default_val) | |
116 | -{ | |
117 | - const s32 *cell; | |
118 | - int len; | |
119 | - | |
120 | - debug("%s: %s: ", __func__, prop_name); | |
121 | - cell = fdt_getprop(blob, node, prop_name, &len); | |
122 | - if (cell && len >= sizeof(s32)) { | |
123 | - s32 val = fdt32_to_cpu(cell[0]); | |
124 | - | |
125 | - debug("%#x (%d)\n", val, val); | |
126 | - return val; | |
127 | - } | |
128 | - debug("(not found)\n"); | |
129 | - return default_val; | |
130 | -} | |
131 | - | |
132 | 114 | uint64_t fdtdec_get_uint64(const void *blob, int node, const char *prop_name, |
133 | 115 | uint64_t default_val) |
134 | 116 | { |
... | ... | @@ -647,24 +629,6 @@ |
647 | 629 | entry->length = reg[1]; |
648 | 630 | |
649 | 631 | return 0; |
650 | -} | |
651 | -#else | |
652 | -#include "libfdt.h" | |
653 | -#include "fdt_support.h" | |
654 | - | |
655 | -int fdtdec_get_int(const void *blob, int node, const char *prop_name, | |
656 | - int default_val) | |
657 | -{ | |
658 | - const int *cell; | |
659 | - int len; | |
660 | - | |
661 | - cell = fdt_getprop_w((void *)blob, node, prop_name, &len); | |
662 | - if (cell && len >= sizeof(int)) { | |
663 | - int val = fdt32_to_cpu(cell[0]); | |
664 | - | |
665 | - return val; | |
666 | - } | |
667 | - return default_val; | |
668 | 632 | } |
669 | 633 | #endif |
lib/fdtdec_common.c
1 | +/* | |
2 | + * Copyright (c) 2014 | |
3 | + * Heiko Schocher, DENX Software Engineering, hs@denx.de. | |
4 | + * | |
5 | + * Based on lib/fdtdec.c: | |
6 | + * Copyright (c) 2011 The Chromium OS Authors. | |
7 | + * | |
8 | + * SPDX-License-Identifier: GPL-2.0+ | |
9 | + */ | |
10 | + | |
11 | +#ifndef USE_HOSTCC | |
12 | +#include <common.h> | |
13 | +#include <libfdt.h> | |
14 | +#include <fdtdec.h> | |
15 | +#else | |
16 | +#include "libfdt.h" | |
17 | +#include "fdt_support.h" | |
18 | + | |
19 | +#define debug(...) | |
20 | +#endif | |
21 | + | |
22 | +int fdtdec_get_int(const void *blob, int node, const char *prop_name, | |
23 | + int default_val) | |
24 | +{ | |
25 | + const int *cell; | |
26 | + int len; | |
27 | + | |
28 | + debug("%s: %s: ", __func__, prop_name); | |
29 | + cell = fdt_getprop(blob, node, prop_name, &len); | |
30 | + if (cell && len >= sizeof(int)) { | |
31 | + int val = fdt32_to_cpu(cell[0]); | |
32 | + | |
33 | + debug("%#x (%d)\n", val, val); | |
34 | + return val; | |
35 | + } | |
36 | + debug("(not found)\n"); | |
37 | + return default_val; | |
38 | +} |