diff options
author | Heiko Carstens <heiko.carstens@de.ibm.com> | 2010-02-26 16:37:42 -0500 |
---|---|---|
committer | Martin Schwidefsky <sky@mschwide.boeblingen.de.ibm.com> | 2010-02-26 16:37:31 -0500 |
commit | d96221ab1e7d86dc0d4666466979117cd1915386 (patch) | |
tree | ff3283841e7419226878a70f440d09d388bfe0c9 /arch | |
parent | b8e660b83d505148c83ddc6d5ba69c29d0eab1e3 (diff) |
[S390] free_initmem: reduce code duplication
free_initmem() and free_initrd_mem() are nearly identical. So make them
call a common function.
Also fixes a bug: if the initrd wouldn't start on a page boundary also
memory after the initrd would be initialized with the poison value.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/s390/mm/init.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index 765647952221..d5865e4024ce 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c | |||
@@ -143,33 +143,34 @@ void kernel_map_pages(struct page *page, int numpages, int enable) | |||
143 | } | 143 | } |
144 | #endif | 144 | #endif |
145 | 145 | ||
146 | void free_initmem(void) | 146 | void free_init_pages(char *what, unsigned long begin, unsigned long end) |
147 | { | 147 | { |
148 | unsigned long addr; | 148 | unsigned long addr = begin; |
149 | 149 | ||
150 | addr = (unsigned long)(&__init_begin); | 150 | if (begin >= end) |
151 | for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) { | 151 | return; |
152 | for (; addr < end; addr += PAGE_SIZE) { | ||
152 | ClearPageReserved(virt_to_page(addr)); | 153 | ClearPageReserved(virt_to_page(addr)); |
153 | init_page_count(virt_to_page(addr)); | 154 | init_page_count(virt_to_page(addr)); |
154 | memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE); | 155 | memset((void *)(addr & PAGE_MASK), POISON_FREE_INITMEM, |
156 | PAGE_SIZE); | ||
155 | free_page(addr); | 157 | free_page(addr); |
156 | totalram_pages++; | 158 | totalram_pages++; |
157 | } | 159 | } |
158 | printk ("Freeing unused kernel memory: %ldk freed\n", | 160 | printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10); |
159 | ((unsigned long)&__init_end - (unsigned long)&__init_begin) >> 10); | 161 | } |
162 | |||
163 | void free_initmem(void) | ||
164 | { | ||
165 | free_init_pages("unused kernel memory", | ||
166 | (unsigned long)&__init_begin, | ||
167 | (unsigned long)&__init_end); | ||
160 | } | 168 | } |
161 | 169 | ||
162 | #ifdef CONFIG_BLK_DEV_INITRD | 170 | #ifdef CONFIG_BLK_DEV_INITRD |
163 | void free_initrd_mem(unsigned long start, unsigned long end) | 171 | void free_initrd_mem(unsigned long start, unsigned long end) |
164 | { | 172 | { |
165 | if (start < end) | 173 | free_init_pages("initrd memory", start, end); |
166 | printk ("Freeing initrd memory: %ldk freed\n", (end - start) >> 10); | ||
167 | for (; start < end; start += PAGE_SIZE) { | ||
168 | ClearPageReserved(virt_to_page(start)); | ||
169 | init_page_count(virt_to_page(start)); | ||
170 | free_page(start); | ||
171 | totalram_pages++; | ||
172 | } | ||
173 | } | 174 | } |
174 | #endif | 175 | #endif |
175 | 176 | ||