diff options
| author | Thomas Gleixner <tglx@linutronix.de> | 2005-01-07 22:08:28 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@evo.osdl.org> | 2005-01-07 22:08:28 -0800 |
| commit | 59d086c5b5ef8e612e8d743880e58b907cf6fca1 (patch) | |
| tree | 55cb6aa89e762e192c9d9133c445627779d6601e /include/linux | |
| parent | 55bdd209d57f7064e55ed4094f1af9c4b0da422f (diff) | |
[PATCH] Lock initializer cleanup (common headers)
First part of the patch series. Define initializer macros
Often used structures in the kernel are almost all declared and
initialized by macros in the form:
DEFINE_TYPE(name)
Spinlocks and rwlocks are declared and initialized by:
type name = INITIALIZER;
After converting the runtime initialization of spinlocks/rwlocks to
macro form it is consequent to change the declaration and initializion
of global and static locks to the macro form too. This conversion
identifies those variables as "special", common code controlled
entities similar to list_heads, mutexes... Besides consistency and code
clearness this also helps automatic lock validators and debugging code.
The patch converts
-rwlock_t snd_card_rwlock = RW_LOCK_UNLOCKED;
+DEFINE_RWLOCK(snd_card_rwlock);
and
-static spinlock_t slave_active_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(slave_active_lock);
There is no runtime overhead or actual code change resulting out of this
patch, other than a small reduction in the kernel source code size.
The conversion was done with a script, it was verified manually and it
was reviewed, compiled and tested as far as possible on x86, ARM, PPC.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/spinlock.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index d6a455ed2dcb..b8224ded2d97 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h @@ -581,4 +581,7 @@ static inline int bit_spin_is_locked(int bitnum, unsigned long *addr) #endif } +#define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED +#define DEFINE_RWLOCK(x) rwlock_t x = RW_LOCK_UNLOCKED + #endif /* __LINUX_SPINLOCK_H */ |
