aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2008-09-30 14:29:25 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-09-30 16:34:15 -0400
commiteca73214c9c50e290b8dc823b41730b01788872d (patch)
tree22df16b626afa6fb9755ce289c6efa254f1ae3d4 /arch/arm
parentda46c79a5418dd6ba006665c1535af0713bb77b9 (diff)
[ARM] mm: move validation of membanks to one place
The newly introduced sanity_check_meminfo() function should be used to collect all validation of the meminfo array, which we have in bootmem_init(). Move it there. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mm/init.c9
-rw-r--r--arch/arm/mm/mmu.c8
-rw-r--r--arch/arm/mm/nommu.c14
3 files changed, 19 insertions, 12 deletions
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 80584bd7f03e..ffff901cf627 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -333,14 +333,7 @@ bootmem_init_node(int node, int initrd_node, struct meminfo *mi)
333void __init bootmem_init(struct meminfo *mi) 333void __init bootmem_init(struct meminfo *mi)
334{ 334{
335 unsigned long memend_pfn = 0; 335 unsigned long memend_pfn = 0;
336 int node, initrd_node, i; 336 int node, initrd_node;
337
338 /*
339 * Invalidate the node number for empty or invalid memory banks
340 */
341 for (i = 0; i < mi->nr_banks; i++)
342 if (mi->bank[i].size == 0 || mi->bank[i].node >= MAX_NUMNODES)
343 mi->bank[i].node = -1;
344 337
345 memcpy(&meminfo, mi, sizeof(meminfo)); 338 memcpy(&meminfo, mi, sizeof(meminfo));
346 339
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 94d81a2ba008..f03ad87f6baa 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -569,9 +569,10 @@ void __init iotable_init(struct map_desc *io_desc, int nr)
569static int __init check_membank_valid(struct membank *mb) 569static int __init check_membank_valid(struct membank *mb)
570{ 570{
571 /* 571 /*
572 * Check whether this memory region has non-zero size. 572 * Check whether this memory region has non-zero size or
573 * invalid node number.
573 */ 574 */
574 if (mb->size == 0) 575 if (mb->size == 0 || mb->node >= MAX_NUMNODES)
575 return 0; 576 return 0;
576 577
577 /* 578 /*
@@ -605,8 +606,7 @@ static int __init check_membank_valid(struct membank *mb)
605 606
606static void __init sanity_check_meminfo(struct meminfo *mi) 607static void __init sanity_check_meminfo(struct meminfo *mi)
607{ 608{
608 int i; 609 int i, j;
609 int j;
610 610
611 for (i = 0, j = 0; i < mi->nr_banks; i++) { 611 for (i = 0, j = 0; i < mi->nr_banks; i++) {
612 if (check_membank_valid(&mi->bank[i])) 612 if (check_membank_valid(&mi->bank[i]))
diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c
index 81a3000973b4..07b62b238979 100644
--- a/arch/arm/mm/nommu.c
+++ b/arch/arm/mm/nommu.c
@@ -41,12 +41,26 @@ void __init reserve_node_zero(pg_data_t *pgdat)
41 BOOTMEM_DEFAULT); 41 BOOTMEM_DEFAULT);
42} 42}
43 43
44static void __init sanity_check_meminfo(struct meminfo *mi)
45{
46 int i, j;
47
48 for (i = 0, j = 0; i < mi->nr_banks; i++) {
49 struct membank *mb = &mi->bank[i];
50
51 if (mb->size != 0 && mb->node < MAX_NUMNODES)
52 mi->bank[j++] = mi->bank[i];
53 }
54 mi->nr_banks = j;
55}
56
44/* 57/*
45 * paging_init() sets up the page tables, initialises the zone memory 58 * paging_init() sets up the page tables, initialises the zone memory
46 * maps, and sets up the zero page, bad page and bad page tables. 59 * maps, and sets up the zero page, bad page and bad page tables.
47 */ 60 */
48void __init paging_init(struct meminfo *mi, struct machine_desc *mdesc) 61void __init paging_init(struct meminfo *mi, struct machine_desc *mdesc)
49{ 62{
63 sanity_check_meminfo(mi);
50 bootmem_init(mi); 64 bootmem_init(mi);
51} 65}
52 66