Skip to content

Commit 0768634

Browse files
author
Christoph Hellwig
committed
m68k: rename __iounmap and mark it static
m68k uses __iounmap as the name for an internal helper that is only used for some CPU types. Mark it static, give it a better name and move it around a bit to avoid a forward declaration. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
1 parent d092a87 commit 0768634

2 files changed

Lines changed: 50 additions & 51 deletions

File tree

‎arch/m68k/include/asm/kmap.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ extern void __iomem *__ioremap(unsigned long physaddr, unsigned long size,
2020
int cacheflag);
2121
#define iounmap iounmap
2222
extern void iounmap(void __iomem *addr);
23-
extern void __iounmap(void *addr, unsigned long size);
2423

2524
#define ioremap ioremap
2625
static inline void __iomem *ioremap(unsigned long physaddr, unsigned long size)

‎arch/m68k/mm/kmap.c‎

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,55 @@ static inline void free_io_area(void *addr)
5454

5555
static struct vm_struct *iolist;
5656

57+
/*
58+
* __free_io_area unmaps nearly everything, so be careful
59+
* Currently it doesn't free pointer/page tables anymore but this
60+
* wasn't used anyway and might be added later.
61+
*/
62+
static void __free_io_area(void *addr, unsigned long size)
63+
{
64+
unsigned long virtaddr = (unsigned long)addr;
65+
pgd_t *pgd_dir;
66+
pmd_t *pmd_dir;
67+
pte_t *pte_dir;
68+
69+
while ((long)size > 0) {
70+
pgd_dir = pgd_offset_k(virtaddr);
71+
if (pgd_bad(*pgd_dir)) {
72+
printk("iounmap: bad pgd(%08lx)\n", pgd_val(*pgd_dir));
73+
pgd_clear(pgd_dir);
74+
return;
75+
}
76+
pmd_dir = pmd_offset(pgd_dir, virtaddr);
77+
78+
if (CPU_IS_020_OR_030) {
79+
int pmd_off = (virtaddr/PTRTREESIZE) & 15;
80+
int pmd_type = pmd_dir->pmd[pmd_off] & _DESCTYPE_MASK;
81+
82+
if (pmd_type == _PAGE_PRESENT) {
83+
pmd_dir->pmd[pmd_off] = 0;
84+
virtaddr += PTRTREESIZE;
85+
size -= PTRTREESIZE;
86+
continue;
87+
} else if (pmd_type == 0)
88+
continue;
89+
}
90+
91+
if (pmd_bad(*pmd_dir)) {
92+
printk("iounmap: bad pmd (%08lx)\n", pmd_val(*pmd_dir));
93+
pmd_clear(pmd_dir);
94+
return;
95+
}
96+
pte_dir = pte_offset_kernel(pmd_dir, virtaddr);
97+
98+
pte_val(*pte_dir) = 0;
99+
virtaddr += PAGE_SIZE;
100+
size -= PAGE_SIZE;
101+
}
102+
103+
flush_tlb_all();
104+
}
105+
57106
static struct vm_struct *get_io_area(unsigned long size)
58107
{
59108
unsigned long addr;
@@ -90,7 +139,7 @@ static inline void free_io_area(void *addr)
90139
if (tmp->addr == addr) {
91140
*p = tmp->next;
92141
/* remove gap added in get_io_area() */
93-
__iounmap(tmp->addr, tmp->size - IO_SIZE);
142+
__free_io_area(tmp->addr, tmp->size - IO_SIZE);
94143
kfree(tmp);
95144
return;
96145
}
@@ -249,55 +298,6 @@ void iounmap(void __iomem *addr)
249298
}
250299
EXPORT_SYMBOL(iounmap);
251300

252-
/*
253-
* __iounmap unmaps nearly everything, so be careful
254-
* Currently it doesn't free pointer/page tables anymore but this
255-
* wasn't used anyway and might be added later.
256-
*/
257-
void __iounmap(void *addr, unsigned long size)
258-
{
259-
unsigned long virtaddr = (unsigned long)addr;
260-
pgd_t *pgd_dir;
261-
pmd_t *pmd_dir;
262-
pte_t *pte_dir;
263-
264-
while ((long)size > 0) {
265-
pgd_dir = pgd_offset_k(virtaddr);
266-
if (pgd_bad(*pgd_dir)) {
267-
printk("iounmap: bad pgd(%08lx)\n", pgd_val(*pgd_dir));
268-
pgd_clear(pgd_dir);
269-
return;
270-
}
271-
pmd_dir = pmd_offset(pgd_dir, virtaddr);
272-
273-
if (CPU_IS_020_OR_030) {
274-
int pmd_off = (virtaddr/PTRTREESIZE) & 15;
275-
int pmd_type = pmd_dir->pmd[pmd_off] & _DESCTYPE_MASK;
276-
277-
if (pmd_type == _PAGE_PRESENT) {
278-
pmd_dir->pmd[pmd_off] = 0;
279-
virtaddr += PTRTREESIZE;
280-
size -= PTRTREESIZE;
281-
continue;
282-
} else if (pmd_type == 0)
283-
continue;
284-
}
285-
286-
if (pmd_bad(*pmd_dir)) {
287-
printk("iounmap: bad pmd (%08lx)\n", pmd_val(*pmd_dir));
288-
pmd_clear(pmd_dir);
289-
return;
290-
}
291-
pte_dir = pte_offset_kernel(pmd_dir, virtaddr);
292-
293-
pte_val(*pte_dir) = 0;
294-
virtaddr += PAGE_SIZE;
295-
size -= PAGE_SIZE;
296-
}
297-
298-
flush_tlb_all();
299-
}
300-
301301
/*
302302
* Set new cache mode for some kernel address space.
303303
* The caller must push data for that range itself, if such data may already

0 commit comments

Comments
 (0)