From: Joe Perches Date: Mon, 13 Oct 2014 22:52:01 +0000 (-0700) Subject: checkpatch: warn on logging functions with KERN_ X-Git-Tag: v5.15~17045^2~105 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f78d98f6ce66fc7cc0be714d56b0240923a8b4f4;p=platform%2Fkernel%2Flinux-starfive.git checkpatch: warn on logging functions with KERN_ Warn on probable misuses of logging functions with KERN_ like pr_err(KERN_ERR "foo\n"); Signed-off-by: Joe Perches Suggested-by: Andrew Morton Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 52a223e..374abf4 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -4447,6 +4447,17 @@ sub process { } } +# check for logging functions with KERN_ + if ($line !~ /printk\s*\(/ && + $line =~ /\b$logFunctions\s*\(.*\b(KERN_[A-Z]+)\b/) { + my $level = $1; + if (WARN("UNNECESSARY_KERN_LEVEL", + "Possible unnecessary $level\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/\s*$level\s*//; + } + } + # check for bad placement of section $InitAttribute (e.g.: __initdata) if ($line =~ /(\b$InitAttribute\b)/) { my $attr = $1;