From: Matthew Dobson <colpatch@us.ibm.com>

Fix up the arm arch.  This needs to be reviewed.  Relatively
straightforward replacement of NR_NODES with standard MAX_NUMNODES.



 arch/arm/mm/discontig.c                |    6 +++---
 arch/arm/mm/init.c                     |   12 +++---------
 include/asm-arm/arch-clps711x/memory.h |    2 --
 include/asm-arm/arch-sa1100/memory.h   |    2 --
 include/asm-arm/memory.h               |    9 +++++++--
 include/asm-arm/numnodes.h             |    5 ++---
 6 files changed, 15 insertions(+), 21 deletions(-)

diff -puN arch/arm/mm/discontig.c~node-enumeration-cleanup-04 arch/arm/mm/discontig.c
--- 25/arch/arm/mm/discontig.c~node-enumeration-cleanup-04	2003-09-16 00:15:51.000000000 -0700
+++ 25-akpm/arch/arm/mm/discontig.c	2003-09-16 00:15:51.000000000 -0700
@@ -15,7 +15,7 @@
 #include <linux/init.h>
 #include <linux/bootmem.h>
 
-#if NR_NODES != 4
+#if MAX_NUMNODES != 4
 #error Fix Me Please
 #endif
 
@@ -23,9 +23,9 @@
  * Our node_data structure for discontiguous memory.
  */
 
-static bootmem_data_t node_bootmem_data[NR_NODES];
+static bootmem_data_t node_bootmem_data[MAX_NUMNODES];
 
-pg_data_t discontig_node_data[NR_NODES] = {
+pg_data_t discontig_node_data[MAX_NUMNODES] = {
   { .bdata = &node_bootmem_data[0] },
   { .bdata = &node_bootmem_data[1] },
   { .bdata = &node_bootmem_data[2] },
diff -puN arch/arm/mm/init.c~node-enumeration-cleanup-04 arch/arm/mm/init.c
--- 25/arch/arm/mm/init.c~node-enumeration-cleanup-04	2003-09-16 00:15:51.000000000 -0700
+++ 25-akpm/arch/arm/mm/init.c	2003-09-16 00:15:51.000000000 -0700
@@ -33,12 +33,6 @@
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 
-#ifndef CONFIG_DISCONTIGMEM
-#define NR_NODES	1
-#else
-#define NR_NODES	4
-#endif
-
 #ifdef CONFIG_CPU_32
 #define TABLE_OFFSET	(PTRS_PER_PTE)
 #else
@@ -178,7 +172,7 @@ find_memend_and_nodes(struct meminfo *mi
 {
 	unsigned int i, bootmem_pages = 0, memend_pfn = 0;
 
-	for (i = 0; i < NR_NODES; i++) {
+	for (i = 0; i < MAX_NUMNODES; i++) {
 		np[i].start = -1U;
 		np[i].end = 0;
 		np[i].bootmap_pages = 0;
@@ -207,7 +201,7 @@ find_memend_and_nodes(struct meminfo *mi
 			 * we have, we're in trouble.  (maybe we ought to
 			 * limit, instead of bugging?)
 			 */
-			if (numnodes > NR_NODES)
+			if (numnodes > MAX_NUMNODES)
 				BUG();
 		}
 
@@ -365,7 +359,7 @@ static inline void free_bootmem_node_ban
  */
 void __init bootmem_init(struct meminfo *mi)
 {
-	struct node_info node_info[NR_NODES], *np = node_info;
+	struct node_info node_info[MAX_NUMNODES], *np = node_info;
 	unsigned int bootmap_pages, bootmap_pfn, map_pg;
 	int node, initrd_node;
 
diff -puN include/asm-arm/arch-clps711x/memory.h~node-enumeration-cleanup-04 include/asm-arm/arch-clps711x/memory.h
--- 25/include/asm-arm/arch-clps711x/memory.h~node-enumeration-cleanup-04	2003-09-16 00:15:51.000000000 -0700
+++ 25-akpm/include/asm-arm/arch-clps711x/memory.h	2003-09-16 00:15:51.000000000 -0700
@@ -109,8 +109,6 @@
  * 	node 3:  0xd8000000 - 0xdfffffff
  */
 
-#define NR_NODES	4
-
 /*
  * Given a kernel address, find the home node of the underlying memory.
  */
diff -puN include/asm-arm/arch-sa1100/memory.h~node-enumeration-cleanup-04 include/asm-arm/arch-sa1100/memory.h
--- 25/include/asm-arm/arch-sa1100/memory.h~node-enumeration-cleanup-04	2003-09-16 00:15:51.000000000 -0700
+++ 25-akpm/include/asm-arm/arch-sa1100/memory.h	2003-09-16 00:15:51.000000000 -0700
@@ -74,8 +74,6 @@
  * 	node 3:  0xd8000000 - 0xdfffffff
  */
 
-#define NR_NODES	4
-
 /*
  * Given a kernel address, find the home node of the underlying memory.
  */
diff -puN include/asm-arm/memory.h~node-enumeration-cleanup-04 include/asm-arm/memory.h
--- 25/include/asm-arm/memory.h~node-enumeration-cleanup-04	2003-09-16 00:15:51.000000000 -0700
+++ 25-akpm/include/asm-arm/memory.h	2003-09-16 00:15:51.000000000 -0700
@@ -89,6 +89,9 @@ static inline void *phys_to_virt(unsigne
  * This is more complex.  We have a set of mem_map arrays spread
  * around in memory.
  */
+#include <asm/numnodes.h>
+#define NUM_NODES	(1 << NODES_SHIFT)
+
 #define page_to_pfn(page)					\
 	(( (page) - page_zone(page)->zone_mem_map)		\
 	  + page_zone(page)->zone_start_pfn)
@@ -96,12 +99,12 @@ static inline void *phys_to_virt(unsigne
 #define pfn_to_page(pfn)					\
 	(PFN_TO_MAPBASE(pfn) + LOCAL_MAP_NR((pfn) << PAGE_SHIFT))
 
-#define pfn_valid(pfn)		(PFN_TO_NID(pfn) < NR_NODES)
+#define pfn_valid(pfn)		(PFN_TO_NID(pfn) < NUM_NODES)
 
 #define virt_to_page(kaddr)					\
 	(ADDR_TO_MAPBASE(kaddr) + LOCAL_MAP_NR(kaddr))
 
-#define virt_addr_valid(kaddr)	(KVADDR_TO_NID(kaddr) < NR_NODES)
+#define virt_addr_valid(kaddr)	(KVADDR_TO_NID(kaddr) < NUM_NODES)
 
 /*
  * Common discontigmem stuff.
@@ -109,6 +112,8 @@ static inline void *phys_to_virt(unsigne
  */
 #define PHYS_TO_NID(addr)	PFN_TO_NID((addr) >> PAGE_SHIFT)
 
+#undef NUM_NODES
+
 #endif
 
 /*
diff -puN include/asm-arm/numnodes.h~node-enumeration-cleanup-04 include/asm-arm/numnodes.h
--- 25/include/asm-arm/numnodes.h~node-enumeration-cleanup-04	2003-09-16 00:15:51.000000000 -0700
+++ 25-akpm/include/asm-arm/numnodes.h	2003-09-16 00:15:51.000000000 -0700
@@ -10,8 +10,7 @@
 #ifndef __ASM_ARM_NUMNODES_H
 #define __ASM_ARM_NUMNODES_H
 
-#include <asm/memory.h>
-
-#define MAX_NUMNODES	NR_NODES
+/* Max 4 Nodes */
+#define NODES_SHIFT	2
 
 #endif

_