1 #ifndef _BLACKFIN_BITOPS_H
2 #define _BLACKFIN_BITOPS_H
5 * Copyright 1992, Linus Torvalds.
8 #include <linux/compiler.h>
9 #include <asm/byteorder.h> /* swab32 */
10 #include <asm/system.h> /* save_flags */
14 #include <asm-generic/bitops/ffs.h>
15 #include <asm-generic/bitops/__ffs.h>
16 #include <asm-generic/bitops/sched.h>
17 #include <asm-generic/bitops/ffz.h>
19 static __inline__ void set_bit(int nr, volatile unsigned long *addr)
26 mask = 1 << (nr & 0x1f);
27 local_irq_save(flags);
29 local_irq_restore(flags);
32 static __inline__ void __set_bit(int nr, volatile unsigned long *addr)
38 mask = 1 << (nr & 0x1f);
43 * clear_bit() doesn't provide any barrier for the compiler.
45 #define smp_mb__before_clear_bit() barrier()
46 #define smp_mb__after_clear_bit() barrier()
48 static __inline__ void clear_bit(int nr, volatile unsigned long *addr)
54 mask = 1 << (nr & 0x1f);
55 local_irq_save(flags);
57 local_irq_restore(flags);
60 static __inline__ void __clear_bit(int nr, volatile unsigned long *addr)
66 mask = 1 << (nr & 0x1f);
70 static __inline__ void change_bit(int nr, volatile unsigned long *addr)
73 unsigned long *ADDR = (unsigned long *)addr;
76 mask = 1 << (nr & 31);
77 local_irq_save(flags);
79 local_irq_restore(flags);
82 static __inline__ void __change_bit(int nr, volatile unsigned long *addr)
85 unsigned long *ADDR = (unsigned long *)addr;
88 mask = 1 << (nr & 31);
92 static __inline__ int test_and_set_bit(int nr, void *addr)
95 volatile unsigned int *a = (volatile unsigned int *)addr;
99 mask = 1 << (nr & 0x1f);
100 local_irq_save(flags);
101 retval = (mask & *a) != 0;
103 local_irq_restore(flags);
108 static __inline__ int __test_and_set_bit(int nr, volatile unsigned long *addr)
111 volatile unsigned int *a = (volatile unsigned int *)addr;
114 mask = 1 << (nr & 0x1f);
115 retval = (mask & *a) != 0;
120 static __inline__ int test_and_clear_bit(int nr, volatile unsigned long *addr)
123 volatile unsigned int *a = (volatile unsigned int *)addr;
127 mask = 1 << (nr & 0x1f);
128 local_irq_save(flags);
129 retval = (mask & *a) != 0;
131 local_irq_restore(flags);
136 static __inline__ int __test_and_clear_bit(int nr, volatile unsigned long *addr)
139 volatile unsigned int *a = (volatile unsigned int *)addr;
142 mask = 1 << (nr & 0x1f);
143 retval = (mask & *a) != 0;
148 static __inline__ int test_and_change_bit(int nr, volatile unsigned long *addr)
151 volatile unsigned int *a = (volatile unsigned int *)addr;
155 mask = 1 << (nr & 0x1f);
156 local_irq_save(flags);
157 retval = (mask & *a) != 0;
159 local_irq_restore(flags);
163 static __inline__ int __test_and_change_bit(int nr,
164 volatile unsigned long *addr)
167 volatile unsigned int *a = (volatile unsigned int *)addr;
170 mask = 1 << (nr & 0x1f);
171 retval = (mask & *a) != 0;
177 * This routine doesn't need to be atomic.
179 static __inline__ int __constant_test_bit(int nr, const void *addr)
181 return ((1UL << (nr & 31)) &
182 (((const volatile unsigned int *)addr)[nr >> 5])) != 0;
185 static __inline__ int __test_bit(int nr, const void *addr)
187 int *a = (int *)addr;
191 mask = 1 << (nr & 0x1f);
192 return ((mask & *a) != 0);
195 #define test_bit(nr,addr) \
196 (__builtin_constant_p(nr) ? \
197 __constant_test_bit((nr),(addr)) : \
198 __test_bit((nr),(addr)))
200 #include <asm-generic/bitops/find.h>
201 #include <asm-generic/bitops/hweight.h>
203 #include <asm-generic/bitops/ext2-atomic.h>
204 #include <asm-generic/bitops/ext2-non-atomic.h>
206 #include <asm-generic/bitops/minix.h>
208 #endif /* __KERNEL__ */
210 #include <asm-generic/bitops/fls.h>
211 #include <asm-generic/bitops/fls64.h>
213 #endif /* _BLACKFIN_BITOPS_H */