···86868787The routines look the same as above:88888989- rwlock_t xxx_lock = RW_LOCK_UNLOCKED;8989+ rwlock_t xxx_lock = __RW_LOCK_UNLOCKED(xxx_lock);90909191 unsigned long flags;9292···196196197197For static initialization, use DEFINE_SPINLOCK() / DEFINE_RWLOCK() or198198__SPIN_LOCK_UNLOCKED() / __RW_LOCK_UNLOCKED() as appropriate.199199-200200-SPIN_LOCK_UNLOCKED and RW_LOCK_UNLOCKED are deprecated. These interfere201201-with lockdep state tracking.202202-203203-Most of the time, you can simply turn:204204- static spinlock_t xxx_lock = SPIN_LOCK_UNLOCKED;205205-into:206206- static DEFINE_SPINLOCK(xxx_lock);207207-208208-Static structure member variables go from:209209-210210- struct foo bar {211211- .lock = SPIN_LOCK_UNLOCKED;212212- };213213-214214-to:215215-216216- struct foo bar {217217- .lock = __SPIN_LOCK_UNLOCKED(bar.lock);218218- };219219-220220-Declaration of static rw_locks undergo a similar transformation.
-8
include/linux/rwlock_types.h
···4343 RW_DEP_MAP_INIT(lockname) }4444#endif45454646-/*4747- * RW_LOCK_UNLOCKED defeat lockdep state tracking and is hence4848- * deprecated.4949- *5050- * Please use DEFINE_RWLOCK() or __RW_LOCK_UNLOCKED() as appropriate.5151- */5252-#define RW_LOCK_UNLOCKED __RW_LOCK_UNLOCKED(old_style_rw_init)5353-5446#define DEFINE_RWLOCK(x) rwlock_t x = __RW_LOCK_UNLOCKED(x)55475648#endif /* __LINUX_RWLOCK_TYPES_H */
-8
include/linux/spinlock_types.h
···8181#define __SPIN_LOCK_UNLOCKED(lockname) \8282 (spinlock_t ) __SPIN_LOCK_INITIALIZER(lockname)83838484-/*8585- * SPIN_LOCK_UNLOCKED defeats lockdep state tracking and is hence8686- * deprecated.8787- * Please use DEFINE_SPINLOCK() or __SPIN_LOCK_UNLOCKED() as8888- * appropriate.8989- */9090-#define SPIN_LOCK_UNLOCKED __SPIN_LOCK_UNLOCKED(old_style_spin_init)9191-9284#define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x)93859486#include <linux/rwlock_types.h>
-5
scripts/checkpatch.pl
···26542654 WARN("Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr);26552655 }2656265626572657-# SPIN_LOCK_UNLOCKED & RW_LOCK_UNLOCKED are deprecated26582658- if ($line =~ /\b(SPIN_LOCK_UNLOCKED|RW_LOCK_UNLOCKED)/) {26592659- ERROR("Use of $1 is deprecated: see Documentation/spinlocks.txt\n" . $herecurr);26602660- }26612661-26622657# warn about #if 026632658 if ($line =~ /^.\s*\#\s*if\s+0\b/) {26642659 CHK("if this code is redundant consider removing it\n" .