treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / arch / riscv / mm / hugetlbpage.c
blob0d4747e9d5b59d0c0a4be908aba83fe3a20f0874
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/hugetlb.h>
3 #include <linux/err.h>
5 int pud_huge(pud_t pud)
7 return pud_present(pud) &&
8 (pud_val(pud) & (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC));
11 int pmd_huge(pmd_t pmd)
13 return pmd_present(pmd) &&
14 (pmd_val(pmd) & (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC));
17 static __init int setup_hugepagesz(char *opt)
19 unsigned long ps = memparse(opt, &opt);
21 if (ps == HPAGE_SIZE) {
22 hugetlb_add_hstate(HPAGE_SHIFT - PAGE_SHIFT);
23 } else if (IS_ENABLED(CONFIG_64BIT) && ps == PUD_SIZE) {
24 hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
25 } else {
26 hugetlb_bad_size();
27 pr_err("hugepagesz: Unsupported page size %lu M\n", ps >> 20);
28 return 0;
31 return 1;
33 __setup("hugepagesz=", setup_hugepagesz);
35 #ifdef CONFIG_CONTIG_ALLOC
36 static __init int gigantic_pages_init(void)
38 /* With CONTIG_ALLOC, we can allocate gigantic pages at runtime */
39 if (IS_ENABLED(CONFIG_64BIT) && !size_to_hstate(1UL << PUD_SHIFT))
40 hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
41 return 0;
43 arch_initcall(gigantic_pages_init);
44 #endif