add SDHC support in mmc driver
[u-boot-openmoko/mini2440.git] / include / asm-m68k / bitops.h
blob0f9e8abe9c12e43e23865686e1a8edea3ae29203
1 /*
2 * bitops.h: Bit string operations on the m68k
3 */
5 #ifndef _M68K_BITOPS_H
6 #define _M68K_BITOPS_H
8 #include <linux/config.h>
9 #include <asm/byteorder.h>
11 extern void set_bit(int nr, volatile void *addr);
12 extern void clear_bit(int nr, volatile void *addr);
13 extern void change_bit(int nr, volatile void *addr);
14 extern int test_and_set_bit(int nr, volatile void *addr);
15 extern int test_and_clear_bit(int nr, volatile void *addr);
16 extern int test_and_change_bit(int nr, volatile void *addr);
18 #ifdef __KERNEL__
21 * ffs: find first bit set. This is defined the same way as
22 * the libc and compiler builtin ffs routines, therefore
23 * differs in spirit from the above ffz (man ffs).
25 extern __inline__ int ffs(int x)
27 int r = 1;
29 if (!x)
30 return 0;
31 if (!(x & 0xffff)) {
32 x >>= 16;
33 r += 16;
35 if (!(x & 0xff)) {
36 x >>= 8;
37 r += 8;
39 if (!(x & 0xf)) {
40 x >>= 4;
41 r += 4;
43 if (!(x & 3)) {
44 x >>= 2;
45 r += 2;
47 if (!(x & 1)) {
48 x >>= 1;
49 r += 1;
51 return r;
53 #define __ffs(x) (ffs(x) - 1)
55 #endif /* __KERNEL__ */
57 #endif /* _M68K_BITOPS_H */