]> git.karo-electronics.de Git - linux-beck.git/blobdiff - scripts/checkpatch.pl
Merge branch 'drm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied...
[linux-beck.git] / scripts / checkpatch.pl
index 315faf99effd95a1f8246504b6560680e464b5d8..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);
@@ -1454,6 +1458,13 @@ sub process {
                        WARN("please, no space before tabs\n" . $herevet);
                }
 
+# check for spaces at the beginning of a line.
+               if ($rawline =~ /^\+ / && $rawline !~ /\+ +\*/)  {
+                       my $herevet = "$here\n" . cat_vet($rawline) . "\n";
+                       WARN("please, no space for starting a line, \
+                               excluding comments\n" . $herevet);
+               }
+
 # check we are in a valid C source file if not then ignore this hunk
                next if ($realfile !~ /\.(h|c)$/);
 
@@ -1784,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.
@@ -2576,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";