hugetlbfs: add arch_hugetlb_valid_size
[linux-2.6-microblaze.git] / arch / powerpc / mm / hugetlbpage.c
index 33b3461..de54d2a 100644 (file)
@@ -558,7 +558,7 @@ unsigned long vma_mmu_pagesize(struct vm_area_struct *vma)
        return vma_kernel_pagesize(vma);
 }
 
-static int __init add_huge_page_size(unsigned long long size)
+bool __init arch_hugetlb_valid_size(unsigned long size)
 {
        int shift = __ffs(size);
        int mmu_psize;
@@ -566,20 +566,26 @@ static int __init add_huge_page_size(unsigned long long size)
        /* Check that it is a page size supported by the hardware and
         * that it fits within pagetable and slice limits. */
        if (size <= PAGE_SIZE || !is_power_of_2(size))
-               return -EINVAL;
+               return false;
 
        mmu_psize = check_and_get_huge_psize(shift);
        if (mmu_psize < 0)
-               return -EINVAL;
+               return false;
 
        BUG_ON(mmu_psize_defs[mmu_psize].shift != shift);
 
-       /* Return if huge page size has already been setup */
-       if (size_to_hstate(size))
-               return 0;
+       return true;
+}
 
-       hugetlb_add_hstate(shift - PAGE_SHIFT);
+static int __init add_huge_page_size(unsigned long long size)
+{
+       int shift = __ffs(size);
+
+       if (!arch_hugetlb_valid_size((unsigned long)size))
+               return -EINVAL;
 
+       if (!size_to_hstate(size))
+               hugetlb_add_hstate(shift - PAGE_SHIFT);
        return 0;
 }