public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] fdt_support: Use VLA instead of MEMORY_BANKS_MAX
@ 2018-08-12 20:37 Ramon Fried
  2018-08-13  7:20 ` Peter Robinson
  0 siblings, 1 reply; 11+ messages in thread
From: Ramon Fried @ 2018-08-12 20:37 UTC (permalink / raw)
  To: u-boot

From: Ramon Fried <ramon.fried@intel.com>

Instead of relaying on user to configure MEMORY_BANKS_MAX
correctly, use VLA (variable length array) to accommodate the
required banks.

Fixes: 2a1f4f1758b5 ("Revert "fdt_support: Use CONFIG_NR_DRAM_BANKS if
defined"")

Signed-off-by: Ramon Fried <ramon.fried@intel.com>
---
 common/fdt_support.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 34d2bd5..e898236 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -409,19 +409,14 @@ static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size,
 	return p - (char *)buf;
 }
 
-#define MEMORY_BANKS_MAX 4
 int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks)
 {
 	int err, nodeoffset;
 	int len, i;
-	u8 tmp[MEMORY_BANKS_MAX * 16]; /* Up to 64-bit address + 64-bit size */
+	u8 tmp[banks * 16]; /* Up to 64-bit address + 64-bit size */
 
-	if (banks > MEMORY_BANKS_MAX) {
-		printf("%s: num banks %d exceeds hardcoded limit %d."
-		       " Recompile with higher MEMORY_BANKS_MAX?\n",
-		       __FUNCTION__, banks, MEMORY_BANKS_MAX);
+	if (!banks)
 		return -1;
-	}
 
 	err = fdt_check_header(blob);
 	if (err < 0) {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-08-13 19:55 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-12 20:37 [U-Boot] [PATCH] fdt_support: Use VLA instead of MEMORY_BANKS_MAX Ramon Fried
2018-08-13  7:20 ` Peter Robinson
2018-08-13 14:52   ` Tom Rini
2018-08-13 18:54     ` Ramon Fried
2018-08-13 16:08       ` Tom Rini
2018-08-13 16:14         ` Ramon Fried
2018-08-13 16:15           ` Tom Rini
2018-08-13 16:22             ` Ramon Fried
2018-08-13 19:55               ` Ramon Fried
2018-08-13 16:59                 ` Tom Rini
2018-08-13 17:19                   ` Ramon Fried

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox