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.h78
1 files changed, 62 insertions, 16 deletions
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index d311a090fae7..e0c0fccced46 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>
@@ -182,8 +183,14 @@ do { \
182 183
183#ifdef CONFIG_DEBUG_LOCK_ALLOC 184#ifdef CONFIG_DEBUG_LOCK_ALLOC
184# define spin_lock_nested(lock, subclass) _spin_lock_nested(lock, subclass) 185# define spin_lock_nested(lock, subclass) _spin_lock_nested(lock, subclass)
186# define spin_lock_nest_lock(lock, nest_lock) \
187 do { \
188 typecheck(struct lockdep_map *, &(nest_lock)->dep_map);\
189 _spin_lock_nest_lock(lock, &(nest_lock)->dep_map); \
190 } while (0)
185#else 191#else
186# define spin_lock_nested(lock, subclass) _spin_lock(lock) 192# define spin_lock_nested(lock, subclass) _spin_lock(lock)
193# define spin_lock_nest_lock(lock, nest_lock) _spin_lock(lock)
187#endif 194#endif
188 195
189#define write_lock(lock) _write_lock(lock) 196#define write_lock(lock) _write_lock(lock)
@@ -191,23 +198,53 @@ do { \
191 198
192#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) 199#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
193 200
194#define spin_lock_irqsave(lock, flags) flags = _spin_lock_irqsave(lock) 201#define spin_lock_irqsave(lock, flags) \
195#define read_lock_irqsave(lock, flags) flags = _read_lock_irqsave(lock) 202 do { \
196#define write_lock_irqsave(lock, flags) flags = _write_lock_irqsave(lock) 203 typecheck(unsigned long, flags); \
204 flags = _spin_lock_irqsave(lock); \
205 } while (0)
206#define read_lock_irqsave(lock, flags) \
207 do { \
208 typecheck(unsigned long, flags); \
209 flags = _read_lock_irqsave(lock); \
210 } while (0)
211#define write_lock_irqsave(lock, flags) \
212 do { \
213 typecheck(unsigned long, flags); \
214 flags = _write_lock_irqsave(lock); \
215 } while (0)
197 216
198#ifdef CONFIG_DEBUG_LOCK_ALLOC 217#ifdef CONFIG_DEBUG_LOCK_ALLOC
199#define spin_lock_irqsave_nested(lock, flags, subclass) \ 218#define spin_lock_irqsave_nested(lock, flags, subclass) \
200 flags = _spin_lock_irqsave_nested(lock, subclass) 219 do { \
220 typecheck(unsigned long, flags); \
221 flags = _spin_lock_irqsave_nested(lock, subclass); \
222 } while (0)
201#else 223#else
202#define spin_lock_irqsave_nested(lock, flags, subclass) \ 224#define spin_lock_irqsave_nested(lock, flags, subclass) \
203 flags = _spin_lock_irqsave(lock) 225 do { \
226 typecheck(unsigned long, flags); \
227 flags = _spin_lock_irqsave(lock); \
228 } while (0)
204#endif 229#endif
205 230
206#else 231#else
207 232
208#define spin_lock_irqsave(lock, flags) _spin_lock_irqsave(lock, flags) 233#define spin_lock_irqsave(lock, flags) \
209#define read_lock_irqsave(lock, flags) _read_lock_irqsave(lock, flags) 234 do { \
210#define write_lock_irqsave(lock, flags) _write_lock_irqsave(lock, flags) 235 typecheck(unsigned long, flags); \
236 _spin_lock_irqsave(lock, flags); \
237 } while (0)
238#define read_lock_irqsave(lock, flags) \
239 do { \
240 typecheck(unsigned long, flags); \
241 _read_lock_irqsave(lock, flags); \
242 } while (0)
243#define write_lock_irqsave(lock, flags) \
244 do { \
245 typecheck(unsigned long, flags); \
246 _write_lock_irqsave(lock, flags); \
247 } while (0)
211#define spin_lock_irqsave_nested(lock, flags, subclass) \ 248#define spin_lock_irqsave_nested(lock, flags, subclass) \
212 spin_lock_irqsave(lock, flags) 249 spin_lock_irqsave(lock, flags)
213 250
@@ -260,16 +297,25 @@ do { \
260} while (0) 297} while (0)
261#endif 298#endif
262 299
263#define spin_unlock_irqrestore(lock, flags) \ 300#define spin_unlock_irqrestore(lock, flags) \
264 _spin_unlock_irqrestore(lock, flags) 301 do { \
302 typecheck(unsigned long, flags); \
303 _spin_unlock_irqrestore(lock, flags); \
304 } while (0)
265#define spin_unlock_bh(lock) _spin_unlock_bh(lock) 305#define spin_unlock_bh(lock) _spin_unlock_bh(lock)
266 306
267#define read_unlock_irqrestore(lock, flags) \ 307#define read_unlock_irqrestore(lock, flags) \
268 _read_unlock_irqrestore(lock, flags) 308 do { \
309 typecheck(unsigned long, flags); \
310 _read_unlock_irqrestore(lock, flags); \
311 } while (0)
269#define read_unlock_bh(lock) _read_unlock_bh(lock) 312#define read_unlock_bh(lock) _read_unlock_bh(lock)
270 313
271#define write_unlock_irqrestore(lock, flags) \ 314#define write_unlock_irqrestore(lock, flags) \
272 _write_unlock_irqrestore(lock, flags) 315 do { \
316 typecheck(unsigned long, flags); \
317 _write_unlock_irqrestore(lock, flags); \
318 } while (0)
273#define write_unlock_bh(lock) _write_unlock_bh(lock) 319#define write_unlock_bh(lock) _write_unlock_bh(lock)
274 320
275#define spin_trylock_bh(lock) __cond_lock(lock, _spin_trylock_bh(lock)) 321#define spin_trylock_bh(lock) __cond_lock(lock, _spin_trylock_bh(lock))