memblock/sparc: Use new accessors
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 4 Aug 2010 03:43:31 +0000 (13:43 +1000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 4 Aug 2010 04:39:00 +0000 (14:39 +1000)
CC: David S. Miller <davem@davemloft.net>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/sparc/mm/init_64.c

index 16d8bee889ba0762c2636dbb2d9cf0b4ee08a94d..dd68025ecdbe5236407ca1048d524c9923a47966 100644 (file)
@@ -972,13 +972,13 @@ int of_node_to_nid(struct device_node *dp)
 
 static void __init add_node_ranges(void)
 {
-       int i;
+       struct memblock_region *reg;
 
-       for (i = 0; i < memblock.memory.cnt; i++) {
-               unsigned long size = memblock_size_bytes(&memblock.memory, i);
+       for_each_memblock(memory, reg) {
+               unsigned long size = reg->size;
                unsigned long start, end;
 
-               start = memblock.memory.regions[i].base;
+               start = reg->base;
                end = start + size;
                while (start < end) {
                        unsigned long this_end;
@@ -1281,7 +1281,7 @@ static void __init bootmem_init_nonnuma(void)
 {
        unsigned long top_of_ram = memblock_end_of_DRAM();
        unsigned long total_ram = memblock_phys_mem_size();
-       unsigned int i;
+       struct memblock_region *reg;
 
        numadbg("bootmem_init_nonnuma()\n");
 
@@ -1292,15 +1292,14 @@ static void __init bootmem_init_nonnuma(void)
 
        init_node_masks_nonnuma();
 
-       for (i = 0; i < memblock.memory.cnt; i++) {
-               unsigned long size = memblock_size_bytes(&memblock.memory, i);
+       for_each_memblock(memory, reg) {
                unsigned long start_pfn, end_pfn;
 
-               if (!size)
+               if (!reg->size)
                        continue;
 
-               start_pfn = memblock.memory.regions[i].base >> PAGE_SHIFT;
-               end_pfn = start_pfn + memblock_size_pages(&memblock.memory, i);
+               start_pfn = memblock_region_base_pfn(reg);
+               end_pfn = memblock_region_end_pfn(reg);
                add_active_range(0, start_pfn, end_pfn);
        }
 
@@ -1334,17 +1333,12 @@ static void __init reserve_range_in_node(int nid, unsigned long start,
 
 static void __init trim_reserved_in_node(int nid)
 {
-       int i;
+       struct memblock_region *reg;
 
        numadbg("  trim_reserved_in_node(%d)\n", nid);
 
-       for (i = 0; i < memblock.reserved.cnt; i++) {
-               unsigned long start = memblock.reserved.regions[i].base;
-               unsigned long size = memblock_size_bytes(&memblock.reserved, i);
-               unsigned long end = start + size;
-
-               reserve_range_in_node(nid, start, end);
-       }
+       for_each_memblock(reserved, reg)
+               reserve_range_in_node(nid, reg->base, reg->base + reg->size);
 }
 
 static void __init bootmem_init_one_node(int nid)