Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __SND_SEQ_LOCK_H |
| 2 | #define __SND_SEQ_LOCK_H |
| 3 | |
| 4 | #include <linux/sched.h> |
| 5 | |
| 6 | #if defined(CONFIG_SMP) || defined(CONFIG_SND_DEBUG) |
| 7 | |
| 8 | typedef atomic_t snd_use_lock_t; |
| 9 | |
| 10 | /* initialize lock */ |
| 11 | #define snd_use_lock_init(lockp) atomic_set(lockp, 0) |
| 12 | |
| 13 | /* increment lock */ |
| 14 | #define snd_use_lock_use(lockp) atomic_inc(lockp) |
| 15 | |
| 16 | /* release lock */ |
| 17 | #define snd_use_lock_free(lockp) atomic_dec(lockp) |
| 18 | |
| 19 | /* wait until all locks are released */ |
| 20 | void snd_use_lock_sync_helper(snd_use_lock_t *lock, const char *file, int line); |
| 21 | #define snd_use_lock_sync(lockp) snd_use_lock_sync_helper(lockp, __BASE_FILE__, __LINE__) |
| 22 | |
| 23 | #else /* SMP || CONFIG_SND_DEBUG */ |
| 24 | |
| 25 | typedef spinlock_t snd_use_lock_t; /* dummy */ |
| 26 | #define snd_use_lock_init(lockp) /**/ |
| 27 | #define snd_use_lock_use(lockp) /**/ |
| 28 | #define snd_use_lock_free(lockp) /**/ |
| 29 | #define snd_use_lock_sync(lockp) /**/ |
| 30 | |
| 31 | #endif /* SMP || CONFIG_SND_DEBUG */ |
| 32 | |
| 33 | #endif /* __SND_SEQ_LOCK_H */ |