1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_METAG_BITOPS_H
3 #define __ASM_METAG_BITOPS_H
5 #include <linux/compiler.h>
6 #include <asm/barrier.h>
7 #include <asm/global_lock.h>
11 * These functions are the basis of our bit ops.
13 static inline void set_bit(unsigned int bit, volatile unsigned long *p)
16 unsigned long mask = 1UL << (bit & 31);
20 __global_lock1(flags);
23 __global_unlock1(flags);
26 static inline void clear_bit(unsigned int bit, volatile unsigned long *p)
29 unsigned long mask = 1UL << (bit & 31);
33 __global_lock1(flags);
36 __global_unlock1(flags);
39 static inline void change_bit(unsigned int bit, volatile unsigned long *p)
42 unsigned long mask = 1UL << (bit & 31);
46 __global_lock1(flags);
49 __global_unlock1(flags);
52 static inline int test_and_set_bit(unsigned int bit, volatile unsigned long *p)
56 unsigned long mask = 1UL << (bit & 31);
60 __global_lock1(flags);
66 __global_unlock1(flags);
68 return (old & mask) != 0;
71 static inline int test_and_clear_bit(unsigned int bit,
72 volatile unsigned long *p)
76 unsigned long mask = 1UL << (bit & 31);
80 __global_lock1(flags);
86 __global_unlock1(flags);
88 return (old & mask) != 0;
91 static inline int test_and_change_bit(unsigned int bit,
92 volatile unsigned long *p)
96 unsigned long mask = 1UL << (bit & 31);
100 __global_lock1(flags);
104 __global_unlock1(flags);
106 return (old & mask) != 0;
110 #include <asm-generic/bitops/atomic.h>
111 #endif /* CONFIG_SMP */
113 #include <asm-generic/bitops/non-atomic.h>
114 #include <asm-generic/bitops/find.h>
115 #include <asm-generic/bitops/ffs.h>
116 #include <asm-generic/bitops/__ffs.h>
117 #include <asm-generic/bitops/ffz.h>
118 #include <asm-generic/bitops/fls.h>
119 #include <asm-generic/bitops/__fls.h>
120 #include <asm-generic/bitops/fls64.h>
121 #include <asm-generic/bitops/hweight.h>
122 #include <asm-generic/bitops/lock.h>
123 #include <asm-generic/bitops/sched.h>
124 #include <asm-generic/bitops/le.h>
125 #include <asm-generic/bitops/ext2-atomic.h>
127 #endif /* __ASM_METAG_BITOPS_H */