memblock: use for_each_memblock()

This is a small cleanup.

Signed-off-by: Emil Medve <Emilian.Medve@Freescale.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Emil Medve 2014-04-07 15:37:52 -07:00 committed by Linus Torvalds
parent ed6d7c8e57
commit 136199f0a6
2 changed files with 16 additions and 18 deletions

View File

@ -1271,16 +1271,14 @@ phys_addr_t __init_memblock memblock_end_of_DRAM(void)
void __init memblock_enforce_memory_limit(phys_addr_t limit) void __init memblock_enforce_memory_limit(phys_addr_t limit)
{ {
unsigned long i;
phys_addr_t max_addr = (phys_addr_t)ULLONG_MAX; phys_addr_t max_addr = (phys_addr_t)ULLONG_MAX;
struct memblock_region *r;
if (!limit) if (!limit)
return; return;
/* find out max address */ /* find out max address */
for (i = 0; i < memblock.memory.cnt; i++) { for_each_memblock(memory, r) {
struct memblock_region *r = &memblock.memory.regions[i];
if (limit <= r->size) { if (limit <= r->size) {
max_addr = r->base + limit; max_addr = r->base + limit;
break; break;
@ -1379,13 +1377,12 @@ int __init_memblock memblock_is_region_reserved(phys_addr_t base, phys_addr_t si
void __init_memblock memblock_trim_memory(phys_addr_t align) void __init_memblock memblock_trim_memory(phys_addr_t align)
{ {
int i;
phys_addr_t start, end, orig_start, orig_end; phys_addr_t start, end, orig_start, orig_end;
struct memblock_type *mem = &memblock.memory; struct memblock_region *r;
for (i = 0; i < mem->cnt; i++) { for_each_memblock(memory, r) {
orig_start = mem->regions[i].base; orig_start = r->base;
orig_end = mem->regions[i].base + mem->regions[i].size; orig_end = r->base + r->size;
start = round_up(orig_start, align); start = round_up(orig_start, align);
end = round_down(orig_end, align); end = round_down(orig_end, align);
@ -1393,11 +1390,12 @@ void __init_memblock memblock_trim_memory(phys_addr_t align)
continue; continue;
if (start < end) { if (start < end) {
mem->regions[i].base = start; r->base = start;
mem->regions[i].size = end - start; r->size = end - start;
} else { } else {
memblock_remove_region(mem, i); memblock_remove_region(&memblock.memory,
i--; r - memblock.memory.regions);
r--;
} }
} }
} }

View File

@ -5073,7 +5073,7 @@ static void __init find_zone_movable_pfns_for_nodes(void)
nodemask_t saved_node_state = node_states[N_MEMORY]; nodemask_t saved_node_state = node_states[N_MEMORY];
unsigned long totalpages = early_calculate_totalpages(); unsigned long totalpages = early_calculate_totalpages();
int usable_nodes = nodes_weight(node_states[N_MEMORY]); int usable_nodes = nodes_weight(node_states[N_MEMORY]);
struct memblock_type *type = &memblock.memory; struct memblock_region *r;
/* Need to find movable_zone earlier when movable_node is specified. */ /* Need to find movable_zone earlier when movable_node is specified. */
find_usable_zone_for_movable(); find_usable_zone_for_movable();
@ -5083,13 +5083,13 @@ static void __init find_zone_movable_pfns_for_nodes(void)
* options. * options.
*/ */
if (movable_node_is_enabled()) { if (movable_node_is_enabled()) {
for (i = 0; i < type->cnt; i++) { for_each_memblock(memory, r) {
if (!memblock_is_hotpluggable(&type->regions[i])) if (!memblock_is_hotpluggable(r))
continue; continue;
nid = type->regions[i].nid; nid = r->nid;
usable_startpfn = PFN_DOWN(type->regions[i].base); usable_startpfn = PFN_DOWN(r->base);
zone_movable_pfn[nid] = zone_movable_pfn[nid] ? zone_movable_pfn[nid] = zone_movable_pfn[nid] ?
min(usable_startpfn, zone_movable_pfn[nid]) : min(usable_startpfn, zone_movable_pfn[nid]) :
usable_startpfn; usable_startpfn;