
From: Dave Hansen <haveblue@us.ibm.com>
I think this makes the nonlinear initialization code a bit easier to read.
It's probably a tad slower, but it's init code, so it doesn't really matter.

Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
---

 memhotplug-dave/mm/nonlinear.c |   47 +++++++++++++++++------------------------
 1 files changed, 20 insertions(+), 27 deletions(-)

diff -puN mm/nonlinear.c~C2-nonlinear-init_cleanup mm/nonlinear.c
--- memhotplug/mm/nonlinear.c~C2-nonlinear-init_cleanup	2004-11-12 16:51:43.000000000 -0800
+++ memhotplug-dave/mm/nonlinear.c	2004-11-12 16:51:43.000000000 -0800
@@ -31,17 +31,14 @@ unsigned short phys_section[NR_PHYS_SECT
 void
 setup_memsections(void)
 {
-	int	index;
-	struct mem_section *ms;
-	unsigned short *ps;
-
-	for (index = 0, ms = mem_section; index < NR_SECTIONS; index++, ms++) {
-		ms->phys_section = INVALID_SECTION;
-		ms->mem_map = NULL;
-	}
-	for (index = 0, ps = phys_section; index < NR_PHYS_SECTIONS; index++, ps++) {
-		*ps = INVALID_PHYS_SECTION;
+	int index;
+
+	for (index = 0; index < NR_SECTIONS; index++) {
+		mem_section[index].phys_section = INVALID_SECTION;
+		mem_section[index].mem_map = NULL;
 	}
+	for (index = 0; index < NR_PHYS_SECTIONS; index++)
+		phys_section[index] = INVALID_PHYS_SECTION;
 }
 
 void
@@ -53,38 +50,34 @@ alloc_memsections(unsigned long start_pf
 	unsigned int physid;
 	unsigned int sect_count;
 	unsigned short sect_index;
-	struct mem_section *ms;
-	unsigned short *ps;
 
 	sect_count = pfn_to_section_roundup(pfn_count);
 	sect_index = index = pfn_to_section(start_pfn);
 	limit = index + sect_count;
-	ms = &mem_section[index];
 	physid = pfn_to_section(start_phys_pfn);
-	for (; index < limit; index++, ms++, physid++) {
-		ms->phys_section = physid;
-	}
+	for (; index < limit; index++, physid++)
+		mem_section[index].phys_section = physid;
 
 	index = pfn_to_section(start_phys_pfn);
 	limit = index + sect_count;
-	for (ps = &phys_section[index]; index < limit; index++, ps++, sect_index++) {
-		*ps = sect_index;
-	}
+	for (; index < limit; index++, sect_index++)
+		phys_section[index] = sect_index;
 }
 
 void
-alloc_memmap(struct page *page, unsigned long start_pfn, unsigned long size)
+alloc_memmap(struct page *mem_map, unsigned long start_pfn, unsigned long size)
 {
-	unsigned int index, limit;
-	struct mem_section *ms;
+	unsigned int section_nr, limit, page_idx;
 
 	size = pfn_to_section_roundup(size);
-	index = pfn_to_section(start_pfn);
-	limit = index + size;
-	ms = &mem_section[index];
-	for (; index < limit; index++, ms++, page += PAGES_PER_SECTION) {
-		ms->mem_map = page;
+	section_nr = pfn_to_section(start_pfn);
+	limit = section_nr + size;
+	for (; section_nr < limit; section_nr++, mem_map += PAGES_PER_SECTION) {
+		mem_section[section_nr].mem_map = mem_map;
+		for (page_idx = 0; page_idx < PAGES_PER_SECTION; page_idx++)
+			mem_map[page_idx].section = section_nr;
 	}
+
 }
 
 void
_
