]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
checkpatch: prefer dev_<level>( to dev_printk(KERN_<LEVEL>
authorJoe Perches <joe@perches.com>
Wed, 20 Feb 2013 02:15:34 +0000 (13:15 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 20 Feb 2013 05:53:19 +0000 (16:53 +1100)
Add YA check to printk style.

dev_<level> uses are functions and generate smaller
object code than dev_printk(KERN_<LEVEL>.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
scripts/checkpatch.pl

index 2bb08a962ce3168a7fe1c01d3f397349e0143bc5..f9afd075e1096a082dde48cef594d6416d4947c8 100755 (executable)
@@ -2430,6 +2430,15 @@ sub process {
                             "Prefer pr_warn(... to pr_warning(...\n" . $herecurr);
                }
 
+               if ($line =~ /\bdev_printk\s*\(\s*KERN_([A-Z]+)/) {
+                       my $orig = $1;
+                       my $level = lc($orig);
+                       $level = "warn" if ($level eq "warning");
+                       $level = "dbg" if ($level eq "debug");
+                       WARN("PREFER_DEV_LEVEL",
+                            "Prefer dev_$level(... to dev_printk(KERN_$orig, ...\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