aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-mips
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-mips')
-rw-r--r--include/asm-mips/bitops.h56
-rw-r--r--include/asm-mips/mips-boards/generic.h1
2 files changed, 25 insertions, 32 deletions
diff --git a/include/asm-mips/bitops.h b/include/asm-mips/bitops.h
index 0e71df31f81c..098cec263681 100644
--- a/include/asm-mips/bitops.h
+++ b/include/asm-mips/bitops.h
@@ -466,64 +466,56 @@ static inline unsigned long __ffs(unsigned long word)
466} 466}
467 467
468/* 468/*
469 * ffs - find first bit set. 469 * fls - find last bit set.
470 * @word: The word to search 470 * @word: The word to search
471 * 471 *
472 * Returns 1..SZLONG 472 * This is defined the same way as ffs.
473 * Returns 0 if no bit exists 473 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
474 */ 474 */
475 475static inline int fls(int word)
476static inline unsigned long ffs(unsigned long word)
477{ 476{
478 if (!word) 477 __asm__ ("clz %0, %1" : "=r" (word) : "r" (word));
479 return 0;
480 478
481 return __ffs(word) + 1; 479 return 32 - word;
482} 480}
483 481
484/* 482#if defined(CONFIG_64BIT) && defined(CONFIG_CPU_MIPS64)
485 * ffz - find first zero in word. 483static inline int fls64(__u64 word)
486 * @word: The word to search
487 *
488 * Undefined if no zero exists, so code should check against ~0UL first.
489 */
490static inline unsigned long ffz(unsigned long word)
491{ 484{
492 return __ffs (~word); 485 __asm__ ("dclz %0, %1" : "=r" (word) : "r" (word));
486
487 return 64 - word;
493} 488}
489#else
490#include <asm-generic/bitops/fls64.h>
491#endif
494 492
495/* 493/*
496 * fls - find last bit set. 494 * ffs - find first bit set.
497 * @word: The word to search 495 * @word: The word to search
498 * 496 *
499 * Returns 1..SZLONG 497 * This is defined the same way as
500 * Returns 0 if no bit exists 498 * the libc and compiler builtin ffs routines, therefore
499 * differs in spirit from the above ffz (man ffs).
501 */ 500 */
502static inline unsigned long fls(unsigned long word) 501static inline int ffs(int word)
503{ 502{
504#ifdef CONFIG_CPU_MIPS32 503 if (!word)
505 __asm__ ("clz %0, %1" : "=r" (word) : "r" (word)); 504 return 0;
506
507 return 32 - word;
508#endif
509
510#ifdef CONFIG_CPU_MIPS64
511 __asm__ ("dclz %0, %1" : "=r" (word) : "r" (word));
512 505
513 return 64 - word; 506 return fls(word & -word);
514#endif
515} 507}
516 508
517#else 509#else
518 510
519#include <asm-generic/bitops/__ffs.h> 511#include <asm-generic/bitops/__ffs.h>
520#include <asm-generic/bitops/ffs.h> 512#include <asm-generic/bitops/ffs.h>
521#include <asm-generic/bitops/ffz.h>
522#include <asm-generic/bitops/fls.h> 513#include <asm-generic/bitops/fls.h>
514#include <asm-generic/bitops/fls64.h>
523 515
524#endif /*defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64) */ 516#endif /*defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64) */
525 517
526#include <asm-generic/bitops/fls64.h> 518#include <asm-generic/bitops/ffz.h>
527#include <asm-generic/bitops/find.h> 519#include <asm-generic/bitops/find.h>
528 520
529#ifdef __KERNEL__ 521#ifdef __KERNEL__
diff --git a/include/asm-mips/mips-boards/generic.h b/include/asm-mips/mips-boards/generic.h
index cad47ce8a7e9..b98f1658cfd0 100644
--- a/include/asm-mips/mips-boards/generic.h
+++ b/include/asm-mips/mips-boards/generic.h
@@ -66,6 +66,7 @@
66#define MIPS_REVISION_CORID_CORE_FPGA2 7 66#define MIPS_REVISION_CORID_CORE_FPGA2 7
67#define MIPS_REVISION_CORID_CORE_FPGAR2 8 67#define MIPS_REVISION_CORID_CORE_FPGAR2 8
68#define MIPS_REVISION_CORID_CORE_FPGA3 9 68#define MIPS_REVISION_CORID_CORE_FPGA3 9
69#define MIPS_REVISION_CORID_CORE_24K 10
69 70
70/**** Artificial corid defines ****/ 71/**** Artificial corid defines ****/
71/* 72/*