diff options
author | Kevin Cernekee <cernekee@gmail.com> | 2011-06-18 14:28:48 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2011-09-16 20:37:04 -0400 |
commit | 16650107579aed81e0b0534a60400f9ba911fe9b (patch) | |
tree | a0628e1f814556334ef8300651e6c47e07bd792c | |
parent | fe0b030cf016ee9a4b0ae4adb0095c46d0e461cc (diff) |
MIPS: Trivial style cleanups in mmap.c
Fix checkpatch warnings. Rename arch_get_unmapped_area_foo() to
arch_get_unmapped_area_common(). Make indentations and spacing more
consistent. Add <linux/compiler.h> for likely/unlikely.
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Cc: Jian Peng <jipeng2005@gmail.com>
Cc: David Daney <ddaney@caviumnetworks.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/2506/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | arch/mips/mm/mmap.c | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c index 9ff5d0fac556..302d779d5b0d 100644 --- a/arch/mips/mm/mmap.c +++ b/arch/mips/mm/mmap.c | |||
@@ -6,6 +6,7 @@ | |||
6 | * Copyright (C) 2011 Wind River Systems, | 6 | * Copyright (C) 2011 Wind River Systems, |
7 | * written by Ralf Baechle <ralf@linux-mips.org> | 7 | * written by Ralf Baechle <ralf@linux-mips.org> |
8 | */ | 8 | */ |
9 | #include <linux/compiler.h> | ||
9 | #include <linux/errno.h> | 10 | #include <linux/errno.h> |
10 | #include <linux/mm.h> | 11 | #include <linux/mm.h> |
11 | #include <linux/mman.h> | 12 | #include <linux/mman.h> |
@@ -15,12 +16,11 @@ | |||
15 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
16 | 17 | ||
17 | unsigned long shm_align_mask = PAGE_SIZE - 1; /* Sane caches */ | 18 | unsigned long shm_align_mask = PAGE_SIZE - 1; /* Sane caches */ |
18 | |||
19 | EXPORT_SYMBOL(shm_align_mask); | 19 | EXPORT_SYMBOL(shm_align_mask); |
20 | 20 | ||
21 | /* gap between mmap and stack */ | 21 | /* gap between mmap and stack */ |
22 | #define MIN_GAP (128*1024*1024UL) | 22 | #define MIN_GAP (128*1024*1024UL) |
23 | #define MAX_GAP ((TASK_SIZE)/6*5) | 23 | #define MAX_GAP ((TASK_SIZE)/6*5) |
24 | 24 | ||
25 | static int mmap_is_legacy(void) | 25 | static int mmap_is_legacy(void) |
26 | { | 26 | { |
@@ -57,13 +57,13 @@ static inline unsigned long COLOUR_ALIGN_DOWN(unsigned long addr, | |||
57 | return base - off; | 57 | return base - off; |
58 | } | 58 | } |
59 | 59 | ||
60 | #define COLOUR_ALIGN(addr,pgoff) \ | 60 | #define COLOUR_ALIGN(addr, pgoff) \ |
61 | ((((addr) + shm_align_mask) & ~shm_align_mask) + \ | 61 | ((((addr) + shm_align_mask) & ~shm_align_mask) + \ |
62 | (((pgoff) << PAGE_SHIFT) & shm_align_mask)) | 62 | (((pgoff) << PAGE_SHIFT) & shm_align_mask)) |
63 | 63 | ||
64 | enum mmap_allocation_direction {UP, DOWN}; | 64 | enum mmap_allocation_direction {UP, DOWN}; |
65 | 65 | ||
66 | static unsigned long arch_get_unmapped_area_foo(struct file *filp, | 66 | static unsigned long arch_get_unmapped_area_common(struct file *filp, |
67 | unsigned long addr0, unsigned long len, unsigned long pgoff, | 67 | unsigned long addr0, unsigned long len, unsigned long pgoff, |
68 | unsigned long flags, enum mmap_allocation_direction dir) | 68 | unsigned long flags, enum mmap_allocation_direction dir) |
69 | { | 69 | { |
@@ -103,16 +103,16 @@ static unsigned long arch_get_unmapped_area_foo(struct file *filp, | |||
103 | 103 | ||
104 | vma = find_vma(mm, addr); | 104 | vma = find_vma(mm, addr); |
105 | if (TASK_SIZE - len >= addr && | 105 | if (TASK_SIZE - len >= addr && |
106 | (!vma || addr + len <= vma->vm_start)) | 106 | (!vma || addr + len <= vma->vm_start)) |
107 | return addr; | 107 | return addr; |
108 | } | 108 | } |
109 | 109 | ||
110 | if (dir == UP) { | 110 | if (dir == UP) { |
111 | addr = mm->mmap_base; | 111 | addr = mm->mmap_base; |
112 | if (do_color_align) | 112 | if (do_color_align) |
113 | addr = COLOUR_ALIGN(addr, pgoff); | 113 | addr = COLOUR_ALIGN(addr, pgoff); |
114 | else | 114 | else |
115 | addr = PAGE_ALIGN(addr); | 115 | addr = PAGE_ALIGN(addr); |
116 | 116 | ||
117 | for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) { | 117 | for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) { |
118 | /* At this point: (!vma || addr < vma->vm_end). */ | 118 | /* At this point: (!vma || addr < vma->vm_end). */ |
@@ -131,28 +131,30 @@ static unsigned long arch_get_unmapped_area_foo(struct file *filp, | |||
131 | mm->free_area_cache = mm->mmap_base; | 131 | mm->free_area_cache = mm->mmap_base; |
132 | } | 132 | } |
133 | 133 | ||
134 | /* either no address requested or can't fit in requested address hole */ | 134 | /* |
135 | * either no address requested, or the mapping can't fit into | ||
136 | * the requested address hole | ||
137 | */ | ||
135 | addr = mm->free_area_cache; | 138 | addr = mm->free_area_cache; |
136 | if (do_color_align) { | 139 | if (do_color_align) { |
137 | unsigned long base = | 140 | unsigned long base = |
138 | COLOUR_ALIGN_DOWN(addr - len, pgoff); | 141 | COLOUR_ALIGN_DOWN(addr - len, pgoff); |
139 | |||
140 | addr = base + len; | 142 | addr = base + len; |
141 | } | 143 | } |
142 | 144 | ||
143 | /* make sure it can fit in the remaining address space */ | 145 | /* make sure it can fit in the remaining address space */ |
144 | if (likely(addr > len)) { | 146 | if (likely(addr > len)) { |
145 | vma = find_vma(mm, addr - len); | 147 | vma = find_vma(mm, addr - len); |
146 | if (!vma || addr <= vma->vm_start) { | 148 | if (!vma || addr <= vma->vm_start) { |
147 | /* remember the address as a hint for next time */ | 149 | /* cache the address as a hint for next time */ |
148 | return mm->free_area_cache = addr-len; | 150 | return mm->free_area_cache = addr - len; |
149 | } | 151 | } |
150 | } | 152 | } |
151 | 153 | ||
152 | if (unlikely(mm->mmap_base < len)) | 154 | if (unlikely(mm->mmap_base < len)) |
153 | goto bottomup; | 155 | goto bottomup; |
154 | 156 | ||
155 | addr = mm->mmap_base-len; | 157 | addr = mm->mmap_base - len; |
156 | if (do_color_align) | 158 | if (do_color_align) |
157 | addr = COLOUR_ALIGN_DOWN(addr, pgoff); | 159 | addr = COLOUR_ALIGN_DOWN(addr, pgoff); |
158 | 160 | ||
@@ -163,8 +165,8 @@ static unsigned long arch_get_unmapped_area_foo(struct file *filp, | |||
163 | * return with success: | 165 | * return with success: |
164 | */ | 166 | */ |
165 | vma = find_vma(mm, addr); | 167 | vma = find_vma(mm, addr); |
166 | if (likely(!vma || addr+len <= vma->vm_start)) { | 168 | if (likely(!vma || addr + len <= vma->vm_start)) { |
167 | /* remember the address as a hint for next time */ | 169 | /* cache the address as a hint for next time */ |
168 | return mm->free_area_cache = addr; | 170 | return mm->free_area_cache = addr; |
169 | } | 171 | } |
170 | 172 | ||
@@ -173,7 +175,7 @@ static unsigned long arch_get_unmapped_area_foo(struct file *filp, | |||
173 | mm->cached_hole_size = vma->vm_start - addr; | 175 | mm->cached_hole_size = vma->vm_start - addr; |
174 | 176 | ||
175 | /* try just below the current vma->vm_start */ | 177 | /* try just below the current vma->vm_start */ |
176 | addr = vma->vm_start-len; | 178 | addr = vma->vm_start - len; |
177 | if (do_color_align) | 179 | if (do_color_align) |
178 | addr = COLOUR_ALIGN_DOWN(addr, pgoff); | 180 | addr = COLOUR_ALIGN_DOWN(addr, pgoff); |
179 | } while (likely(len < vma->vm_start)); | 181 | } while (likely(len < vma->vm_start)); |
@@ -201,7 +203,7 @@ bottomup: | |||
201 | unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr0, | 203 | unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr0, |
202 | unsigned long len, unsigned long pgoff, unsigned long flags) | 204 | unsigned long len, unsigned long pgoff, unsigned long flags) |
203 | { | 205 | { |
204 | return arch_get_unmapped_area_foo(filp, | 206 | return arch_get_unmapped_area_common(filp, |
205 | addr0, len, pgoff, flags, UP); | 207 | addr0, len, pgoff, flags, UP); |
206 | } | 208 | } |
207 | 209 | ||
@@ -213,7 +215,7 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp, | |||
213 | unsigned long addr0, unsigned long len, unsigned long pgoff, | 215 | unsigned long addr0, unsigned long len, unsigned long pgoff, |
214 | unsigned long flags) | 216 | unsigned long flags) |
215 | { | 217 | { |
216 | return arch_get_unmapped_area_foo(filp, | 218 | return arch_get_unmapped_area_common(filp, |
217 | addr0, len, pgoff, flags, DOWN); | 219 | addr0, len, pgoff, flags, DOWN); |
218 | } | 220 | } |
219 | 221 | ||