From d6a1396f06e33b06d19df55a8ad1092072068aa1 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Wed, 21 Mar 2012 10:57:20 +1100 Subject: [PATCH] checkpatch: suggest pr_ over printk(KERN_ Suggest the shorter pr_ instead of printk(KERN_. Prefer to use pr_ over bare printks. Prefer to use pr_warn over pr_warning. Signed-off-by: Joe Perches Cc: Andy Whitcroft Cc: Theodore Ts'o Signed-off-by: Andrew Morton --- scripts/checkpatch.pl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index de639eeeed50..512766594ddf 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2388,6 +2388,19 @@ sub process { } } + if ($line =~ /\bprintk\s*\(\s*KERN_([A-Z]+)/) { + my $orig = $1; + my $level = lc($orig); + $level = "warn" if ($level eq "warning"); + WARN("PREFER_PR_LEVEL", + "Prefer pr_$level(... to printk(KERN_$1, ...\n" . $herecurr); + } + + if ($line =~ /\bpr_warning\s*\(/) { + WARN("PREFER_PR_LEVEL", + "Prefer pr_warn(... to pr_warning(...\n" . $herecurr); + } + # function brace can't be on same line, except for #defines of do while, # or if closed on same line if (($line=~/$Type\s*$Ident\(.*\).*\s{/) and -- 2.39.5