diff options
Diffstat (limited to 'include/asm-generic')
-rw-r--r-- | include/asm-generic/bitops/atomic.h | 27 | ||||
-rw-r--r-- | include/asm-generic/bitops/non-atomic.h | 29 |
2 files changed, 25 insertions, 31 deletions
diff --git a/include/asm-generic/bitops/atomic.h b/include/asm-generic/bitops/atomic.h index cd8a9641bd66..4657f3e410fc 100644 --- a/include/asm-generic/bitops/atomic.h +++ b/include/asm-generic/bitops/atomic.h | |||
@@ -3,9 +3,6 @@ | |||
3 | 3 | ||
4 | #include <asm/types.h> | 4 | #include <asm/types.h> |
5 | 5 | ||
6 | #define BITOP_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) | ||
7 | #define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) | ||
8 | |||
9 | #ifdef CONFIG_SMP | 6 | #ifdef CONFIG_SMP |
10 | #include <asm/spinlock.h> | 7 | #include <asm/spinlock.h> |
11 | #include <asm/cache.h> /* we use L1_CACHE_BYTES */ | 8 | #include <asm/cache.h> /* we use L1_CACHE_BYTES */ |
@@ -66,8 +63,8 @@ extern raw_spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned; | |||
66 | */ | 63 | */ |
67 | static inline void set_bit(int nr, volatile unsigned long *addr) | 64 | static inline void set_bit(int nr, volatile unsigned long *addr) |
68 | { | 65 | { |
69 | unsigned long mask = BITOP_MASK(nr); | 66 | unsigned long mask = BIT_MASK(nr); |
70 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | 67 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); |
71 | unsigned long flags; | 68 | unsigned long flags; |
72 | 69 | ||
73 | _atomic_spin_lock_irqsave(p, flags); | 70 | _atomic_spin_lock_irqsave(p, flags); |
@@ -87,8 +84,8 @@ static inline void set_bit(int nr, volatile unsigned long *addr) | |||
87 | */ | 84 | */ |
88 | static inline void clear_bit(int nr, volatile unsigned long *addr) | 85 | static inline void clear_bit(int nr, volatile unsigned long *addr) |
89 | { | 86 | { |
90 | unsigned long mask = BITOP_MASK(nr); | 87 | unsigned long mask = BIT_MASK(nr); |
91 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | 88 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); |
92 | unsigned long flags; | 89 | unsigned long flags; |
93 | 90 | ||
94 | _atomic_spin_lock_irqsave(p, flags); | 91 | _atomic_spin_lock_irqsave(p, flags); |
@@ -108,8 +105,8 @@ static inline void clear_bit(int nr, volatile unsigned long *addr) | |||
108 | */ | 105 | */ |
109 | static inline void change_bit(int nr, volatile unsigned long *addr) | 106 | static inline void change_bit(int nr, volatile unsigned long *addr) |
110 | { | 107 | { |
111 | unsigned long mask = BITOP_MASK(nr); | 108 | unsigned long mask = BIT_MASK(nr); |
112 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | 109 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); |
113 | unsigned long flags; | 110 | unsigned long flags; |
114 | 111 | ||
115 | _atomic_spin_lock_irqsave(p, flags); | 112 | _atomic_spin_lock_irqsave(p, flags); |
@@ -128,8 +125,8 @@ static inline void change_bit(int nr, volatile unsigned long *addr) | |||
128 | */ | 125 | */ |
129 | static inline int test_and_set_bit(int nr, volatile unsigned long *addr) | 126 | static inline int test_and_set_bit(int nr, volatile unsigned long *addr) |
130 | { | 127 | { |
131 | unsigned long mask = BITOP_MASK(nr); | 128 | unsigned long mask = BIT_MASK(nr); |
132 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | 129 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); |
133 | unsigned long old; | 130 | unsigned long old; |
134 | unsigned long flags; | 131 | unsigned long flags; |
135 | 132 | ||
@@ -152,8 +149,8 @@ static inline int test_and_set_bit(int nr, volatile unsigned long *addr) | |||
152 | */ | 149 | */ |
153 | static inline int test_and_clear_bit(int nr, volatile unsigned long *addr) | 150 | static inline int test_and_clear_bit(int nr, volatile unsigned long *addr) |
154 | { | 151 | { |
155 | unsigned long mask = BITOP_MASK(nr); | 152 | unsigned long mask = BIT_MASK(nr); |
156 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | 153 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); |
157 | unsigned long old; | 154 | unsigned long old; |
158 | unsigned long flags; | 155 | unsigned long flags; |
159 | 156 | ||
@@ -175,8 +172,8 @@ static inline int test_and_clear_bit(int nr, volatile unsigned long *addr) | |||
175 | */ | 172 | */ |
176 | static inline int test_and_change_bit(int nr, volatile unsigned long *addr) | 173 | static inline int test_and_change_bit(int nr, volatile unsigned long *addr) |
177 | { | 174 | { |
178 | unsigned long mask = BITOP_MASK(nr); | 175 | unsigned long mask = BIT_MASK(nr); |
179 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | 176 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); |
180 | unsigned long old; | 177 | unsigned long old; |
181 | unsigned long flags; | 178 | unsigned long flags; |
182 | 179 | ||
diff --git a/include/asm-generic/bitops/non-atomic.h b/include/asm-generic/bitops/non-atomic.h index 46a825cf2ae1..697cc2b7e0f0 100644 --- a/include/asm-generic/bitops/non-atomic.h +++ b/include/asm-generic/bitops/non-atomic.h | |||
@@ -3,9 +3,6 @@ | |||
3 | 3 | ||
4 | #include <asm/types.h> | 4 | #include <asm/types.h> |
5 | 5 | ||
6 | #define BITOP_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) | ||
7 | #define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) | ||
8 | |||
9 | /** | 6 | /** |
10 | * __set_bit - Set a bit in memory | 7 | * __set_bit - Set a bit in memory |
11 | * @nr: the bit to set | 8 | * @nr: the bit to set |
@@ -17,16 +14,16 @@ | |||
17 | */ | 14 | */ |
18 | static inline void __set_bit(int nr, volatile unsigned long *addr) | 15 | static inline void __set_bit(int nr, volatile unsigned long *addr) |
19 | { | 16 | { |
20 | unsigned long mask = BITOP_MASK(nr); | 17 | unsigned long mask = BIT_MASK(nr); |
21 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | 18 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); |
22 | 19 | ||
23 | *p |= mask; | 20 | *p |= mask; |
24 | } | 21 | } |
25 | 22 | ||
26 | static inline void __clear_bit(int nr, volatile unsigned long *addr) | 23 | static inline void __clear_bit(int nr, volatile unsigned long *addr) |
27 | { | 24 | { |
28 | unsigned long mask = BITOP_MASK(nr); | 25 | unsigned long mask = BIT_MASK(nr); |
29 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | 26 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); |
30 | 27 | ||
31 | *p &= ~mask; | 28 | *p &= ~mask; |
32 | } | 29 | } |
@@ -42,8 +39,8 @@ static inline void __clear_bit(int nr, volatile unsigned long *addr) | |||
42 | */ | 39 | */ |
43 | static inline void __change_bit(int nr, volatile unsigned long *addr) | 40 | static inline void __change_bit(int nr, volatile unsigned long *addr) |
44 | { | 41 | { |
45 | unsigned long mask = BITOP_MASK(nr); | 42 | unsigned long mask = BIT_MASK(nr); |
46 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | 43 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); |
47 | 44 | ||
48 | *p ^= mask; | 45 | *p ^= mask; |
49 | } | 46 | } |
@@ -59,8 +56,8 @@ static inline void __change_bit(int nr, volatile unsigned long *addr) | |||
59 | */ | 56 | */ |
60 | static inline int __test_and_set_bit(int nr, volatile unsigned long *addr) | 57 | static inline int __test_and_set_bit(int nr, volatile unsigned long *addr) |
61 | { | 58 | { |
62 | unsigned long mask = BITOP_MASK(nr); | 59 | unsigned long mask = BIT_MASK(nr); |
63 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | 60 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); |
64 | unsigned long old = *p; | 61 | unsigned long old = *p; |
65 | 62 | ||
66 | *p = old | mask; | 63 | *p = old | mask; |
@@ -78,8 +75,8 @@ static inline int __test_and_set_bit(int nr, volatile unsigned long *addr) | |||
78 | */ | 75 | */ |
79 | static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr) | 76 | static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr) |
80 | { | 77 | { |
81 | unsigned long mask = BITOP_MASK(nr); | 78 | unsigned long mask = BIT_MASK(nr); |
82 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | 79 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); |
83 | unsigned long old = *p; | 80 | unsigned long old = *p; |
84 | 81 | ||
85 | *p = old & ~mask; | 82 | *p = old & ~mask; |
@@ -90,8 +87,8 @@ static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr) | |||
90 | static inline int __test_and_change_bit(int nr, | 87 | static inline int __test_and_change_bit(int nr, |
91 | volatile unsigned long *addr) | 88 | volatile unsigned long *addr) |
92 | { | 89 | { |
93 | unsigned long mask = BITOP_MASK(nr); | 90 | unsigned long mask = BIT_MASK(nr); |
94 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | 91 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); |
95 | unsigned long old = *p; | 92 | unsigned long old = *p; |
96 | 93 | ||
97 | *p = old ^ mask; | 94 | *p = old ^ mask; |
@@ -105,7 +102,7 @@ static inline int __test_and_change_bit(int nr, | |||
105 | */ | 102 | */ |
106 | static inline int test_bit(int nr, const volatile unsigned long *addr) | 103 | static inline int test_bit(int nr, const volatile unsigned long *addr) |
107 | { | 104 | { |
108 | return 1UL & (addr[BITOP_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); | 105 | return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); |
109 | } | 106 | } |
110 | 107 | ||
111 | #endif /* _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ */ | 108 | #endif /* _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ */ |