checkpatch.pl: Suggest lockdep instead of asserting !spin_is_locked()
authorPaul E. McKenney <paulmck@linux.ibm.com>
Sun, 11 Nov 2018 18:49:10 +0000 (10:49 -0800)
committerPaul E. McKenney <paulmck@linux.ibm.com>
Mon, 12 Nov 2018 17:03:59 +0000 (09:03 -0800)
This commit points people who might otherwise code up something like
WARN_ON(!spin_is_locked(&mylock)) to lockdep_assert_held(&mylock).

Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Joe Perches <joe@perches.com>
scripts/checkpatch.pl

index dd29e3c28166726523de735679da0661bf428218..377f373db6c002ab87ce739be7f87f1d19bbe0cc 100755 (executable)
@@ -6389,6 +6389,12 @@ sub process {
                             "please use device_initcall() or more appropriate function instead of __initcall() (see include/linux/init.h)\n" . $herecurr);
                }
 
+# check for spin_is_locked(), suggest lockdep instead
+               if ($line =~ /\bspin_is_locked\(/) {
+                       WARN("USE_LOCKDEP",
+                            "Where possible, use lockdep_assert_held instead of assertions based on spin_is_locked\n" . $herecurr);
+               }
+
 # check for deprecated apis
                if ($line =~ /\b($deprecated_apis_search)\b\s*\(/) {
                        my $deprecated_api = $1;