Commit 11199692d83dd3fe1511203024fb9853d176ec4c
Committed by
Linus Torvalds
1 parent
dcf6b7ddd7
Exists in
master
and in
20 other branches
mm: change signature of free_reserved_area() to fix building warnings
Change signature of free_reserved_area() according to Russell King's suggestion to fix following build warnings: arch/arm/mm/init.c: In function 'mem_init': arch/arm/mm/init.c:603:2: warning: passing argument 1 of 'free_reserved_area' makes integer from pointer without a cast [enabled by default] free_reserved_area(__va(PHYS_PFN_OFFSET), swapper_pg_dir, 0, NULL); ^ In file included from include/linux/mman.h:4:0, from arch/arm/mm/init.c:15: include/linux/mm.h:1301:22: note: expected 'long unsigned int' but argument is of type 'void *' extern unsigned long free_reserved_area(unsigned long start, unsigned long end, mm/page_alloc.c: In function 'free_reserved_area': >> mm/page_alloc.c:5134:3: warning: passing argument 1 of 'virt_to_phys' makes pointer from integer without a cast [enabled by default] In file included from arch/mips/include/asm/page.h:49:0, from include/linux/mmzone.h:20, from include/linux/gfp.h:4, from include/linux/mm.h:8, from mm/page_alloc.c:18: arch/mips/include/asm/io.h:119:29: note: expected 'const volatile void *' but argument is of type 'long unsigned int' mm/page_alloc.c: In function 'free_area_init_nodes': mm/page_alloc.c:5030:34: warning: array subscript is below array bounds [-Warray-bounds] Also address some minor code review comments. Signed-off-by: Jiang Liu <jiang.liu@huawei.com> Reported-by: Arnd Bergmann <arnd@arndb.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: <sworddragon2@aol.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Chris Metcalf <cmetcalf@tilera.com> Cc: David Howells <dhowells@redhat.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jeremy Fitzhardinge <jeremy@goop.org> Cc: Jianguo Wu <wujianguo@huawei.com> Cc: Joonsoo Kim <js1304@gmail.com> Cc: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: Marek Szyprowski <m.szyprowski@samsung.com> Cc: Mel Gorman <mel@csn.ul.ie> Cc: Michel Lespinasse <walken@google.com> Cc: Minchan Kim <minchan@kernel.org> Cc: Rik van Riel <riel@redhat.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Tang Chen <tangchen@cn.fujitsu.com> Cc: Tejun Heo <tj@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Wen Congyang <wency@cn.fujitsu.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com> Cc: Yinghai Lu <yinghai@kernel.org> Cc: Russell King <rmk@arm.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 31 changed files with 50 additions and 45 deletions Side-by-side Diff
- arch/alpha/kernel/sys_nautilus.c
- arch/alpha/mm/init.c
- arch/arc/mm/init.c
- arch/arm/mm/init.c
- arch/arm64/mm/init.c
- arch/avr32/mm/init.c
- arch/blackfin/mm/init.c
- arch/c6x/mm/init.c
- arch/frv/mm/init.c
- arch/h8300/mm/init.c
- arch/ia64/mm/init.c
- arch/m32r/mm/init.c
- arch/m68k/mm/init.c
- arch/metag/mm/init.c
- arch/microblaze/mm/init.c
- arch/mips/mm/init.c
- arch/mn10300/mm/init.c
- arch/openrisc/mm/init.c
- arch/parisc/mm/init.c
- arch/powerpc/kernel/kvm.c
- arch/powerpc/mm/mem.c
- arch/s390/mm/init.c
- arch/score/mm/init.c
- arch/sh/mm/init.c
- arch/sparc/mm/init_32.c
- arch/sparc/mm/init_64.c
- arch/um/kernel/mem.c
- arch/unicore32/mm/init.c
- arch/xtensa/mm/init.c
- include/linux/mm.h
- mm/page_alloc.c
arch/alpha/kernel/sys_nautilus.c
... | ... | @@ -238,8 +238,8 @@ |
238 | 238 | if (pci_mem < memtop) |
239 | 239 | memtop = pci_mem; |
240 | 240 | if (memtop > alpha_mv.min_mem_address) { |
241 | - free_reserved_area((unsigned long)__va(alpha_mv.min_mem_address), | |
242 | - (unsigned long)__va(memtop), 0, NULL); | |
241 | + free_reserved_area(__va(alpha_mv.min_mem_address), | |
242 | + __va(memtop), 0, NULL); | |
243 | 243 | printk("nautilus_init_pci: %ldk freed\n", |
244 | 244 | (memtop - alpha_mv.min_mem_address) >> 10); |
245 | 245 | } |
arch/alpha/mm/init.c
arch/arc/mm/init.c
... | ... | @@ -152,7 +152,7 @@ |
152 | 152 | #ifdef CONFIG_BLK_DEV_INITRD |
153 | 153 | void __init free_initrd_mem(unsigned long start, unsigned long end) |
154 | 154 | { |
155 | - free_reserved_area(start, end, 0, "initrd"); | |
155 | + free_reserved_area((void *)start, (void *)end, 0, "initrd"); | |
156 | 156 | } |
157 | 157 | #endif |
158 | 158 |
arch/arm/mm/init.c
arch/arm64/mm/init.c
arch/avr32/mm/init.c
arch/blackfin/mm/init.c
arch/c6x/mm/init.c
arch/frv/mm/init.c
... | ... | @@ -173,7 +173,7 @@ |
173 | 173 | #ifdef CONFIG_BLK_DEV_INITRD |
174 | 174 | void __init free_initrd_mem(unsigned long start, unsigned long end) |
175 | 175 | { |
176 | - free_reserved_area(start, end, 0, "initrd"); | |
176 | + free_reserved_area((void *)start, (void *)end, 0, "initrd"); | |
177 | 177 | } /* end free_initrd_mem() */ |
178 | 178 | #endif |
arch/h8300/mm/init.c
arch/ia64/mm/init.c
... | ... | @@ -154,8 +154,7 @@ |
154 | 154 | void |
155 | 155 | free_initmem (void) |
156 | 156 | { |
157 | - free_reserved_area((unsigned long)ia64_imva(__init_begin), | |
158 | - (unsigned long)ia64_imva(__init_end), | |
157 | + free_reserved_area(ia64_imva(__init_begin), ia64_imva(__init_end), | |
159 | 158 | 0, "unused kernel"); |
160 | 159 | } |
161 | 160 |
arch/m32r/mm/init.c
... | ... | @@ -191,7 +191,7 @@ |
191 | 191 | *======================================================================*/ |
192 | 192 | void free_initrd_mem(unsigned long start, unsigned long end) |
193 | 193 | { |
194 | - free_reserved_area(start, end, 0, "initrd"); | |
194 | + free_reserved_area((void *)start, (void *)end, 0, "initrd"); | |
195 | 195 | } |
196 | 196 | #endif |
arch/m68k/mm/init.c
arch/metag/mm/init.c
... | ... | @@ -414,7 +414,8 @@ |
414 | 414 | #ifdef CONFIG_BLK_DEV_INITRD |
415 | 415 | void free_initrd_mem(unsigned long start, unsigned long end) |
416 | 416 | { |
417 | - free_reserved_area(start, end, POISON_FREE_INITMEM, "initrd"); | |
417 | + free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM, | |
418 | + "initrd"); | |
418 | 419 | } |
419 | 420 | #endif |
420 | 421 |
arch/microblaze/mm/init.c
arch/mips/mm/init.c
... | ... | @@ -440,7 +440,8 @@ |
440 | 440 | #ifdef CONFIG_BLK_DEV_INITRD |
441 | 441 | void free_initrd_mem(unsigned long start, unsigned long end) |
442 | 442 | { |
443 | - free_reserved_area(start, end, POISON_FREE_INITMEM, "initrd"); | |
443 | + free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM, | |
444 | + "initrd"); | |
444 | 445 | } |
445 | 446 | #endif |
446 | 447 |
arch/mn10300/mm/init.c
... | ... | @@ -152,7 +152,8 @@ |
152 | 152 | #ifdef CONFIG_BLK_DEV_INITRD |
153 | 153 | void free_initrd_mem(unsigned long start, unsigned long end) |
154 | 154 | { |
155 | - free_reserved_area(start, end, POISON_FREE_INITMEM, "initrd"); | |
155 | + free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM, | |
156 | + "initrd"); | |
156 | 157 | } |
157 | 158 | #endif |
arch/openrisc/mm/init.c
arch/parisc/mm/init.c
... | ... | @@ -1101,7 +1101,8 @@ |
1101 | 1101 | #ifdef CONFIG_BLK_DEV_INITRD |
1102 | 1102 | void free_initrd_mem(unsigned long start, unsigned long end) |
1103 | 1103 | { |
1104 | - num_physpages += free_reserved_area(start, end, 0, "initrd"); | |
1104 | + num_physpages += free_reserved_area((void *)start, (void *)end, 0, | |
1105 | + "initrd"); | |
1105 | 1106 | } |
1106 | 1107 | #endif |
arch/powerpc/kernel/kvm.c
... | ... | @@ -756,7 +756,7 @@ |
756 | 756 | end = (ulong)&kvm_tmp[ARRAY_SIZE(kvm_tmp)] & PAGE_MASK; |
757 | 757 | |
758 | 758 | /* Free the tmp space we don't need */ |
759 | - free_reserved_area(start, end, 0, NULL); | |
759 | + free_reserved_area((void *)start, (void *)end, 0, NULL); | |
760 | 760 | } |
761 | 761 | |
762 | 762 | static int __init kvm_guest_init(void) |
arch/powerpc/mm/mem.c
... | ... | @@ -407,7 +407,7 @@ |
407 | 407 | #ifdef CONFIG_BLK_DEV_INITRD |
408 | 408 | void __init free_initrd_mem(unsigned long start, unsigned long end) |
409 | 409 | { |
410 | - free_reserved_area(start, end, 0, "initrd"); | |
410 | + free_reserved_area((void *)start, (void *)end, 0, "initrd"); | |
411 | 411 | } |
412 | 412 | #endif |
413 | 413 |
arch/s390/mm/init.c
... | ... | @@ -172,7 +172,8 @@ |
172 | 172 | #ifdef CONFIG_BLK_DEV_INITRD |
173 | 173 | void __init free_initrd_mem(unsigned long start, unsigned long end) |
174 | 174 | { |
175 | - free_reserved_area(start, end, POISON_FREE_INITMEM, "initrd"); | |
175 | + free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM, | |
176 | + "initrd"); | |
176 | 177 | } |
177 | 178 | #endif |
178 | 179 |
arch/score/mm/init.c
... | ... | @@ -108,7 +108,8 @@ |
108 | 108 | #ifdef CONFIG_BLK_DEV_INITRD |
109 | 109 | void free_initrd_mem(unsigned long start, unsigned long end) |
110 | 110 | { |
111 | - free_reserved_area(start, end, POISON_FREE_INITMEM, "initrd"); | |
111 | + free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM, | |
112 | + "initrd"); | |
112 | 113 | } |
113 | 114 | #endif |
114 | 115 |
arch/sh/mm/init.c
arch/sparc/mm/init_32.c
... | ... | @@ -372,8 +372,8 @@ |
372 | 372 | #ifdef CONFIG_BLK_DEV_INITRD |
373 | 373 | void free_initrd_mem(unsigned long start, unsigned long end) |
374 | 374 | { |
375 | - num_physpages += free_reserved_area(start, end, POISON_FREE_INITMEM, | |
376 | - "initrd"); | |
375 | + num_physpages += free_reserved_area((void *)start, (void *)end, | |
376 | + POISON_FREE_INITMEM, "initrd"); | |
377 | 377 | } |
378 | 378 | #endif |
379 | 379 |
arch/sparc/mm/init_64.c
... | ... | @@ -2131,8 +2131,8 @@ |
2131 | 2131 | #ifdef CONFIG_BLK_DEV_INITRD |
2132 | 2132 | void free_initrd_mem(unsigned long start, unsigned long end) |
2133 | 2133 | { |
2134 | - num_physpages += free_reserved_area(start, end, POISON_FREE_INITMEM, | |
2135 | - "initrd"); | |
2134 | + num_physpages += free_reserved_area((void *)start, (void *)end, | |
2135 | + POISON_FREE_INITMEM, "initrd"); | |
2136 | 2136 | } |
2137 | 2137 | #endif |
2138 | 2138 |
arch/um/kernel/mem.c
arch/unicore32/mm/init.c
... | ... | @@ -486,7 +486,7 @@ |
486 | 486 | void free_initrd_mem(unsigned long start, unsigned long end) |
487 | 487 | { |
488 | 488 | if (!keep_initrd) |
489 | - free_reserved_area(start, end, 0, "initrd"); | |
489 | + free_reserved_area((void *)start, (void *)end, 0, "initrd"); | |
490 | 490 | } |
491 | 491 | |
492 | 492 | static int __init keepinitrd_setup(char *__unused) |
arch/xtensa/mm/init.c
include/linux/mm.h
... | ... | @@ -1311,7 +1311,7 @@ |
1311 | 1311 | * "poison" if it's non-zero. |
1312 | 1312 | * Return pages freed into the buddy system. |
1313 | 1313 | */ |
1314 | -extern unsigned long free_reserved_area(unsigned long start, unsigned long end, | |
1314 | +extern unsigned long free_reserved_area(void *start, void *end, | |
1315 | 1315 | int poison, char *s); |
1316 | 1316 | #ifdef CONFIG_HIGHMEM |
1317 | 1317 | /* |
... | ... | @@ -1355,8 +1355,7 @@ |
1355 | 1355 | { |
1356 | 1356 | extern char __init_begin[], __init_end[]; |
1357 | 1357 | |
1358 | - return free_reserved_area(PAGE_ALIGN((unsigned long)&__init_begin) , | |
1359 | - ((unsigned long)&__init_end) & PAGE_MASK, | |
1358 | + return free_reserved_area(&__init_begin, &__init_end, | |
1360 | 1359 | poison, "unused kernel"); |
1361 | 1360 | } |
1362 | 1361 |
mm/page_alloc.c
... | ... | @@ -5206,25 +5206,26 @@ |
5206 | 5206 | |
5207 | 5207 | #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ |
5208 | 5208 | |
5209 | -unsigned long free_reserved_area(unsigned long start, unsigned long end, | |
5210 | - int poison, char *s) | |
5209 | +unsigned long free_reserved_area(void *start, void *end, int poison, char *s) | |
5211 | 5210 | { |
5212 | - unsigned long pages, pos; | |
5211 | + void *pos; | |
5212 | + unsigned long pages = 0; | |
5213 | 5213 | |
5214 | - pos = start = PAGE_ALIGN(start); | |
5215 | - end &= PAGE_MASK; | |
5216 | - for (pages = 0; pos < end; pos += PAGE_SIZE, pages++) { | |
5214 | + start = (void *)PAGE_ALIGN((unsigned long)start); | |
5215 | + end = (void *)((unsigned long)end & PAGE_MASK); | |
5216 | + for (pos = start; pos < end; pos += PAGE_SIZE, pages++) { | |
5217 | 5217 | if (poison) |
5218 | - memset((void *)pos, poison, PAGE_SIZE); | |
5219 | - free_reserved_page(virt_to_page((void *)pos)); | |
5218 | + memset(pos, poison, PAGE_SIZE); | |
5219 | + free_reserved_page(virt_to_page(pos)); | |
5220 | 5220 | } |
5221 | 5221 | |
5222 | 5222 | if (pages && s) |
5223 | - pr_info("Freeing %s memory: %ldK (%lx - %lx)\n", | |
5223 | + pr_info("Freeing %s memory: %ldK (%p - %p)\n", | |
5224 | 5224 | s, pages << (PAGE_SHIFT - 10), start, end); |
5225 | 5225 | |
5226 | 5226 | return pages; |
5227 | 5227 | } |
5228 | +EXPORT_SYMBOL(free_reserved_area); | |
5228 | 5229 | |
5229 | 5230 | #ifdef CONFIG_HIGHMEM |
5230 | 5231 | void free_highmem_page(struct page *page) |