Skip to content

Commit

Permalink
frv: define __fls
Browse files Browse the repository at this point in the history
Like fls, but can't be handed 0 and returns the bit number.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
Rusty Russell committed Jan 3, 2009
1 parent 0999769 commit ee38e51
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/asm-frv/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,19 @@ int __ffs(unsigned long x)
return 31 - bit;
}

/**
* __fls - find last (most-significant) set bit in a long word
* @word: the word to search
*
* Undefined if no set bit exists, so code should check against 0 first.
*/
static inline unsigned long __fls(unsigned long word)
{
unsigned long bit;
asm("scan %1,gr0,%0" : "=r"(bit) : "r"(word));
return bit;
}

/*
* special slimline version of fls() for calculating ilog2_u32()
* - note: no protection against n == 0
Expand Down

0 comments on commit ee38e51

Please sign in to comment.