Skip to content

Commit

Permalink
checkpatch: suggest pr_<level> over printk(KERN_<LEVEL>
Browse files Browse the repository at this point in the history
Suggest the shorter pr_<level> instead of printk(KERN_<LEVEL>.

Prefer to use pr_<level> over bare printks.
Prefer to use pr_warn over pr_warning.

Signed-off-by: Joe Perches <[email protected]>
Cc: Andy Whitcroft <[email protected]>
Cc: Theodore Ts'o <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
JoePerches authored and torvalds committed Jun 1, 2012
1 parent 9a4cad4 commit 243f380
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2382,6 +2382,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
Expand Down

0 comments on commit 243f380

Please sign in to comment.