diff options
author | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2007-05-31 00:57:05 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2007-05-31 00:57:05 -0400 |
commit | 5bc65793cbf8da0d35f19ef025dda22887e79e80 (patch) | |
tree | 8291998abd73055de6f487fafa174ee2a5d3afee /include/asm-alpha/bitops.h | |
parent | 6edae708bf77e012d855a7e2c7766f211d234f4f (diff) | |
parent | 3f0a6766e0cc5a577805732e5adb50a585c58175 (diff) |
[SCSI] Merge up to linux-2.6 head
Conflicts:
drivers/scsi/jazz_esp.c
Same changes made by both SCSI and SPARC trees: problem with UTF-8
conversion in the copyright.
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'include/asm-alpha/bitops.h')
-rw-r--r-- | include/asm-alpha/bitops.h | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/include/asm-alpha/bitops.h b/include/asm-alpha/bitops.h index 4b6ef7f21b93..3a0cbeb03fa1 100644 --- a/include/asm-alpha/bitops.h +++ b/include/asm-alpha/bitops.h | |||
@@ -313,32 +313,29 @@ static inline int ffs(int word) | |||
313 | * fls: find last bit set. | 313 | * fls: find last bit set. |
314 | */ | 314 | */ |
315 | #if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67) | 315 | #if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67) |
316 | static inline int fls(int word) | 316 | static inline int fls64(unsigned long word) |
317 | { | 317 | { |
318 | return 64 - __kernel_ctlz(word & 0xffffffff); | 318 | return 64 - __kernel_ctlz(word); |
319 | } | 319 | } |
320 | #else | 320 | #else |
321 | #include <asm-generic/bitops/fls.h> | 321 | extern const unsigned char __flsm1_tab[256]; |
322 | #endif | ||
323 | #include <asm-generic/bitops/fls64.h> | ||
324 | 322 | ||
325 | /* Compute powers of two for the given integer. */ | 323 | static inline int fls64(unsigned long x) |
326 | static inline long floor_log2(unsigned long word) | ||
327 | { | 324 | { |
328 | #if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67) | 325 | unsigned long t, a, r; |
329 | return 63 - __kernel_ctlz(word); | 326 | |
330 | #else | 327 | t = __kernel_cmpbge (x, 0x0101010101010101); |
331 | long bit; | 328 | a = __flsm1_tab[t]; |
332 | for (bit = -1; word ; bit++) | 329 | t = __kernel_extbl (x, a); |
333 | word >>= 1; | 330 | r = a*8 + __flsm1_tab[t] + (x != 0); |
334 | return bit; | 331 | |
335 | #endif | 332 | return r; |
336 | } | 333 | } |
334 | #endif | ||
337 | 335 | ||
338 | static inline long ceil_log2(unsigned long word) | 336 | static inline int fls(int x) |
339 | { | 337 | { |
340 | long bit = floor_log2(word); | 338 | return fls64((unsigned int) x); |
341 | return bit + (word > (1UL << bit)); | ||
342 | } | 339 | } |
343 | 340 | ||
344 | /* | 341 | /* |
@@ -353,9 +350,20 @@ static inline unsigned long hweight64(unsigned long w) | |||
353 | return __kernel_ctpop(w); | 350 | return __kernel_ctpop(w); |
354 | } | 351 | } |
355 | 352 | ||
356 | #define hweight32(x) (unsigned int) hweight64((x) & 0xfffffffful) | 353 | static inline unsigned int hweight32(unsigned int w) |
357 | #define hweight16(x) (unsigned int) hweight64((x) & 0xfffful) | 354 | { |
358 | #define hweight8(x) (unsigned int) hweight64((x) & 0xfful) | 355 | return hweight64(w); |
356 | } | ||
357 | |||
358 | static inline unsigned int hweight16(unsigned int w) | ||
359 | { | ||
360 | return hweight64(w & 0xffff); | ||
361 | } | ||
362 | |||
363 | static inline unsigned int hweight8(unsigned int w) | ||
364 | { | ||
365 | return hweight64(w & 0xff); | ||
366 | } | ||
359 | #else | 367 | #else |
360 | #include <asm-generic/bitops/hweight.h> | 368 | #include <asm-generic/bitops/hweight.h> |
361 | #endif | 369 | #endif |