aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/memblock.h7
-rw-r--r--mm/memblock.c10
2 files changed, 13 insertions, 4 deletions
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index c9c7b0f344a5..150be938b910 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -18,7 +18,7 @@
18 18
19#include <asm/memblock.h> 19#include <asm/memblock.h>
20 20
21#define MAX_MEMBLOCK_REGIONS 128 21#define INIT_MEMBLOCK_REGIONS 128
22 22
23struct memblock_region { 23struct memblock_region {
24 phys_addr_t base; 24 phys_addr_t base;
@@ -26,8 +26,9 @@ struct memblock_region {
26}; 26};
27 27
28struct memblock_type { 28struct memblock_type {
29 unsigned long cnt; 29 unsigned long cnt; /* number of regions */
30 struct memblock_region regions[MAX_MEMBLOCK_REGIONS+1]; 30 unsigned long max; /* size of the allocated array */
31 struct memblock_region *regions;
31}; 32};
32 33
33struct memblock { 34struct memblock {
diff --git a/mm/memblock.c b/mm/memblock.c
index 5ae413e9afd8..3c474502d92b 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -18,6 +18,8 @@
18struct memblock memblock; 18struct memblock memblock;
19 19
20static int memblock_debug; 20static int memblock_debug;
21static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS + 1];
22static struct memblock_region memblock_reserved_init_regions[INIT_MEMBLOCK_REGIONS + 1];
21 23
22static int __init early_memblock(char *p) 24static int __init early_memblock(char *p)
23{ 25{
@@ -104,6 +106,12 @@ static void memblock_coalesce_regions(struct memblock_type *type,
104 106
105void __init memblock_init(void) 107void __init memblock_init(void)
106{ 108{
109 /* Hookup the initial arrays */
110 memblock.memory.regions = memblock_memory_init_regions;
111 memblock.memory.max = INIT_MEMBLOCK_REGIONS;
112 memblock.reserved.regions = memblock_reserved_init_regions;
113 memblock.reserved.max = INIT_MEMBLOCK_REGIONS;
114
107 /* Create a dummy zero size MEMBLOCK which will get coalesced away later. 115 /* Create a dummy zero size MEMBLOCK which will get coalesced away later.
108 * This simplifies the memblock_add() code below... 116 * This simplifies the memblock_add() code below...
109 */ 117 */
@@ -169,7 +177,7 @@ static long memblock_add_region(struct memblock_type *type, phys_addr_t base, ph
169 177
170 if (coalesced) 178 if (coalesced)
171 return coalesced; 179 return coalesced;
172 if (type->cnt >= MAX_MEMBLOCK_REGIONS) 180 if (type->cnt >= type->max)
173 return -1; 181 return -1;
174 182
175 /* Couldn't coalesce the MEMBLOCK, so add it to the sorted table. */ 183 /* Couldn't coalesce the MEMBLOCK, so add it to the sorted table. */