]> git.sur5r.net Git - u-boot/blobdiff - common/fdt_support.c
board_f: Only reserve memory for U-Boot if we're going to relocate
[u-boot] / common / fdt_support.c
index 17623a1728f6982887148d82716d2cf4f8ab4258..812eca8173ba91c2f14cc698600ba1d069a07cf1 100644 (file)
@@ -1,10 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2007
  * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com
  *
  * Copyright 2010-2011 Freescale Semiconductor, Inc.
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -13,7 +12,7 @@
 #include <linux/ctype.h>
 #include <linux/types.h>
 #include <asm/global_data.h>
-#include <libfdt.h>
+#include <linux/libfdt.h>
 #include <fdt_support.h>
 #include <exports.h>
 #include <fdtdec.h>
@@ -418,7 +417,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) {
@@ -447,9 +446,22 @@ int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks)
                return err;
        }
 
+       for (i = 0; i < banks; i++) {
+               if (start[i] == 0 && size[i] == 0)
+                       break;
+       }
+
+       banks = i;
+
        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);