aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/spinlock.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/spinlock.h')
-rw-r--r--include/linux/spinlock.h72
1 files changed, 56 insertions, 16 deletions
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index d311a090fae7..61e5610ad165 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -46,6 +46,7 @@
46 * linux/spinlock.h: builds the final spin_*() APIs. 46 * linux/spinlock.h: builds the final spin_*() APIs.
47 */ 47 */
48 48
49#include <linux/typecheck.h>
49#include <linux/preempt.h> 50#include <linux/preempt.h>
50#include <linux/linkage.h> 51#include <linux/linkage.h>
51#include <linux/compiler.h> 52#include <linux/compiler.h>
@@ -191,23 +192,53 @@ do { \
191 192
192#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) 193#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
193 194
194#define spin_lock_irqsave(lock, flags) flags = _spin_lock_irqsave(lock) 195#define spin_lock_irqsave(lock, flags) \
195#define read_lock_irqsave(lock, flags) flags = _read_lock_irqsave(lock) 196 do { \
196#define write_lock_irqsave(lock, flags) flags = _write_lock_irqsave(lock) 197 typecheck(unsigned long, flags); \
198 flags = _spin_lock_irqsave(lock); \
199 } while (0)
200#define read_lock_irqsave(lock, flags) \
201 do { \
202 typecheck(unsigned long, flags); \
203 flags = _read_lock_irqsave(lock); \
204 } while (0)
205#define write_lock_irqsave(lock, flags) \
206 do { \
207 typecheck(unsigned long, flags); \
208 flags = _write_lock_irqsave(lock); \
209 } while (0)
197 210
198#ifdef CONFIG_DEBUG_LOCK_ALLOC 211#ifdef CONFIG_DEBUG_LOCK_ALLOC
199#define spin_lock_irqsave_nested(lock, flags, subclass) \ 212#define spin_lock_irqsave_nested(lock, flags, subclass) \
200 flags = _spin_lock_irqsave_nested(lock, subclass) 213 do { \
214 typecheck(unsigned long, flags); \
215 flags = _spin_lock_irqsave_nested(lock, subclass); \
216 } while (0)
201#else 217#else
202#define spin_lock_irqsave_nested(lock, flags, subclass) \ 218#define spin_lock_irqsave_nested(lock, flags, subclass) \
203 flags = _spin_lock_irqsave(lock) 219 do { \
220 typecheck(unsigned long, flags); \
221 flags = _spin_lock_irqsave(lock); \
222 } while (0)
204#endif 223#endif
205 224
206#else 225#else
207 226
208#define spin_lock_irqsave(lock, flags) _spin_lock_irqsave(lock, flags) 227#define spin_lock_irqsave(lock, flags) \
209#define read_lock_irqsave(lock, flags) _read_lock_irqsave(lock, flags) 228 do { \
210#define write_lock_irqsave(lock, flags) _write_lock_irqsave(lock, flags) 229 typecheck(unsigned long, flags); \
230 _spin_lock_irqsave(lock, flags); \
231 } while (0)
232#define read_lock_irqsave(lock, flags) \
233 do { \
234 typecheck(unsigned long, flags); \
235 _read_lock_irqsave(lock, flags); \
236 } while (0)
237#define write_lock_irqsave(lock, flags) \
238 do { \
239 typecheck(unsigned long, flags); \
240 _write_lock_irqsave(lock, flags); \
241 } while (0)
211#define spin_lock_irqsave_nested(lock, flags, subclass) \ 242#define spin_lock_irqsave_nested(lock, flags, subclass) \
212 spin_lock_irqsave(lock, flags) 243 spin_lock_irqsave(lock, flags)
213 244
@@ -260,16 +291,25 @@ do { \
260} while (0) 291} while (0)
261#endif 292#endif
262 293
263#define spin_unlock_irqrestore(lock, flags) \ 294#define spin_unlock_irqrestore(lock, flags) \
264 _spin_unlock_irqrestore(lock, flags) 295 do { \
296 typecheck(unsigned long, flags); \
297 _spin_unlock_irqrestore(lock, flags); \
298 } while (0)
265#define spin_unlock_bh(lock) _spin_unlock_bh(lock) 299#define spin_unlock_bh(lock) _spin_unlock_bh(lock)
266 300
267#define read_unlock_irqrestore(lock, flags) \ 301#define read_unlock_irqrestore(lock, flags) \
268 _read_unlock_irqrestore(lock, flags) 302 do { \
303 typecheck(unsigned long, flags); \
304 _read_unlock_irqrestore(lock, flags); \
305 } while (0)
269#define read_unlock_bh(lock) _read_unlock_bh(lock) 306#define read_unlock_bh(lock) _read_unlock_bh(lock)
270 307
271#define write_unlock_irqrestore(lock, flags) \ 308#define write_unlock_irqrestore(lock, flags) \
272 _write_unlock_irqrestore(lock, flags) 309 do { \
310 typecheck(unsigned long, flags); \
311 _write_unlock_irqrestore(lock, flags); \
312 } while (0)
273#define write_unlock_bh(lock) _write_unlock_bh(lock) 313#define write_unlock_bh(lock) _write_unlock_bh(lock)
274 314
275#define spin_trylock_bh(lock) __cond_lock(lock, _spin_trylock_bh(lock)) 315#define spin_trylock_bh(lock) __cond_lock(lock, _spin_trylock_bh(lock))