]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - scripts/checkpatch.pl
[media] drivers/media/IR/imon.c: Use pr_err instead of err
[net-next-2.6.git] / scripts / checkpatch.pl
index d7a44fd3b2243405cfb5c9a871d305221e6dd2cf..2039acdf51222b3961b06291d6a02f4a8105a240 100755 (executable)
@@ -195,7 +195,7 @@ our $typeTypedefs = qr{(?x:
 our $logFunctions = qr{(?x:
        printk|
        pr_(debug|dbg|vdbg|devel|info|warning|err|notice|alert|crit|emerg|cont)|
-       dev_(printk|dbg|vdbg|info|warn|err|notice|alert|crit|emerg|WARN)|
+       (dev|netdev|netif)_(printk|dbg|vdbg|info|warn|err|notice|alert|crit|emerg|WARN)|
        WARN|
        panic
 )};
@@ -558,6 +558,9 @@ sub ctx_statement_block {
                        $type = ($level != 0)? '{' : '';
 
                        if ($level == 0) {
+                               if (substr($blk, $off + 1, 1) eq ';') {
+                                       $off++;
+                               }
                                last;
                        }
                }
@@ -1409,7 +1412,8 @@ sub process {
 #80 column limit
                if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
                    $rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
-                   $line !~ /^\+\s*$logFunctions\s*\(\s*(?:KERN_\S+\s*)?"[X\t]*"\s*(?:,|\)\s*;)\s*$/ &&
+                   !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:,|\)\s*;)\s*$/ ||
+                   $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
                    $length > 80)
                {
                        WARN("line over 80 characters\n" . $herecurr);
@@ -1791,9 +1795,9 @@ sub process {
                        WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr);
                }
 
-# check for external initialisers.
+# check for global initialisers.
                if ($line =~ /^.$Type\s*$Ident\s*(?:\s+$Modifier)*\s*=\s*(0|NULL|false)\s*;/) {
-                       ERROR("do not initialise externals to 0 or NULL\n" .
+                       ERROR("do not initialise globals to 0 or NULL\n" .
                                $herecurr);
                }
 # check for static initialisers.
@@ -2583,6 +2587,21 @@ sub process {
                        }
                }
 
+# prefer usleep_range over udelay
+               if ($line =~ /\budelay\s*\(\s*(\w+)\s*\)/) {
+                       # ignore udelay's < 10, however
+                       if (! (($1 =~ /(\d+)/) && ($1 < 10)) ) {
+                               CHK("usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt\n" . $line);
+                       }
+               }
+
+# warn about unexpectedly long msleep's
+               if ($line =~ /\bmsleep\s*\((\d+)\);/) {
+                       if ($1 < 20) {
+                               WARN("msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt\n" . $line);
+                       }
+               }
+
 # warn about #ifdefs in C files
 #              if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) {
 #                      print "#ifdef in C files should be avoided\n";