diff options
author | Akinobu Mita <mita@miraclelinux.com> | 2006-03-26 04:39:20 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-26 11:57:12 -0500 |
commit | d142d8601993f423386556f1cbbacbdcf7b7a767 (patch) | |
tree | b0f792a30a5b7a90222d90dff03dfd649f5080b0 | |
parent | b89c3b165fbec605c60fd5a9e32d647e4c0befbb (diff) |
[PATCH] bitops: arm26: use generic bitops
- remove __{,test_and_}{set,clear,change}_bit() and test_bit()
- remove ffz()
- remove __ffs()
- remove generic_fls()
- remove generic_fls64()
- remove generic_ffs()
- remove sched_find_first_bit()
- remove generic_hweight{32,16,8}()
Signed-off-by: Akinobu Mita <mita@miraclelinux.com>
Cc: Ian Molton <spyro@f2s.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | arch/arm26/Kconfig | 4 | ||||
-rw-r--r-- | include/asm-arm26/bitops.h | 146 |
2 files changed, 14 insertions, 136 deletions
diff --git a/arch/arm26/Kconfig b/arch/arm26/Kconfig index dee23d87fc5a..cf4ebf4c274d 100644 --- a/arch/arm26/Kconfig +++ b/arch/arm26/Kconfig | |||
@@ -41,6 +41,10 @@ config RWSEM_GENERIC_SPINLOCK | |||
41 | config RWSEM_XCHGADD_ALGORITHM | 41 | config RWSEM_XCHGADD_ALGORITHM |
42 | bool | 42 | bool |
43 | 43 | ||
44 | config GENERIC_HWEIGHT | ||
45 | bool | ||
46 | default y | ||
47 | |||
44 | config GENERIC_CALIBRATE_DELAY | 48 | config GENERIC_CALIBRATE_DELAY |
45 | bool | 49 | bool |
46 | default y | 50 | default y |
diff --git a/include/asm-arm26/bitops.h b/include/asm-arm26/bitops.h index d87f8634e625..19a69573a654 100644 --- a/include/asm-arm26/bitops.h +++ b/include/asm-arm26/bitops.h | |||
@@ -117,65 +117,7 @@ ____atomic_test_and_change_bit(unsigned int bit, volatile unsigned long *p) | |||
117 | return res & mask; | 117 | return res & mask; |
118 | } | 118 | } |
119 | 119 | ||
120 | /* | 120 | #include <asm-generic/bitops/non-atomic.h> |
121 | * Now the non-atomic variants. We let the compiler handle all | ||
122 | * optimisations for these. These are all _native_ endian. | ||
123 | */ | ||
124 | static inline void __set_bit(int nr, volatile unsigned long *p) | ||
125 | { | ||
126 | p[nr >> 5] |= (1UL << (nr & 31)); | ||
127 | } | ||
128 | |||
129 | static inline void __clear_bit(int nr, volatile unsigned long *p) | ||
130 | { | ||
131 | p[nr >> 5] &= ~(1UL << (nr & 31)); | ||
132 | } | ||
133 | |||
134 | static inline void __change_bit(int nr, volatile unsigned long *p) | ||
135 | { | ||
136 | p[nr >> 5] ^= (1UL << (nr & 31)); | ||
137 | } | ||
138 | |||
139 | static inline int __test_and_set_bit(int nr, volatile unsigned long *p) | ||
140 | { | ||
141 | unsigned long oldval, mask = 1UL << (nr & 31); | ||
142 | |||
143 | p += nr >> 5; | ||
144 | |||
145 | oldval = *p; | ||
146 | *p = oldval | mask; | ||
147 | return oldval & mask; | ||
148 | } | ||
149 | |||
150 | static inline int __test_and_clear_bit(int nr, volatile unsigned long *p) | ||
151 | { | ||
152 | unsigned long oldval, mask = 1UL << (nr & 31); | ||
153 | |||
154 | p += nr >> 5; | ||
155 | |||
156 | oldval = *p; | ||
157 | *p = oldval & ~mask; | ||
158 | return oldval & mask; | ||
159 | } | ||
160 | |||
161 | static inline int __test_and_change_bit(int nr, volatile unsigned long *p) | ||
162 | { | ||
163 | unsigned long oldval, mask = 1UL << (nr & 31); | ||
164 | |||
165 | p += nr >> 5; | ||
166 | |||
167 | oldval = *p; | ||
168 | *p = oldval ^ mask; | ||
169 | return oldval & mask; | ||
170 | } | ||
171 | |||
172 | /* | ||
173 | * This routine doesn't need to be atomic. | ||
174 | */ | ||
175 | static inline int __test_bit(int nr, const volatile unsigned long * p) | ||
176 | { | ||
177 | return (p[nr >> 5] >> (nr & 31)) & 1UL; | ||
178 | } | ||
179 | 121 | ||
180 | /* | 122 | /* |
181 | * Little endian assembly bitops. nr = 0 -> byte 0 bit 0. | 123 | * Little endian assembly bitops. nr = 0 -> byte 0 bit 0. |
@@ -211,7 +153,6 @@ extern int _find_next_bit_le(const unsigned long *p, int size, int offset); | |||
211 | #define test_and_set_bit(nr,p) ATOMIC_BITOP_LE(test_and_set_bit,nr,p) | 153 | #define test_and_set_bit(nr,p) ATOMIC_BITOP_LE(test_and_set_bit,nr,p) |
212 | #define test_and_clear_bit(nr,p) ATOMIC_BITOP_LE(test_and_clear_bit,nr,p) | 154 | #define test_and_clear_bit(nr,p) ATOMIC_BITOP_LE(test_and_clear_bit,nr,p) |
213 | #define test_and_change_bit(nr,p) ATOMIC_BITOP_LE(test_and_change_bit,nr,p) | 155 | #define test_and_change_bit(nr,p) ATOMIC_BITOP_LE(test_and_change_bit,nr,p) |
214 | #define test_bit(nr,p) __test_bit(nr,p) | ||
215 | #define find_first_zero_bit(p,sz) _find_first_zero_bit_le(p,sz) | 156 | #define find_first_zero_bit(p,sz) _find_first_zero_bit_le(p,sz) |
216 | #define find_next_zero_bit(p,sz,off) _find_next_zero_bit_le(p,sz,off) | 157 | #define find_next_zero_bit(p,sz,off) _find_next_zero_bit_le(p,sz,off) |
217 | #define find_first_bit(p,sz) _find_first_bit_le(p,sz) | 158 | #define find_first_bit(p,sz) _find_first_bit_le(p,sz) |
@@ -219,80 +160,13 @@ extern int _find_next_bit_le(const unsigned long *p, int size, int offset); | |||
219 | 160 | ||
220 | #define WORD_BITOFF_TO_LE(x) ((x)) | 161 | #define WORD_BITOFF_TO_LE(x) ((x)) |
221 | 162 | ||
222 | /* | 163 | #include <asm-generic/bitops/ffz.h> |
223 | * ffz = Find First Zero in word. Undefined if no zero exists, | 164 | #include <asm-generic/bitops/__ffs.h> |
224 | * so code should check against ~0UL first.. | 165 | #include <asm-generic/bitops/fls.h> |
225 | */ | 166 | #include <asm-generic/bitops/fls64.h> |
226 | static inline unsigned long ffz(unsigned long word) | 167 | #include <asm-generic/bitops/ffs.h> |
227 | { | 168 | #include <asm-generic/bitops/sched.h> |
228 | int k; | 169 | #include <asm-generic/bitops/hweight.h> |
229 | |||
230 | word = ~word; | ||
231 | k = 31; | ||
232 | if (word & 0x0000ffff) { k -= 16; word <<= 16; } | ||
233 | if (word & 0x00ff0000) { k -= 8; word <<= 8; } | ||
234 | if (word & 0x0f000000) { k -= 4; word <<= 4; } | ||
235 | if (word & 0x30000000) { k -= 2; word <<= 2; } | ||
236 | if (word & 0x40000000) { k -= 1; } | ||
237 | return k; | ||
238 | } | ||
239 | |||
240 | /* | ||
241 | * ffz = Find First Zero in word. Undefined if no zero exists, | ||
242 | * so code should check against ~0UL first.. | ||
243 | */ | ||
244 | static inline unsigned long __ffs(unsigned long word) | ||
245 | { | ||
246 | int k; | ||
247 | |||
248 | k = 31; | ||
249 | if (word & 0x0000ffff) { k -= 16; word <<= 16; } | ||
250 | if (word & 0x00ff0000) { k -= 8; word <<= 8; } | ||
251 | if (word & 0x0f000000) { k -= 4; word <<= 4; } | ||
252 | if (word & 0x30000000) { k -= 2; word <<= 2; } | ||
253 | if (word & 0x40000000) { k -= 1; } | ||
254 | return k; | ||
255 | } | ||
256 | |||
257 | /* | ||
258 | * fls: find last bit set. | ||
259 | */ | ||
260 | |||
261 | #define fls(x) generic_fls(x) | ||
262 | #define fls64(x) generic_fls64(x) | ||
263 | |||
264 | /* | ||
265 | * ffs: find first bit set. This is defined the same way as | ||
266 | * the libc and compiler builtin ffs routines, therefore | ||
267 | * differs in spirit from the above ffz (man ffs). | ||
268 | */ | ||
269 | |||
270 | #define ffs(x) generic_ffs(x) | ||
271 | |||
272 | /* | ||
273 | * Find first bit set in a 168-bit bitmap, where the first | ||
274 | * 128 bits are unlikely to be set. | ||
275 | */ | ||
276 | static inline int sched_find_first_bit(unsigned long *b) | ||
277 | { | ||
278 | unsigned long v; | ||
279 | unsigned int off; | ||
280 | |||
281 | for (off = 0; v = b[off], off < 4; off++) { | ||
282 | if (unlikely(v)) | ||
283 | break; | ||
284 | } | ||
285 | return __ffs(v) + off * 32; | ||
286 | } | ||
287 | |||
288 | /* | ||
289 | * hweightN: returns the hamming weight (i.e. the number | ||
290 | * of bits set) of a N-bit word | ||
291 | */ | ||
292 | |||
293 | #define hweight32(x) generic_hweight32(x) | ||
294 | #define hweight16(x) generic_hweight16(x) | ||
295 | #define hweight8(x) generic_hweight8(x) | ||
296 | 170 | ||
297 | /* | 171 | /* |
298 | * Ext2 is defined to use little-endian byte ordering. | 172 | * Ext2 is defined to use little-endian byte ordering. |
@@ -307,7 +181,7 @@ static inline int sched_find_first_bit(unsigned long *b) | |||
307 | #define ext2_clear_bit_atomic(lock,nr,p) \ | 181 | #define ext2_clear_bit_atomic(lock,nr,p) \ |
308 | test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) | 182 | test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) |
309 | #define ext2_test_bit(nr,p) \ | 183 | #define ext2_test_bit(nr,p) \ |
310 | __test_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) | 184 | test_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) |
311 | #define ext2_find_first_zero_bit(p,sz) \ | 185 | #define ext2_find_first_zero_bit(p,sz) \ |
312 | _find_first_zero_bit_le(p,sz) | 186 | _find_first_zero_bit_le(p,sz) |
313 | #define ext2_find_next_zero_bit(p,sz,off) \ | 187 | #define ext2_find_next_zero_bit(p,sz,off) \ |
@@ -320,7 +194,7 @@ static inline int sched_find_first_bit(unsigned long *b) | |||
320 | #define minix_set_bit(nr,p) \ | 194 | #define minix_set_bit(nr,p) \ |
321 | __set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) | 195 | __set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) |
322 | #define minix_test_bit(nr,p) \ | 196 | #define minix_test_bit(nr,p) \ |
323 | __test_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) | 197 | test_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) |
324 | #define minix_test_and_set_bit(nr,p) \ | 198 | #define minix_test_and_set_bit(nr,p) \ |
325 | __test_and_set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) | 199 | __test_and_set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) |
326 | #define minix_test_and_clear_bit(nr,p) \ | 200 | #define minix_test_and_clear_bit(nr,p) \ |