summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2018-01-30 11:34:17 +0100
committerSimon Glass <sjg@chromium.org>2018-02-18 12:53:38 -0700
commit6d29cc7dcf2d35966aa0b6119fd1cbca0d21d5e6 (patch)
tree975964f8f78831085d7f597493d3aea645e19ea5
parent4280342adb2d72d6242ec1ffbb723af380b31586 (diff)
fdt: Fixup only valid memory banks
Memory banks with address 0 and size 0 are empty and should not be passed to the OS via device tree. Signed-off-by: Thierry Reding <treding@nvidia.com> Acked-by: Stephen Warren <swarren@nvidia.com>
-rw-r--r--common/fdt_support.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 17623a1728..bd0478de40 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -418,7 +418,7 @@ static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size,
int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks)
{
int err, nodeoffset;
- int len;
+ int len, i;
u8 tmp[MEMORY_BANKS_MAX * 16]; /* Up to 64-bit address + 64-bit size */
if (banks > MEMORY_BANKS_MAX) {
@@ -450,6 +450,12 @@ int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks)
if (!banks)
return 0;
+ for (i = 0; i < banks; i++)
+ if (start[i] == 0 && size[i] == 0)
+ break;
+
+ banks = i;
+
len = fdt_pack_reg(blob, tmp, start, size, banks);
err = fdt_setprop(blob, nodeoffset, "reg", tmp, len);