diff options
author | Haavard Skinnemoen <hskinnemoen@atmel.com> | 2006-12-08 05:38:05 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-08 11:28:52 -0500 |
commit | e34067fdd2bf7a6e62808b9bbc49d2b2a1357216 (patch) | |
tree | bc2347c0d6982532ed253531f6b2762b475ca376 /arch/parisc/mm | |
parent | 8e087929df884dbb13e383d49d192bdd6928ecbf (diff) |
[PATCH] Generic ioremap_page_range: parisc conversion
Convert parisc to use generic ioremap_page_range()
Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Acked-by: Kyle McMartin <kyle@parisc-linux.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/parisc/mm')
-rw-r--r-- | arch/parisc/mm/ioremap.c | 111 |
1 files changed, 7 insertions, 104 deletions
diff --git a/arch/parisc/mm/ioremap.c b/arch/parisc/mm/ioremap.c index 47a1d2ac9419..44b42c7f639d 100644 --- a/arch/parisc/mm/ioremap.c +++ b/arch/parisc/mm/ioremap.c | |||
@@ -9,110 +9,8 @@ | |||
9 | #include <linux/vmalloc.h> | 9 | #include <linux/vmalloc.h> |
10 | #include <linux/errno.h> | 10 | #include <linux/errno.h> |
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <asm/io.h> | 12 | #include <linux/io.h> |
13 | #include <asm/pgalloc.h> | 13 | #include <asm/pgalloc.h> |
14 | #include <asm/tlbflush.h> | ||
15 | #include <asm/cacheflush.h> | ||
16 | |||
17 | static inline void | ||
18 | remap_area_pte(pte_t *pte, unsigned long address, unsigned long size, | ||
19 | unsigned long phys_addr, unsigned long flags) | ||
20 | { | ||
21 | unsigned long end, pfn; | ||
22 | pgprot_t pgprot = __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | | ||
23 | _PAGE_ACCESSED | flags); | ||
24 | |||
25 | address &= ~PMD_MASK; | ||
26 | |||
27 | end = address + size; | ||
28 | if (end > PMD_SIZE) | ||
29 | end = PMD_SIZE; | ||
30 | |||
31 | BUG_ON(address >= end); | ||
32 | |||
33 | pfn = phys_addr >> PAGE_SHIFT; | ||
34 | do { | ||
35 | BUG_ON(!pte_none(*pte)); | ||
36 | |||
37 | set_pte(pte, pfn_pte(pfn, pgprot)); | ||
38 | |||
39 | address += PAGE_SIZE; | ||
40 | pfn++; | ||
41 | pte++; | ||
42 | } while (address && (address < end)); | ||
43 | } | ||
44 | |||
45 | static inline int | ||
46 | remap_area_pmd(pmd_t *pmd, unsigned long address, unsigned long size, | ||
47 | unsigned long phys_addr, unsigned long flags) | ||
48 | { | ||
49 | unsigned long end; | ||
50 | |||
51 | address &= ~PGDIR_MASK; | ||
52 | |||
53 | end = address + size; | ||
54 | if (end > PGDIR_SIZE) | ||
55 | end = PGDIR_SIZE; | ||
56 | |||
57 | BUG_ON(address >= end); | ||
58 | |||
59 | phys_addr -= address; | ||
60 | do { | ||
61 | pte_t *pte = pte_alloc_kernel(pmd, address); | ||
62 | if (!pte) | ||
63 | return -ENOMEM; | ||
64 | |||
65 | remap_area_pte(pte, address, end - address, | ||
66 | address + phys_addr, flags); | ||
67 | |||
68 | address = (address + PMD_SIZE) & PMD_MASK; | ||
69 | pmd++; | ||
70 | } while (address && (address < end)); | ||
71 | |||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | static int | ||
76 | remap_area_pages(unsigned long address, unsigned long phys_addr, | ||
77 | unsigned long size, unsigned long flags) | ||
78 | { | ||
79 | pgd_t *dir; | ||
80 | int error = 0; | ||
81 | unsigned long end = address + size; | ||
82 | |||
83 | BUG_ON(address >= end); | ||
84 | |||
85 | phys_addr -= address; | ||
86 | dir = pgd_offset_k(address); | ||
87 | |||
88 | flush_cache_all(); | ||
89 | |||
90 | do { | ||
91 | pud_t *pud; | ||
92 | pmd_t *pmd; | ||
93 | |||
94 | error = -ENOMEM; | ||
95 | pud = pud_alloc(&init_mm, dir, address); | ||
96 | if (!pud) | ||
97 | break; | ||
98 | |||
99 | pmd = pmd_alloc(&init_mm, pud, address); | ||
100 | if (!pmd) | ||
101 | break; | ||
102 | |||
103 | if (remap_area_pmd(pmd, address, end - address, | ||
104 | phys_addr + address, flags)) | ||
105 | break; | ||
106 | |||
107 | error = 0; | ||
108 | address = (address + PGDIR_SIZE) & PGDIR_MASK; | ||
109 | dir++; | ||
110 | } while (address && (address < end)); | ||
111 | |||
112 | flush_tlb_all(); | ||
113 | |||
114 | return error; | ||
115 | } | ||
116 | 14 | ||
117 | /* | 15 | /* |
118 | * Generic mapping function (not visible outside): | 16 | * Generic mapping function (not visible outside): |
@@ -131,6 +29,7 @@ void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned l | |||
131 | void *addr; | 29 | void *addr; |
132 | struct vm_struct *area; | 30 | struct vm_struct *area; |
133 | unsigned long offset, last_addr; | 31 | unsigned long offset, last_addr; |
32 | pgprot_t pgprot; | ||
134 | 33 | ||
135 | #ifdef CONFIG_EISA | 34 | #ifdef CONFIG_EISA |
136 | unsigned long end = phys_addr + size - 1; | 35 | unsigned long end = phys_addr + size - 1; |
@@ -164,6 +63,9 @@ void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned l | |||
164 | } | 63 | } |
165 | } | 64 | } |
166 | 65 | ||
66 | pgprot = __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | | ||
67 | _PAGE_ACCESSED | flags); | ||
68 | |||
167 | /* | 69 | /* |
168 | * Mappings have to be page-aligned | 70 | * Mappings have to be page-aligned |
169 | */ | 71 | */ |
@@ -179,7 +81,8 @@ void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned l | |||
179 | return NULL; | 81 | return NULL; |
180 | 82 | ||
181 | addr = area->addr; | 83 | addr = area->addr; |
182 | if (remap_area_pages((unsigned long) addr, phys_addr, size, flags)) { | 84 | if (ioremap_page_range((unsigned long)addr, (unsigned long)addr + size, |
85 | phys_addr, pgprot)) { | ||
183 | vfree(addr); | 86 | vfree(addr); |
184 | return NULL; | 87 | return NULL; |
185 | } | 88 | } |