Commit 691d77b6b85c20e4166bafd12bd0131b28f95a16
Committed by
Linus Torvalds
1 parent
94e2959e7a
Exists in
master
and in
4 other branches
checkpatch: add checks for in_atomic()
in_atomic() is not for driver use so report any such use as an ERROR. Also in_atomic() is often used to determine if we may sleep, but it is not reliable in this use model therefore strongly discourage its use. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 9 additions and 0 deletions Side-by-side Diff
scripts/checkpatch.pl
... | ... | @@ -2466,6 +2466,15 @@ |
2466 | 2466 | last; |
2467 | 2467 | } |
2468 | 2468 | } |
2469 | + | |
2470 | +# whine mightly about in_atomic | |
2471 | + if ($line =~ /\bin_atomic\s*\(/) { | |
2472 | + if ($realfile =~ m@^drivers/@) { | |
2473 | + ERROR("do not use in_atomic in drivers\n" . $herecurr); | |
2474 | + } else { | |
2475 | + WARN("use of in_atomic() is incorrect outside core kernel code\n" . $herecurr); | |
2476 | + } | |
2477 | + } | |
2469 | 2478 | } |
2470 | 2479 | |
2471 | 2480 | # If we have no input at all, then there is nothing to report on |