Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add additional examples in Documentation/spinlocks.txt

Checkpatch will throw an error if code doesn't use the correct initializers
for static spinlocks:

ERROR: Use of SPIN_LOCK_UNLOCKED is deprecated: see Documentation/spinlocks.txt

This is fine, but Documentation/spinlocks.txt isn't very clear on how to
_use_ the new initializers for static variables. To save people time in the
future, I added two small examples of how to fix old-style static
initializers to be more lockdep friendly.

Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Mark Fasheh and committed by
Jonathan Corbet
14dadf1d d396c5f1

+22
+22
Documentation/spinlocks.txt
··· 5 5 __SPIN_LOCK_UNLOCKED()/__RW_LOCK_UNLOCKED() as appropriate for static 6 6 initialization. 7 7 8 + Most of the time, you can simply turn: 9 + 10 + static spinlock_t xxx_lock = SPIN_LOCK_UNLOCKED; 11 + 12 + into: 13 + 14 + static DEFINE_SPINLOCK(xxx_lock); 15 + 16 + Static structure member variables go from: 17 + 18 + struct foo bar { 19 + .lock = SPIN_LOCK_UNLOCKED; 20 + }; 21 + 22 + to: 23 + 24 + struct foo bar { 25 + .lock = __SPIN_LOCK_UNLOCKED(bar.lock); 26 + }; 27 + 28 + Declaration of static rw_locks undergo a similar transformation. 29 + 8 30 Dynamic initialization, when necessary, may be performed as 9 31 demonstrated below. 10 32