From b9fa8456448312e96e993335ecb6407038ad5b03 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sat, 4 Oct 2003 21:02:34 -0700 Subject: [PATCH] [PATCH] Clean up MAX_NR_NODES/NUMNODES/etc. [4/5] From: Matthew Dobson 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 --git a/arch/arm/mm/discontig.c b/arch/arm/mm/discontig.c index 82f972f079116..5d67df4a60733 100644 --- a/arch/arm/mm/discontig.c +++ b/arch/arm/mm/discontig.c @@ -15,7 +15,7 @@ #include #include -#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 --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 90dcf272009cc..5269355e1f78c 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -33,12 +33,6 @@ #include #include -#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, struct node_info *np) { 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, struct node_info *np) * 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_bank(int node, struct meminfo *mi) */ 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 --git a/include/asm-arm/arch-clps711x/memory.h b/include/asm-arm/arch-clps711x/memory.h index efa55531eae26..a116a7fa52327 100644 --- a/include/asm-arm/arch-clps711x/memory.h +++ b/include/asm-arm/arch-clps711x/memory.h @@ -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 --git a/include/asm-arm/arch-sa1100/memory.h b/include/asm-arm/arch-sa1100/memory.h index 6303e6cce320d..076b3a9d41b68 100644 --- a/include/asm-arm/arch-sa1100/memory.h +++ b/include/asm-arm/arch-sa1100/memory.h @@ -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 --git a/include/asm-arm/memory.h b/include/asm-arm/memory.h index 588c47d263389..c6c9fa67479a4 100644 --- a/include/asm-arm/memory.h +++ b/include/asm-arm/memory.h @@ -89,6 +89,9 @@ static inline void *phys_to_virt(unsigned long x) * This is more complex. We have a set of mem_map arrays spread * around in memory. */ +#include +#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(unsigned long x) #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(unsigned long x) */ #define PHYS_TO_NID(addr) PFN_TO_NID((addr) >> PAGE_SHIFT) +#undef NUM_NODES + #endif /* diff --git a/include/asm-arm/numnodes.h b/include/asm-arm/numnodes.h index 4c12812f73dca..609f73b00b6a1 100644 --- a/include/asm-arm/numnodes.h +++ b/include/asm-arm/numnodes.h @@ -10,8 +10,7 @@ #ifndef __ASM_ARM_NUMNODES_H #define __ASM_ARM_NUMNODES_H -#include - -#define MAX_NUMNODES NR_NODES +/* Max 4 Nodes */ +#define NODES_SHIFT 2 #endif -- 2.53.0