]> nv-tegra.nvidia Code Review - linux-2.6.git/blob - arch/blackfin/include/asm/bitops.h
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu
[linux-2.6.git] / arch / blackfin / include / asm / bitops.h
1 /*
2  * Copyright 2004-2009 Analog Devices Inc.
3  *
4  * Licensed under the GPL-2 or later.
5  */
6
7 #ifndef _BLACKFIN_BITOPS_H
8 #define _BLACKFIN_BITOPS_H
9
10 #ifndef CONFIG_SMP
11 # include <asm-generic/bitops.h>
12 #else
13
14 #ifndef _LINUX_BITOPS_H
15 #error only <linux/bitops.h> can be included directly
16 #endif
17
18 #include <linux/compiler.h>
19 #include <asm/byteorder.h>      /* swab32 */
20
21 #include <asm-generic/bitops/ffs.h>
22 #include <asm-generic/bitops/__ffs.h>
23 #include <asm-generic/bitops/sched.h>
24 #include <asm-generic/bitops/ffz.h>
25
26 #include <linux/linkage.h>
27
28 asmlinkage int __raw_bit_set_asm(volatile unsigned long *addr, int nr);
29
30 asmlinkage int __raw_bit_clear_asm(volatile unsigned long *addr, int nr);
31
32 asmlinkage int __raw_bit_toggle_asm(volatile unsigned long *addr, int nr);
33
34 asmlinkage int __raw_bit_test_set_asm(volatile unsigned long *addr, int nr);
35
36 asmlinkage int __raw_bit_test_clear_asm(volatile unsigned long *addr, int nr);
37
38 asmlinkage int __raw_bit_test_toggle_asm(volatile unsigned long *addr, int nr);
39
40 asmlinkage int __raw_bit_test_asm(const volatile unsigned long *addr, int nr);
41
42 static inline void set_bit(int nr, volatile unsigned long *addr)
43 {
44         volatile unsigned long *a = addr + (nr >> 5);
45         __raw_bit_set_asm(a, nr & 0x1f);
46 }
47
48 static inline void clear_bit(int nr, volatile unsigned long *addr)
49 {
50         volatile unsigned long *a = addr + (nr >> 5);
51         __raw_bit_clear_asm(a, nr & 0x1f);
52 }
53
54 static inline void change_bit(int nr, volatile unsigned long *addr)
55 {
56         volatile unsigned long *a = addr + (nr >> 5);
57         __raw_bit_toggle_asm(a, nr & 0x1f);
58 }
59
60 static inline int test_bit(int nr, const volatile unsigned long *addr)
61 {
62         volatile const unsigned long *a = addr + (nr >> 5);
63         return __raw_bit_test_asm(a, nr & 0x1f) != 0;
64 }
65
66 static inline int test_and_set_bit(int nr, volatile unsigned long *addr)
67 {
68         volatile unsigned long *a = addr + (nr >> 5);
69         return __raw_bit_test_set_asm(a, nr & 0x1f);
70 }
71
72 static inline int test_and_clear_bit(int nr, volatile unsigned long *addr)
73 {
74         volatile unsigned long *a = addr + (nr >> 5);
75         return __raw_bit_test_clear_asm(a, nr & 0x1f);
76 }
77
78 static inline int test_and_change_bit(int nr, volatile unsigned long *addr)
79 {
80         volatile unsigned long *a = addr + (nr >> 5);
81         return __raw_bit_test_toggle_asm(a, nr & 0x1f);
82 }
83
84 /*
85  * clear_bit() doesn't provide any barrier for the compiler.
86  */
87 #define smp_mb__before_clear_bit()      barrier()
88 #define smp_mb__after_clear_bit()       barrier()
89
90 #include <asm-generic/bitops/non-atomic.h>
91
92 #include <asm-generic/bitops/find.h>
93 #include <asm-generic/bitops/hweight.h>
94 #include <asm-generic/bitops/lock.h>
95
96 #include <asm-generic/bitops/ext2-atomic.h>
97 #include <asm-generic/bitops/ext2-non-atomic.h>
98
99 #include <asm-generic/bitops/minix.h>
100
101 #include <asm-generic/bitops/fls.h>
102 #include <asm-generic/bitops/__fls.h>
103 #include <asm-generic/bitops/fls64.h>
104
105 #endif /* CONFIG_SMP */
106
107 #endif                          /* _BLACKFIN_BITOPS_H */