treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / arch / parisc / mm / fixmap.c
blobe2d8b0a857ee301e71a57fabe9b6b5885d622347
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * fixmaps for parisc
5 * Copyright (c) 2019 Sven Schnelle <svens@stackframe.org>
6 */
8 #include <linux/kprobes.h>
9 #include <linux/mm.h>
10 #include <asm/cacheflush.h>
11 #include <asm/fixmap.h>
13 void notrace set_fixmap(enum fixed_addresses idx, phys_addr_t phys)
15 unsigned long vaddr = __fix_to_virt(idx);
16 pgd_t *pgd = pgd_offset_k(vaddr);
17 p4d_t *p4d = p4d_offset(pgd, vaddr);
18 pud_t *pud = pud_offset(p4d, vaddr);
19 pmd_t *pmd = pmd_offset(pud, vaddr);
20 pte_t *pte;
22 if (pmd_none(*pmd))
23 pmd = pmd_alloc(NULL, pud, vaddr);
25 pte = pte_offset_kernel(pmd, vaddr);
26 if (pte_none(*pte))
27 pte = pte_alloc_kernel(pmd, vaddr);
29 set_pte_at(&init_mm, vaddr, pte, __mk_pte(phys, PAGE_KERNEL_RWX));
30 flush_tlb_kernel_range(vaddr, vaddr + PAGE_SIZE);
33 void notrace clear_fixmap(enum fixed_addresses idx)
35 unsigned long vaddr = __fix_to_virt(idx);
36 pgd_t *pgd = pgd_offset_k(vaddr);
37 p4d_t *p4d = p4d_offset(pgd, vaddr);
38 pud_t *pud = pud_offset(p4d, vaddr);
39 pmd_t *pmd = pmd_offset(pud, vaddr);
40 pte_t *pte = pte_offset_kernel(pmd, vaddr);
42 if (WARN_ON(pte_none(*pte)))
43 return;
45 pte_clear(&init_mm, vaddr, pte);
47 flush_tlb_kernel_range(vaddr, vaddr + PAGE_SIZE);