Commit 3bf2f15351e9533c9c99ebbdd93cafca30558b0d
Committed by
Simon Glass
1 parent
089ff8eb66
Exists in
smarc_8mq_lf_v2020.04
and in
9 other branches
fdtdec: Remove fdt_{addr,size}_unpack()
U-Boot already defines the {upper,lower}_32_bits() macros that have the same purpose. Use the existing macros instead of defining new APIs. Signed-off-by: Thierry Reding <treding@nvidia.com>
Showing 3 changed files with 12 additions and 28 deletions Side-by-side Diff
include/fdtdec.h
... | ... | @@ -24,30 +24,6 @@ |
24 | 24 | typedef phys_addr_t fdt_addr_t; |
25 | 25 | typedef phys_size_t fdt_size_t; |
26 | 26 | |
27 | -static inline fdt32_t fdt_addr_unpack(fdt_addr_t addr, fdt32_t *upper) | |
28 | -{ | |
29 | - if (upper) | |
30 | -#ifdef CONFIG_PHYS_64BIT | |
31 | - *upper = addr >> 32; | |
32 | -#else | |
33 | - *upper = 0; | |
34 | -#endif | |
35 | - | |
36 | - return addr; | |
37 | -} | |
38 | - | |
39 | -static inline fdt32_t fdt_size_unpack(fdt_size_t size, fdt32_t *upper) | |
40 | -{ | |
41 | - if (upper) | |
42 | -#ifdef CONFIG_PHYS_64BIT | |
43 | - *upper = size >> 32; | |
44 | -#else | |
45 | - *upper = 0; | |
46 | -#endif | |
47 | - | |
48 | - return size; | |
49 | -} | |
50 | - | |
51 | 27 | #ifdef CONFIG_PHYS_64BIT |
52 | 28 | #define FDT_ADDR_T_NONE (-1U) |
53 | 29 | #define fdt_addr_to_cpu(reg) be64_to_cpu(reg) |
lib/fdtdec.c
... | ... | @@ -1300,6 +1300,7 @@ |
1300 | 1300 | fdt32_t cells[4] = {}, *ptr = cells; |
1301 | 1301 | uint32_t upper, lower, phandle; |
1302 | 1302 | int parent, node, na, ns, err; |
1303 | + fdt_size_t size; | |
1303 | 1304 | char name[64]; |
1304 | 1305 | |
1305 | 1306 | /* create an empty /reserved-memory node if one doesn't exist */ |
... | ... | @@ -1340,7 +1341,8 @@ |
1340 | 1341 | * Unpack the start address and generate the name of the new node |
1341 | 1342 | * base on the basename and the unit-address. |
1342 | 1343 | */ |
1343 | - lower = fdt_addr_unpack(carveout->start, &upper); | |
1344 | + upper = upper_32_bits(carveout->start); | |
1345 | + lower = lower_32_bits(carveout->start); | |
1344 | 1346 | |
1345 | 1347 | if (na > 1 && upper > 0) |
1346 | 1348 | snprintf(name, sizeof(name), "%s@%x,%x", basename, upper, |
... | ... | @@ -1374,7 +1376,9 @@ |
1374 | 1376 | *ptr++ = cpu_to_fdt32(lower); |
1375 | 1377 | |
1376 | 1378 | /* store one or two size cells */ |
1377 | - lower = fdt_size_unpack(carveout->end - carveout->start + 1, &upper); | |
1379 | + size = carveout->end - carveout->start + 1; | |
1380 | + upper = upper_32_bits(size); | |
1381 | + lower = lower_32_bits(size); | |
1378 | 1382 | |
1379 | 1383 | if (ns > 1) |
1380 | 1384 | *ptr++ = cpu_to_fdt32(upper); |
lib/fdtdec_test.c
... | ... | @@ -155,11 +155,13 @@ |
155 | 155 | }; |
156 | 156 | fdt32_t cells[4], *ptr = cells; |
157 | 157 | uint32_t upper, lower; |
158 | + fdt_size_t size; | |
158 | 159 | char name[32]; |
159 | 160 | int offset; |
160 | 161 | |
161 | 162 | /* store one or two address cells */ |
162 | - lower = fdt_addr_unpack(carveout.start, &upper); | |
163 | + upper = upper_32_bits(carveout.start); | |
164 | + lower = lower_32_bits(carveout.start); | |
163 | 165 | |
164 | 166 | if (na > 1 && upper > 0) |
165 | 167 | snprintf(name, sizeof(name), "%s@%x,%x", basename, upper, |
... | ... | @@ -173,7 +175,9 @@ |
173 | 175 | *ptr++ = cpu_to_fdt32(lower); |
174 | 176 | |
175 | 177 | /* store one or two size cells */ |
176 | - lower = fdt_size_unpack(carveout.end - carveout.start + 1, &upper); | |
178 | + size = carveout.end - carveout.start + 1; | |
179 | + upper = upper_32_bits(size); | |
180 | + lower = lower_32_bits(size); | |
177 | 181 | |
178 | 182 | if (ns > 1) |
179 | 183 | *ptr++ = cpu_to_fdt32(upper); |