mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Add additional examples in Documentation/spinlocks.txt
@ 2008-04-10 20:55 Mark Fasheh
  0 siblings, 0 replies; only message in thread
From: Mark Fasheh @ 2008-04-10 20:55 UTC (permalink / raw)
  To: Jon Corbet; +Cc: linux-kernel, Randy Dunlap, Andrew Morton

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>

diff --git a/Documentation/spinlocks.txt b/Documentation/spinlocks.txt
index 471e753..619699d 100644
--- a/Documentation/spinlocks.txt
+++ b/Documentation/spinlocks.txt
@@ -5,6 +5,28 @@ Please use DEFINE_SPINLOCK()/DEFINE_RWLOCK() or
 __SPIN_LOCK_UNLOCKED()/__RW_LOCK_UNLOCKED() as appropriate for static
 initialization.
 
+Most of the time, you can simply turn:
+
+	static spinlock_t xxx_lock = SPIN_LOCK_UNLOCKED;
+
+into:
+
+	static DEFINE_SPINLOCK(xxx_lock);
+
+Static structure member variables go from:
+
+	struct foo bar {
+		.lock	=	SPIN_LOCK_UNLOCKED;
+	};
+
+to:
+
+	struct foo bar {
+		.lock	=	__SPIN_LOCK_UNLOCKED(bar.lock);
+	};
+
+Declaration of static rw_locks undergo a similar transformation.
+
 Dynamic initialization, when necessary, may be performed as
 demonstrated below.
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-04-10 20:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-10 20:55 [PATCH] Add additional examples in Documentation/spinlocks.txt Mark Fasheh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®