Commit 66e8b438 authored by Gioh Kim's avatar Gioh Kim Committed by Linus Torvalds

mm/memblock.c: make the index explicit argument of for_each_memblock_type

for_each_memblock_type macro function relies on idx variable defined in
the caller context.  Silent macro arguments are almost always wrong
thing to do.  They make code harder to read and easier to get wrong.
Let's use an explicit iterator parameter for for_each_memblock_type and
make the code more obious.  This patch is a mere cleanup and it
shouldn't introduce any functional change.

Link: http://lkml.kernel.org/r/20170913133029.28911-1-gi-oh.kim@profitbricks.comSigned-off-by: default avatarGioh Kim <gi-oh.kim@profitbricks.com>
Acked-by: default avatarMichal Hocko <mhocko@suse.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ecde0f3e
...@@ -389,10 +389,10 @@ static inline unsigned long memblock_region_reserved_end_pfn(const struct memblo ...@@ -389,10 +389,10 @@ static inline unsigned long memblock_region_reserved_end_pfn(const struct memblo
region < (memblock.memblock_type.regions + memblock.memblock_type.cnt); \ region < (memblock.memblock_type.regions + memblock.memblock_type.cnt); \
region++) region++)
#define for_each_memblock_type(memblock_type, rgn) \ #define for_each_memblock_type(i, memblock_type, rgn) \
for (idx = 0, rgn = &memblock_type->regions[0]; \ for (i = 0, rgn = &memblock_type->regions[0]; \
idx < memblock_type->cnt; \ i < memblock_type->cnt; \
idx++, rgn = &memblock_type->regions[idx]) i++, rgn = &memblock_type->regions[i])
#ifdef CONFIG_MEMTEST #ifdef CONFIG_MEMTEST
extern void early_memtest(phys_addr_t start, phys_addr_t end); extern void early_memtest(phys_addr_t start, phys_addr_t end);
......
...@@ -533,7 +533,7 @@ int __init_memblock memblock_add_range(struct memblock_type *type, ...@@ -533,7 +533,7 @@ int __init_memblock memblock_add_range(struct memblock_type *type,
base = obase; base = obase;
nr_new = 0; nr_new = 0;
for_each_memblock_type(type, rgn) { for_each_memblock_type(idx, type, rgn) {
phys_addr_t rbase = rgn->base; phys_addr_t rbase = rgn->base;
phys_addr_t rend = rbase + rgn->size; phys_addr_t rend = rbase + rgn->size;
...@@ -637,7 +637,7 @@ static int __init_memblock memblock_isolate_range(struct memblock_type *type, ...@@ -637,7 +637,7 @@ static int __init_memblock memblock_isolate_range(struct memblock_type *type,
if (memblock_double_array(type, base, size) < 0) if (memblock_double_array(type, base, size) < 0)
return -ENOMEM; return -ENOMEM;
for_each_memblock_type(type, rgn) { for_each_memblock_type(idx, type, rgn) {
phys_addr_t rbase = rgn->base; phys_addr_t rbase = rgn->base;
phys_addr_t rend = rbase + rgn->size; phys_addr_t rend = rbase + rgn->size;
...@@ -1715,7 +1715,7 @@ static void __init_memblock memblock_dump(struct memblock_type *type) ...@@ -1715,7 +1715,7 @@ static void __init_memblock memblock_dump(struct memblock_type *type)
pr_info(" %s.cnt = 0x%lx\n", type->name, type->cnt); pr_info(" %s.cnt = 0x%lx\n", type->name, type->cnt);
for_each_memblock_type(type, rgn) { for_each_memblock_type(idx, type, rgn) {
char nid_buf[32] = ""; char nid_buf[32] = "";
base = rgn->base; base = rgn->base;
...@@ -1739,7 +1739,7 @@ memblock_reserved_memory_within(phys_addr_t start_addr, phys_addr_t end_addr) ...@@ -1739,7 +1739,7 @@ memblock_reserved_memory_within(phys_addr_t start_addr, phys_addr_t end_addr)
unsigned long size = 0; unsigned long size = 0;
int idx; int idx;
for_each_memblock_type((&memblock.reserved), rgn) { for_each_memblock_type(idx, (&memblock.reserved), rgn) {
phys_addr_t start, end; phys_addr_t start, end;
if (rgn->base + rgn->size < start_addr) if (rgn->base + rgn->size < start_addr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment