diff options
Diffstat (limited to 'scripts/checkpatch.pl')
| -rwxr-xr-x | scripts/checkpatch.pl | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 2bb08a962ce3..b28cc384a5bc 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -1931,6 +1931,12 @@ sub process { | |||
| 1931 | "use the SSYNC() macro in asm/blackfin.h\n" . $herevet); | 1931 | "use the SSYNC() macro in asm/blackfin.h\n" . $herevet); |
| 1932 | } | 1932 | } |
| 1933 | 1933 | ||
| 1934 | # check for old HOTPLUG __dev<foo> section markings | ||
| 1935 | if ($line =~ /\b(__dev(init|exit)(data|const|))\b/) { | ||
| 1936 | WARN("HOTPLUG_SECTION", | ||
| 1937 | "Using $1 is unnecessary\n" . $herecurr); | ||
| 1938 | } | ||
| 1939 | |||
| 1934 | # Check for potential 'bare' types | 1940 | # Check for potential 'bare' types |
| 1935 | my ($stat, $cond, $line_nr_next, $remain_next, $off_next, | 1941 | my ($stat, $cond, $line_nr_next, $remain_next, $off_next, |
| 1936 | $realline_next); | 1942 | $realline_next); |
| @@ -2430,6 +2436,15 @@ sub process { | |||
| 2430 | "Prefer pr_warn(... to pr_warning(...\n" . $herecurr); | 2436 | "Prefer pr_warn(... to pr_warning(...\n" . $herecurr); |
| 2431 | } | 2437 | } |
| 2432 | 2438 | ||
| 2439 | if ($line =~ /\bdev_printk\s*\(\s*KERN_([A-Z]+)/) { | ||
| 2440 | my $orig = $1; | ||
| 2441 | my $level = lc($orig); | ||
| 2442 | $level = "warn" if ($level eq "warning"); | ||
| 2443 | $level = "dbg" if ($level eq "debug"); | ||
| 2444 | WARN("PREFER_DEV_LEVEL", | ||
| 2445 | "Prefer dev_$level(... to dev_printk(KERN_$orig, ...\n" . $herecurr); | ||
| 2446 | } | ||
| 2447 | |||
| 2433 | # function brace can't be on same line, except for #defines of do while, | 2448 | # function brace can't be on same line, except for #defines of do while, |
| 2434 | # or if closed on same line | 2449 | # or if closed on same line |
| 2435 | if (($line=~/$Type\s*$Ident\(.*\).*\s{/) and | 2450 | if (($line=~/$Type\s*$Ident\(.*\).*\s{/) and |
| @@ -2915,6 +2930,7 @@ sub process { | |||
| 2915 | my $var = $1; | 2930 | my $var = $1; |
| 2916 | if ($var !~ /$Constant/ && | 2931 | if ($var !~ /$Constant/ && |
| 2917 | $var =~ /[A-Z]\w*[a-z]|[a-z]\w*[A-Z]/ && | 2932 | $var =~ /[A-Z]\w*[a-z]|[a-z]\w*[A-Z]/ && |
| 2933 | $var !~ /"^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ && | ||
| 2918 | !defined $camelcase{$var}) { | 2934 | !defined $camelcase{$var}) { |
| 2919 | $camelcase{$var} = 1; | 2935 | $camelcase{$var} = 1; |
| 2920 | WARN("CAMELCASE", | 2936 | WARN("CAMELCASE", |
| @@ -3237,9 +3253,9 @@ sub process { | |||
| 3237 | } | 3253 | } |
| 3238 | 3254 | ||
| 3239 | # prefer usleep_range over udelay | 3255 | # prefer usleep_range over udelay |
| 3240 | if ($line =~ /\budelay\s*\(\s*(\w+)\s*\)/) { | 3256 | if ($line =~ /\budelay\s*\(\s*(\d+)\s*\)/) { |
| 3241 | # ignore udelay's < 10, however | 3257 | # ignore udelay's < 10, however |
| 3242 | if (! (($1 =~ /(\d+)/) && ($1 < 10)) ) { | 3258 | if (! ($1 < 10) ) { |
| 3243 | CHK("USLEEP_RANGE", | 3259 | CHK("USLEEP_RANGE", |
| 3244 | "usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt\n" . $line); | 3260 | "usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt\n" . $line); |
| 3245 | } | 3261 | } |
| @@ -3460,6 +3476,12 @@ sub process { | |||
| 3460 | "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr); | 3476 | "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr); |
| 3461 | } | 3477 | } |
| 3462 | 3478 | ||
| 3479 | # check for alloc argument mismatch | ||
| 3480 | if ($line =~ /\b(kcalloc|kmalloc_array)\s*\(\s*sizeof\b/) { | ||
| 3481 | WARN("ALLOC_ARRAY_ARGS", | ||
| 3482 | "$1 uses number as first arg, sizeof is generally wrong\n" . $herecurr); | ||
| 3483 | } | ||
| 3484 | |||
| 3463 | # check for multiple semicolons | 3485 | # check for multiple semicolons |
| 3464 | if ($line =~ /;\s*;\s*$/) { | 3486 | if ($line =~ /;\s*;\s*$/) { |
| 3465 | WARN("ONE_SEMICOLON", | 3487 | WARN("ONE_SEMICOLON", |
