sparc64: simplify vmemmap_populate
[sfrench/cifs-2.6.git] / arch / sparc / mm / init_64.c
index 984e9d65ea0d14872a449c39c73f4386f93cc38f..051f7340179389a85bf3fe89e019e7ab5c60c816 100644 (file)
@@ -2644,30 +2644,19 @@ int __meminit vmemmap_populate(unsigned long vstart, unsigned long vend,
        vstart = vstart & PMD_MASK;
        vend = ALIGN(vend, PMD_SIZE);
        for (; vstart < vend; vstart += PMD_SIZE) {
-               pgd_t *pgd = pgd_offset_k(vstart);
+               pgd_t *pgd = vmemmap_pgd_populate(vstart, node);
                unsigned long pte;
                pud_t *pud;
                pmd_t *pmd;
 
-               if (pgd_none(*pgd)) {
-                       pud_t *new = vmemmap_alloc_block(PAGE_SIZE, node);
+               if (!pgd)
+                       return -ENOMEM;
 
-                       if (!new)
-                               return -ENOMEM;
-                       pgd_populate(&init_mm, pgd, new);
-               }
-
-               pud = pud_offset(pgd, vstart);
-               if (pud_none(*pud)) {
-                       pmd_t *new = vmemmap_alloc_block(PAGE_SIZE, node);
-
-                       if (!new)
-                               return -ENOMEM;
-                       pud_populate(&init_mm, pud, new);
-               }
+               pud = vmemmap_pud_populate(pgd, vstart, node);
+               if (!pud)
+                       return -ENOMEM;
 
                pmd = pmd_offset(pud, vstart);
-
                pte = pmd_val(*pmd);
                if (!(pte & _PAGE_VALID)) {
                        void *block = vmemmap_alloc_block(PMD_SIZE, node);