treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / arch / m68k / include / asm / motorola_pgalloc.h
blobff9cc401ffd1d1a641cb5bc5d665df66d1a29322
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _MOTOROLA_PGALLOC_H
3 #define _MOTOROLA_PGALLOC_H
5 #include <asm/tlb.h>
6 #include <asm/tlbflush.h>
8 extern pmd_t *get_pointer_table(void);
9 extern int free_pointer_table(pmd_t *);
11 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
13 pte_t *pte;
15 pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
16 if (pte) {
17 __flush_page_to_ram(pte);
18 flush_tlb_kernel_page(pte);
19 nocache_page(pte);
22 return pte;
25 static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
27 cache_page(pte);
28 free_page((unsigned long) pte);
31 static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
33 struct page *page;
34 pte_t *pte;
36 page = alloc_pages(GFP_KERNEL|__GFP_ZERO, 0);
37 if(!page)
38 return NULL;
39 if (!pgtable_pte_page_ctor(page)) {
40 __free_page(page);
41 return NULL;
44 pte = kmap(page);
45 __flush_page_to_ram(pte);
46 flush_tlb_kernel_page(pte);
47 nocache_page(pte);
48 kunmap(page);
49 return page;
52 static inline void pte_free(struct mm_struct *mm, pgtable_t page)
54 pgtable_pte_page_dtor(page);
55 cache_page(kmap(page));
56 kunmap(page);
57 __free_page(page);
60 static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t page,
61 unsigned long address)
63 pgtable_pte_page_dtor(page);
64 cache_page(kmap(page));
65 kunmap(page);
66 __free_page(page);
70 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
72 return get_pointer_table();
75 static inline int pmd_free(struct mm_struct *mm, pmd_t *pmd)
77 return free_pointer_table(pmd);
80 static inline int __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
81 unsigned long address)
83 return free_pointer_table(pmd);
87 static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
89 pmd_free(mm, (pmd_t *)pgd);
92 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
94 return (pgd_t *)get_pointer_table();
98 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
100 pmd_set(pmd, pte);
103 static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t page)
105 pmd_set(pmd, page_address(page));
107 #define pmd_pgtable(pmd) pmd_page(pmd)
109 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
111 pud_set(pud, pmd);
114 #endif /* _MOTOROLA_PGALLOC_H */