59 lines
1.8 KiB
Diff
59 lines
1.8 KiB
Diff
From patchwork Thu Feb 15 18:05:59 2018
|
|
Content-Type: text/plain; charset="utf-8"
|
|
MIME-Version: 1.0
|
|
Content-Transfer-Encoding: 7bit
|
|
Subject: [U-Boot,v2] fdt: Fixup only valid memory banks
|
|
X-Patchwork-Submitter: Thierry Reding <thierry.reding@gmail.com>
|
|
X-Patchwork-Id: 874036
|
|
Message-Id: <20180215180559.27875-1-thierry.reding@gmail.com>
|
|
To: Simon Glass <sjg@chromium.org>
|
|
Cc: u-boot@lists.denx.de, Tom Warren <twarren@nvidia.com>
|
|
Date: Thu, 15 Feb 2018 19:05:59 +0100
|
|
From: Thierry Reding <thierry.reding@gmail.com>
|
|
List-Id: U-Boot discussion <u-boot.lists.denx.de>
|
|
|
|
From: Thierry Reding <treding@nvidia.com>
|
|
|
|
Memory banks with address 0 and size 0 are empty and should not be
|
|
passed to the OS via device tree.
|
|
|
|
Acked-by: Stephen Warren <swarren@nvidia.com>
|
|
Signed-off-by: Thierry Reding <treding@nvidia.com>
|
|
---
|
|
Changes in v2:
|
|
- check whether or not any banks need to be fixed up after filtering out
|
|
invalid ones (Stephen Warren)
|
|
- use braces around multiple-line body of for loop, even if not strictly
|
|
necessary (Stephen Warren)
|
|
---
|
|
common/fdt_support.c | 9 ++++++++-
|
|
1 file changed, 8 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/common/fdt_support.c b/common/fdt_support.c
|
|
index 17623a1728f6..da0c12e9c1bc 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) {
|
|
@@ -447,6 +447,13 @@ 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;
|
|
|