On Wed, Nov 18, 2009 at 04:52, <[email protected]> wrote:
> Revision 7844 Author hennerich Date 2009-11-18 04:52:03 -0500 (Wed, 18 Nov
> 2009)
>
> Log Message
>
> Fix BFIN_DEPOSIT and BFIN_EXTRACT macros:
> find first bit in word (__ffs) returns 0 in case the first bit in word
> is set.
>
> Modified: trunk/arch/blackfin/include/asm/def_LPBlackfin.h (7843 => 7844)
>
> -#define BFIN_DEPOSIT(mask, x) (((x) << (__ffs(mask) - 1)) & (mask))
> -#define BFIN_EXTRACT(mask, x) (((x) & (mask)) >> (__ffs(mask) - 1))
> +#define BFIN_DEPOSIT(mask, x) (((x) << __ffs(mask)) & (mask))
> +#define BFIN_EXTRACT(mask, x) (((x) & (mask)) >> __ffs(mask))
i was going by the documentation:
/**
* ffs - find first bit set
* @x: the word to search
*
* This is defined the same way as
* the libc and compiler builtin ffs routines
and my C library does:
$ cat test.c
#include <strings.h>
#include <stdio.h>
main(){printf("%i\n", ffs(1));}
$ gcc test.c && ./a.out
1
so if you give a mask of 0x3ff, ffs() should return 1, and you dont
want to do any shifting. i'll have to double check what the kernel
does.
-mike
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits