Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] bitops: v850: use generic bitops

- remove ffz()
- remove find_{next,first}{,_zero}_bit()
- remove generic_ffs()
- remove generic_fls()
- remove generic_fls64()
- remove __ffs()
- remove sched_find_first_bit()
- remove generic_hweight{32,16,8}()
- remove ext2_{set,clear,test,find_first_zero,find_next_zero}_bit()
- remove minix_{test,set,test_and_clear,test,find_first_zero}_bit()

Signed-off-by: Akinobu Mita <mita@miraclelinux.com>
Cc: Miles Bader <uclinux-v850@lsi.nec.co.jp>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Akinobu Mita and committed by
Linus Torvalds
a58259cd 2d78d4be

+17 -209
+6
arch/v850/Kconfig
··· 16 16 config RWSEM_XCHGADD_ALGORITHM 17 17 bool 18 18 default n 19 + config GENERIC_FIND_NEXT_BIT 20 + bool 21 + default y 22 + config GENERIC_HWEIGHT 23 + bool 24 + default y 19 25 config GENERIC_CALIBRATE_DELAY 20 26 bool 21 27 default y
+11 -209
include/asm-v850/bitops.h
··· 22 22 23 23 #ifdef __KERNEL__ 24 24 25 + #include <asm-generic/bitops/ffz.h> 26 + 25 27 /* 26 28 * The __ functions are not atomic 27 29 */ 28 - 29 - /* 30 - * ffz = Find First Zero in word. Undefined if no zero exists, 31 - * so code should check against ~0UL first.. 32 - */ 33 - static inline unsigned long ffz (unsigned long word) 34 - { 35 - unsigned long result = 0; 36 - 37 - while (word & 1) { 38 - result++; 39 - word >>= 1; 40 - } 41 - return result; 42 - } 43 - 44 30 45 31 /* In the following constant-bit-op macros, a "g" constraint is used when 46 32 we really need an integer ("i" constraint). This is to avoid ··· 139 153 #define smp_mb__before_clear_bit() barrier () 140 154 #define smp_mb__after_clear_bit() barrier () 141 155 156 + #include <asm-generic/bitops/ffs.h> 157 + #include <asm-generic/bitops/fls.h> 158 + #include <asm-generic/bitops/fls64.h> 159 + #include <asm-generic/bitops/__ffs.h> 160 + #include <asm-generic/bitops/find.h> 161 + #include <asm-generic/bitops/sched.h> 162 + #include <asm-generic/bitops/hweight.h> 142 163 143 - #define find_first_zero_bit(addr, size) \ 144 - find_next_zero_bit ((addr), (size), 0) 145 - 146 - static inline int find_next_zero_bit(const void *addr, int size, int offset) 147 - { 148 - unsigned long *p = ((unsigned long *) addr) + (offset >> 5); 149 - unsigned long result = offset & ~31UL; 150 - unsigned long tmp; 151 - 152 - if (offset >= size) 153 - return size; 154 - size -= result; 155 - offset &= 31UL; 156 - if (offset) { 157 - tmp = * (p++); 158 - tmp |= ~0UL >> (32-offset); 159 - if (size < 32) 160 - goto found_first; 161 - if (~tmp) 162 - goto found_middle; 163 - size -= 32; 164 - result += 32; 165 - } 166 - while (size & ~31UL) { 167 - if (~ (tmp = * (p++))) 168 - goto found_middle; 169 - result += 32; 170 - size -= 32; 171 - } 172 - if (!size) 173 - return result; 174 - tmp = *p; 175 - 176 - found_first: 177 - tmp |= ~0UL << size; 178 - found_middle: 179 - return result + ffz (tmp); 180 - } 181 - 182 - 183 - /* This is the same as generic_ffs, but we can't use that because it's 184 - inline and the #include order mucks things up. */ 185 - static inline int generic_ffs_for_find_next_bit(int x) 186 - { 187 - int r = 1; 188 - 189 - if (!x) 190 - return 0; 191 - if (!(x & 0xffff)) { 192 - x >>= 16; 193 - r += 16; 194 - } 195 - if (!(x & 0xff)) { 196 - x >>= 8; 197 - r += 8; 198 - } 199 - if (!(x & 0xf)) { 200 - x >>= 4; 201 - r += 4; 202 - } 203 - if (!(x & 3)) { 204 - x >>= 2; 205 - r += 2; 206 - } 207 - if (!(x & 1)) { 208 - x >>= 1; 209 - r += 1; 210 - } 211 - return r; 212 - } 213 - 214 - /* 215 - * Find next one bit in a bitmap reasonably efficiently. 216 - */ 217 - static __inline__ unsigned long find_next_bit(const unsigned long *addr, 218 - unsigned long size, unsigned long offset) 219 - { 220 - unsigned int *p = ((unsigned int *) addr) + (offset >> 5); 221 - unsigned int result = offset & ~31UL; 222 - unsigned int tmp; 223 - 224 - if (offset >= size) 225 - return size; 226 - size -= result; 227 - offset &= 31UL; 228 - if (offset) { 229 - tmp = *p++; 230 - tmp &= ~0UL << offset; 231 - if (size < 32) 232 - goto found_first; 233 - if (tmp) 234 - goto found_middle; 235 - size -= 32; 236 - result += 32; 237 - } 238 - while (size >= 32) { 239 - if ((tmp = *p++) != 0) 240 - goto found_middle; 241 - result += 32; 242 - size -= 32; 243 - } 244 - if (!size) 245 - return result; 246 - tmp = *p; 247 - 248 - found_first: 249 - tmp &= ~0UL >> (32 - size); 250 - if (tmp == 0UL) /* Are any bits set? */ 251 - return result + size; /* Nope. */ 252 - found_middle: 253 - return result + generic_ffs_for_find_next_bit(tmp); 254 - } 255 - 256 - /* 257 - * find_first_bit - find the first set bit in a memory region 258 - */ 259 - #define find_first_bit(addr, size) \ 260 - find_next_bit((addr), (size), 0) 261 - 262 - 263 - #define ffs(x) generic_ffs (x) 264 - #define fls(x) generic_fls (x) 265 - #define fls64(x) generic_fls64(x) 266 - #define __ffs(x) ffs(x) 267 - 268 - 269 - /* 270 - * This is just `generic_ffs' from <linux/bitops.h>, except that it assumes 271 - * that at least one bit is set, and returns the real index of the bit 272 - * (rather than the bit index + 1, like ffs does). 273 - */ 274 - static inline int sched_ffs(int x) 275 - { 276 - int r = 0; 277 - 278 - if (!(x & 0xffff)) { 279 - x >>= 16; 280 - r += 16; 281 - } 282 - if (!(x & 0xff)) { 283 - x >>= 8; 284 - r += 8; 285 - } 286 - if (!(x & 0xf)) { 287 - x >>= 4; 288 - r += 4; 289 - } 290 - if (!(x & 3)) { 291 - x >>= 2; 292 - r += 2; 293 - } 294 - if (!(x & 1)) { 295 - x >>= 1; 296 - r += 1; 297 - } 298 - return r; 299 - } 300 - 301 - /* 302 - * Every architecture must define this function. It's the fastest 303 - * way of searching a 140-bit bitmap where the first 100 bits are 304 - * unlikely to be set. It's guaranteed that at least one of the 140 305 - * bits is set. 306 - */ 307 - static inline int sched_find_first_bit(unsigned long *b) 308 - { 309 - unsigned offs = 0; 310 - while (! *b) { 311 - b++; 312 - offs += 32; 313 - } 314 - return sched_ffs (*b) + offs; 315 - } 316 - 317 - /* 318 - * hweightN: returns the hamming weight (i.e. the number 319 - * of bits set) of a N-bit word 320 - */ 321 - #define hweight32(x) generic_hweight32 (x) 322 - #define hweight16(x) generic_hweight16 (x) 323 - #define hweight8(x) generic_hweight8 (x) 324 - 325 - #define ext2_set_bit __test_and_set_bit 164 + #include <asm-generic/bitops/ext2-non-atomic.h> 326 165 #define ext2_set_bit_atomic(l,n,a) test_and_set_bit(n,a) 327 - #define ext2_clear_bit __test_and_clear_bit 328 166 #define ext2_clear_bit_atomic(l,n,a) test_and_clear_bit(n,a) 329 - #define ext2_test_bit test_bit 330 - #define ext2_find_first_zero_bit find_first_zero_bit 331 - #define ext2_find_next_zero_bit find_next_zero_bit 332 167 333 - /* Bitmap functions for the minix filesystem. */ 334 - #define minix_test_and_set_bit __test_and_set_bit 335 - #define minix_set_bit __set_bit 336 - #define minix_test_and_clear_bit __test_and_clear_bit 337 - #define minix_test_bit test_bit 338 - #define minix_find_first_zero_bit find_first_zero_bit 168 + #include <asm-generic/bitops/minix.h> 339 169 340 170 #endif /* __KERNEL__ */ 341 171