From: Andi Kleen Date: Thu, 3 May 2012 05:44:11 +0000 (+1000) Subject: checkpatch: check for spin_is_locked() X-Git-Tag: next-20120503~2^2~136 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=b88cda3ecb0897035dcbcb3833c4a41f74522a28;p=karo-tx-linux.git checkpatch: check for spin_is_locked() spin_is_locked() is usually misued. In checkpatch.pl: - warn when it is used at all - error out when it is asserted on free, because that's usually broken (e.g. doesn't work on on uni processor builds). Recommend lockdep_assert_held() instead. [joe@perches.com: some improvements] Signed-off-by: Andi Kleen Cc: Andy Whitcroft Cc: Joe Perches Signed-off-by: Andrew Morton --- diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index faea0ec612bf..b8ed516b34ec 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3452,6 +3452,20 @@ sub process { } } +# spin_is_locked is usually misused. warn about it. + if ($line =~ /\bspin_is_locked\s*\(/) { + # BUG_ON/WARN_ON(!spin_is_locked() is generally a bug + if ($line =~ /(BUG_ON|WARN_ON|ASSERT)\s*\(!spin_is_locked/) { + ERROR("SPIN_IS_LOCKED", + "Use lockdep_assert_held() instead of asserts on !spin_is_locked\n" + . $herecurr); + } else { + WARN("SPIN_IS_LOCKED", + "spin_is_locked is usually misused. See Documentation/spinlocks.txt\n" + . $herecurr) + } + } + # check for lockdep_set_novalidate_class if ($line =~ /^.\s*lockdep_set_novalidate_class\s*\(/ || $line =~ /__lockdep_no_validate__\s*\)/ ) {