mm/frv: prepare for removing num_physpages and simplify mem_init()
authorJiang Liu <liuj97@gmail.com>
Wed, 3 Jul 2013 22:03:55 +0000 (15:03 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 3 Jul 2013 23:07:36 +0000 (16:07 -0700)
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/frv/kernel/setup.c
arch/frv/mm/init.c

index a5136474c6fd6f95628362e8e144d82f8799c773..f78f8cb44093d8fdd36d04efdd975f0560b47e8c 100644 (file)
@@ -876,6 +876,7 @@ late_initcall(setup_arch_serial);
 static void __init setup_linux_memory(void)
 {
        unsigned long bootmap_size, low_top_pfn, kstart, kend, high_mem;
+       unsigned long physpages;
 
        kstart  = (unsigned long) &__kernel_image_start - PAGE_OFFSET;
        kend    = (unsigned long) &__kernel_image_end - PAGE_OFFSET;
@@ -893,19 +894,19 @@ static void __init setup_linux_memory(void)
                                         );
 
        /* pass the memory that the kernel can immediately use over to the bootmem allocator */
-       max_mapnr = num_physpages = (memory_end - memory_start) >> PAGE_SHIFT;
+       max_mapnr = physpages = (memory_end - memory_start) >> PAGE_SHIFT;
        low_top_pfn = (KERNEL_LOWMEM_END - KERNEL_LOWMEM_START) >> PAGE_SHIFT;
        high_mem = 0;
 
-       if (num_physpages > low_top_pfn) {
+       if (physpages > low_top_pfn) {
 #ifdef CONFIG_HIGHMEM
-               high_mem = num_physpages - low_top_pfn;
+               high_mem = physpages - low_top_pfn;
 #else
-               max_mapnr = num_physpages = low_top_pfn;
+               max_mapnr = physpages = low_top_pfn;
 #endif
        }
        else {
-               low_top_pfn = num_physpages;
+               low_top_pfn = physpages;
        }
 
        min_low_pfn = memory_start >> PAGE_SHIFT;
@@ -979,7 +980,7 @@ static void __init setup_uclinux_memory(void)
        free_bootmem(memory_start, memory_end - memory_start);
 
        high_memory = (void *) (memory_end & PAGE_MASK);
-       max_mapnr = num_physpages = ((unsigned long) high_memory - PAGE_OFFSET) >> PAGE_SHIFT;
+       max_mapnr = ((unsigned long) high_memory - PAGE_OFFSET) >> PAGE_SHIFT;
 
        min_low_pfn = memory_start >> PAGE_SHIFT;
        max_low_pfn = memory_end >> PAGE_SHIFT;
index 3dcc88803a4fa781a4b9a651bac42ea29e7c2f2d..88a15974352857dda020f5aa2c95b452f90b42c2 100644 (file)
@@ -78,7 +78,7 @@ void __init paging_init(void)
        memset((void *) empty_zero_page, 0, PAGE_SIZE);
 
 #ifdef CONFIG_HIGHMEM
-       if (num_physpages - num_mappedpages) {
+       if (get_num_physpages() - num_mappedpages) {
                pgd_t *pge;
                pud_t *pue;
                pmd_t *pme;
@@ -96,7 +96,7 @@ void __init paging_init(void)
         */
        zones_size[ZONE_NORMAL]  = max_low_pfn - min_low_pfn;
 #ifdef CONFIG_HIGHMEM
-       zones_size[ZONE_HIGHMEM] = num_physpages - num_mappedpages;
+       zones_size[ZONE_HIGHMEM] = get_num_physpages() - num_mappedpages;
 #endif
 
        free_area_init(zones_size);
@@ -114,45 +114,24 @@ void __init paging_init(void)
  */
 void __init mem_init(void)
 {
-       unsigned long npages = (memory_end - memory_start) >> PAGE_SHIFT;
-       unsigned long tmp;
-#ifdef CONFIG_MMU
-       unsigned long loop, pfn;
-       int datapages = 0;
-#endif
-       int codek = 0, datak = 0;
+       unsigned long code_size = _etext - _stext;
 
        /* this will put all low memory onto the freelists */
        free_all_bootmem();
+#if defined(CONFIG_MMU) && defined(CONFIG_HIGHMEM)
+       {
+               unsigned long pfn;
 
-#ifdef CONFIG_MMU
-       for (loop = 0 ; loop < npages ; loop++)
-               if (PageReserved(&mem_map[loop]))
-                       datapages++;
-
-#ifdef CONFIG_HIGHMEM
-       for (pfn = num_physpages - 1; pfn >= num_mappedpages; pfn--)
-               free_highmem_page(&mem_map[pfn]);
-#endif
-
-       codek = ((unsigned long) &_etext - (unsigned long) &_stext) >> 10;
-       datak = datapages << (PAGE_SHIFT - 10);
-
-#else
-       codek = (_etext - _stext) >> 10;
-       datak = 0; //(__bss_stop - _sdata) >> 10;
+               for (pfn = get_num_physpages() - 1;
+                    pfn >= num_mappedpages; pfn--)
+                       free_highmem_page(&mem_map[pfn]);
+       }
 #endif
 
-       tmp = nr_free_pages() << PAGE_SHIFT;
-       printk("Memory available: %luKiB/%luKiB RAM, %luKiB/%luKiB ROM (%dKiB kernel code, %dKiB data)\n",
-              tmp >> 10,
-              npages << (PAGE_SHIFT - 10),
-              (rom_length > 0) ? ((rom_length >> 10) - codek) : 0,
-              rom_length >> 10,
-              codek,
-              datak
-              );
-
+       mem_init_print_info(NULL);
+       if (rom_length > 0 && rom_length >= code_size)
+               printk("Memory available:  %luKiB/%luKiB ROM\n",
+                       (rom_length - code_size) >> 10, rom_length >> 10);
 } /* end mem_init() */
 
 /*****************************************************************************/