diff options
Diffstat (limited to 'include/asm-cris/bitops.h')
-rw-r--r-- | include/asm-cris/bitops.h | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/include/asm-cris/bitops.h b/include/asm-cris/bitops.h index d7861115d731..e3da57f97964 100644 --- a/include/asm-cris/bitops.h +++ b/include/asm-cris/bitops.h | |||
@@ -16,6 +16,7 @@ | |||
16 | 16 | ||
17 | #include <asm/arch/bitops.h> | 17 | #include <asm/arch/bitops.h> |
18 | #include <asm/system.h> | 18 | #include <asm/system.h> |
19 | #include <asm/atomic.h> | ||
19 | #include <linux/compiler.h> | 20 | #include <linux/compiler.h> |
20 | 21 | ||
21 | /* | 22 | /* |
@@ -88,7 +89,7 @@ struct __dummy { unsigned long a[100]; }; | |||
88 | * It also implies a memory barrier. | 89 | * It also implies a memory barrier. |
89 | */ | 90 | */ |
90 | 91 | ||
91 | extern inline int test_and_set_bit(int nr, void *addr) | 92 | extern inline int test_and_set_bit(int nr, volatile unsigned long *addr) |
92 | { | 93 | { |
93 | unsigned int mask, retval; | 94 | unsigned int mask, retval; |
94 | unsigned long flags; | 95 | unsigned long flags; |
@@ -96,15 +97,15 @@ extern inline int test_and_set_bit(int nr, void *addr) | |||
96 | 97 | ||
97 | adr += nr >> 5; | 98 | adr += nr >> 5; |
98 | mask = 1 << (nr & 0x1f); | 99 | mask = 1 << (nr & 0x1f); |
99 | local_save_flags(flags); | 100 | cris_atomic_save(addr, flags); |
100 | local_irq_disable(); | ||
101 | retval = (mask & *adr) != 0; | 101 | retval = (mask & *adr) != 0; |
102 | *adr |= mask; | 102 | *adr |= mask; |
103 | cris_atomic_restore(addr, flags); | ||
103 | local_irq_restore(flags); | 104 | local_irq_restore(flags); |
104 | return retval; | 105 | return retval; |
105 | } | 106 | } |
106 | 107 | ||
107 | extern inline int __test_and_set_bit(int nr, void *addr) | 108 | extern inline int __test_and_set_bit(int nr, volatile unsigned long *addr) |
108 | { | 109 | { |
109 | unsigned int mask, retval; | 110 | unsigned int mask, retval; |
110 | unsigned int *adr = (unsigned int *)addr; | 111 | unsigned int *adr = (unsigned int *)addr; |
@@ -131,7 +132,7 @@ extern inline int __test_and_set_bit(int nr, void *addr) | |||
131 | * It also implies a memory barrier. | 132 | * It also implies a memory barrier. |
132 | */ | 133 | */ |
133 | 134 | ||
134 | extern inline int test_and_clear_bit(int nr, void *addr) | 135 | extern inline int test_and_clear_bit(int nr, volatile unsigned long *addr) |
135 | { | 136 | { |
136 | unsigned int mask, retval; | 137 | unsigned int mask, retval; |
137 | unsigned long flags; | 138 | unsigned long flags; |
@@ -139,11 +140,10 @@ extern inline int test_and_clear_bit(int nr, void *addr) | |||
139 | 140 | ||
140 | adr += nr >> 5; | 141 | adr += nr >> 5; |
141 | mask = 1 << (nr & 0x1f); | 142 | mask = 1 << (nr & 0x1f); |
142 | local_save_flags(flags); | 143 | cris_atomic_save(addr, flags); |
143 | local_irq_disable(); | ||
144 | retval = (mask & *adr) != 0; | 144 | retval = (mask & *adr) != 0; |
145 | *adr &= ~mask; | 145 | *adr &= ~mask; |
146 | local_irq_restore(flags); | 146 | cris_atomic_restore(addr, flags); |
147 | return retval; | 147 | return retval; |
148 | } | 148 | } |
149 | 149 | ||
@@ -157,7 +157,7 @@ extern inline int test_and_clear_bit(int nr, void *addr) | |||
157 | * but actually fail. You must protect multiple accesses with a lock. | 157 | * but actually fail. You must protect multiple accesses with a lock. |
158 | */ | 158 | */ |
159 | 159 | ||
160 | extern inline int __test_and_clear_bit(int nr, void *addr) | 160 | extern inline int __test_and_clear_bit(int nr, volatile unsigned long *addr) |
161 | { | 161 | { |
162 | unsigned int mask, retval; | 162 | unsigned int mask, retval; |
163 | unsigned int *adr = (unsigned int *)addr; | 163 | unsigned int *adr = (unsigned int *)addr; |
@@ -177,24 +177,23 @@ extern inline int __test_and_clear_bit(int nr, void *addr) | |||
177 | * It also implies a memory barrier. | 177 | * It also implies a memory barrier. |
178 | */ | 178 | */ |
179 | 179 | ||
180 | extern inline int test_and_change_bit(int nr, void *addr) | 180 | extern inline int test_and_change_bit(int nr, volatile unsigned long *addr) |
181 | { | 181 | { |
182 | unsigned int mask, retval; | 182 | unsigned int mask, retval; |
183 | unsigned long flags; | 183 | unsigned long flags; |
184 | unsigned int *adr = (unsigned int *)addr; | 184 | unsigned int *adr = (unsigned int *)addr; |
185 | adr += nr >> 5; | 185 | adr += nr >> 5; |
186 | mask = 1 << (nr & 0x1f); | 186 | mask = 1 << (nr & 0x1f); |
187 | local_save_flags(flags); | 187 | cris_atomic_save(addr, flags); |
188 | local_irq_disable(); | ||
189 | retval = (mask & *adr) != 0; | 188 | retval = (mask & *adr) != 0; |
190 | *adr ^= mask; | 189 | *adr ^= mask; |
191 | local_irq_restore(flags); | 190 | cris_atomic_restore(addr, flags); |
192 | return retval; | 191 | return retval; |
193 | } | 192 | } |
194 | 193 | ||
195 | /* WARNING: non atomic and it can be reordered! */ | 194 | /* WARNING: non atomic and it can be reordered! */ |
196 | 195 | ||
197 | extern inline int __test_and_change_bit(int nr, void *addr) | 196 | extern inline int __test_and_change_bit(int nr, volatile unsigned long *addr) |
198 | { | 197 | { |
199 | unsigned int mask, retval; | 198 | unsigned int mask, retval; |
200 | unsigned int *adr = (unsigned int *)addr; | 199 | unsigned int *adr = (unsigned int *)addr; |
@@ -215,7 +214,7 @@ extern inline int __test_and_change_bit(int nr, void *addr) | |||
215 | * This routine doesn't need to be atomic. | 214 | * This routine doesn't need to be atomic. |
216 | */ | 215 | */ |
217 | 216 | ||
218 | extern inline int test_bit(int nr, const void *addr) | 217 | extern inline int test_bit(int nr, const volatile unsigned long *addr) |
219 | { | 218 | { |
220 | unsigned int mask; | 219 | unsigned int mask; |
221 | unsigned int *adr = (unsigned int *)addr; | 220 | unsigned int *adr = (unsigned int *)addr; |
@@ -259,7 +258,7 @@ extern inline int test_bit(int nr, const void *addr) | |||
259 | * @offset: The bitnumber to start searching at | 258 | * @offset: The bitnumber to start searching at |
260 | * @size: The maximum size to search | 259 | * @size: The maximum size to search |
261 | */ | 260 | */ |
262 | extern inline int find_next_zero_bit (void * addr, int size, int offset) | 261 | extern inline int find_next_zero_bit (const unsigned long * addr, int size, int offset) |
263 | { | 262 | { |
264 | unsigned long *p = ((unsigned long *) addr) + (offset >> 5); | 263 | unsigned long *p = ((unsigned long *) addr) + (offset >> 5); |
265 | unsigned long result = offset & ~31UL; | 264 | unsigned long result = offset & ~31UL; |
@@ -301,7 +300,7 @@ extern inline int find_next_zero_bit (void * addr, int size, int offset) | |||
301 | * @offset: The bitnumber to start searching at | 300 | * @offset: The bitnumber to start searching at |
302 | * @size: The maximum size to search | 301 | * @size: The maximum size to search |
303 | */ | 302 | */ |
304 | static __inline__ int find_next_bit(void *addr, int size, int offset) | 303 | static __inline__ int find_next_bit(const unsigned long *addr, int size, int offset) |
305 | { | 304 | { |
306 | unsigned long *p = ((unsigned long *) addr) + (offset >> 5); | 305 | unsigned long *p = ((unsigned long *) addr) + (offset >> 5); |
307 | unsigned long result = offset & ~31UL; | 306 | unsigned long result = offset & ~31UL; |
@@ -367,7 +366,7 @@ found_middle: | |||
367 | #define minix_test_bit(nr,addr) test_bit(nr,addr) | 366 | #define minix_test_bit(nr,addr) test_bit(nr,addr) |
368 | #define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size) | 367 | #define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size) |
369 | 368 | ||
370 | extern inline int sched_find_first_bit(unsigned long *b) | 369 | extern inline int sched_find_first_bit(const unsigned long *b) |
371 | { | 370 | { |
372 | if (unlikely(b[0])) | 371 | if (unlikely(b[0])) |
373 | return __ffs(b[0]); | 372 | return __ffs(b[0]); |