aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.lib3
-rw-r--r--scripts/Makefile.modinst3
-rwxr-xr-xscripts/checkpatch.pl149
-rw-r--r--scripts/dtc/Makefile2
-rw-r--r--scripts/headers_install.pl3
-rw-r--r--scripts/kconfig/expr.h5
-rw-r--r--scripts/kconfig/list.h91
-rw-r--r--scripts/kconfig/lkc_proto.h4
-rw-r--r--scripts/kconfig/mconf.c6
-rw-r--r--scripts/kconfig/menu.c14
-rwxr-xr-xscripts/kernel-doc34
-rw-r--r--scripts/mod/modpost.c24
-rwxr-xr-xscripts/sign-file6
-rw-r--r--scripts/sortextable.c1
14 files changed, 251 insertions, 94 deletions
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 0be6f110cce7..bdf42fdf64c9 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -266,6 +266,9 @@ $(obj)/%.dtb.S: $(obj)/%.dtb
266quiet_cmd_dtc = DTC $@ 266quiet_cmd_dtc = DTC $@
267cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -d $(depfile) $< 267cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -d $(depfile) $<
268 268
269$(obj)/%.dtb: $(src)/%.dts FORCE
270 $(call if_changed_dep,dtc)
271
269# Bzip2 272# Bzip2
270# --------------------------------------------------------------------------- 273# ---------------------------------------------------------------------------
271 274
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
index dda4b2b61927..ecbb44797e28 100644
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -16,8 +16,9 @@ PHONY += $(modules)
16__modinst: $(modules) 16__modinst: $(modules)
17 @: 17 @:
18 18
19# Don't stop modules_install if we can't sign external modules.
19quiet_cmd_modules_install = INSTALL $@ 20quiet_cmd_modules_install = INSTALL $@
20 cmd_modules_install = mkdir -p $(2); cp $@ $(2) ; $(mod_strip_cmd) $(2)/$(notdir $@) ; $(mod_sign_cmd) $(2)/$(notdir $@) 21 cmd_modules_install = mkdir -p $(2); cp $@ $(2) ; $(mod_strip_cmd) $(2)/$(notdir $@) ; $(mod_sign_cmd) $(2)/$(notdir $@) $(patsubst %,|| true,$(KBUILD_EXTMOD))
21 22
22# Modules built outside the kernel source tree go into extra by default 23# Modules built outside the kernel source tree go into extra by default
23INSTALL_MOD_DIR ?= extra 24INSTALL_MOD_DIR ?= extra
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 21a9f5de0a21..1d6e4c541370 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -33,6 +33,7 @@ my %ignore_type = ();
33my @ignore = (); 33my @ignore = ();
34my $help = 0; 34my $help = 0;
35my $configuration_file = ".checkpatch.conf"; 35my $configuration_file = ".checkpatch.conf";
36my $max_line_length = 80;
36 37
37sub help { 38sub help {
38 my ($exitcode) = @_; 39 my ($exitcode) = @_;
@@ -51,6 +52,7 @@ Options:
51 -f, --file treat FILE as regular source file 52 -f, --file treat FILE as regular source file
52 --subjective, --strict enable more subjective tests 53 --subjective, --strict enable more subjective tests
53 --ignore TYPE(,TYPE2...) ignore various comma separated message types 54 --ignore TYPE(,TYPE2...) ignore various comma separated message types
55 --max-line-length=n set the maximum line length, if exceeded, warn
54 --show-types show the message "types" in the output 56 --show-types show the message "types" in the output
55 --root=PATH PATH to the kernel tree root 57 --root=PATH PATH to the kernel tree root
56 --no-summary suppress the per-file summary 58 --no-summary suppress the per-file summary
@@ -107,6 +109,7 @@ GetOptions(
107 'strict!' => \$check, 109 'strict!' => \$check,
108 'ignore=s' => \@ignore, 110 'ignore=s' => \@ignore,
109 'show-types!' => \$show_types, 111 'show-types!' => \$show_types,
112 'max-line-length=i' => \$max_line_length,
110 'root=s' => \$root, 113 'root=s' => \$root,
111 'summary!' => \$summary, 114 'summary!' => \$summary,
112 'mailback!' => \$mailback, 115 'mailback!' => \$mailback,
@@ -227,7 +230,11 @@ our $Inline = qr{inline|__always_inline|noinline};
227our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]}; 230our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]};
228our $Lval = qr{$Ident(?:$Member)*}; 231our $Lval = qr{$Ident(?:$Member)*};
229 232
230our $Constant = qr{(?i:(?:[0-9]+|0x[0-9a-f]+)[ul]*)}; 233our $Float_hex = qr{(?i:0x[0-9a-f]+p-?[0-9]+[fl]?)};
234our $Float_dec = qr{(?i:((?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?))};
235our $Float_int = qr{(?i:[0-9]+e-?[0-9]+[fl]?)};
236our $Float = qr{$Float_hex|$Float_dec|$Float_int};
237our $Constant = qr{(?:$Float|(?i:(?:0x[0-9a-f]+|[0-9]+)[ul]*))};
231our $Assignment = qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)}; 238our $Assignment = qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)};
232our $Compare = qr{<=|>=|==|!=|<|>}; 239our $Compare = qr{<=|>=|==|!=|<|>};
233our $Operators = qr{ 240our $Operators = qr{
@@ -352,27 +359,6 @@ sub deparenthesize {
352 359
353$chk_signoff = 0 if ($file); 360$chk_signoff = 0 if ($file);
354 361
355my @dep_includes = ();
356my @dep_functions = ();
357my $removal = "Documentation/feature-removal-schedule.txt";
358if ($tree && -f "$root/$removal") {
359 open(my $REMOVE, '<', "$root/$removal") ||
360 die "$P: $removal: open failed - $!\n";
361 while (<$REMOVE>) {
362 if (/^Check:\s+(.*\S)/) {
363 for my $entry (split(/[, ]+/, $1)) {
364 if ($entry =~ m@include/(.*)@) {
365 push(@dep_includes, $1);
366
367 } elsif ($entry !~ m@/@) {
368 push(@dep_functions, $entry);
369 }
370 }
371 }
372 }
373 close($REMOVE);
374}
375
376my @rawlines = (); 362my @rawlines = ();
377my @lines = (); 363my @lines = ();
378my $vname; 364my $vname;
@@ -1412,6 +1398,8 @@ sub process {
1412 my %suppress_export; 1398 my %suppress_export;
1413 my $suppress_statement = 0; 1399 my $suppress_statement = 0;
1414 1400
1401 my %camelcase = ();
1402
1415 # Pre-scan the patch sanitizing the lines. 1403 # Pre-scan the patch sanitizing the lines.
1416 # Pre-scan the patch looking for any __setup documentation. 1404 # Pre-scan the patch looking for any __setup documentation.
1417 # 1405 #
@@ -1757,6 +1745,13 @@ sub process {
1757 #print "is_start<$is_start> is_end<$is_end> length<$length>\n"; 1745 #print "is_start<$is_start> is_end<$is_end> length<$length>\n";
1758 } 1746 }
1759 1747
1748# discourage the addition of CONFIG_EXPERIMENTAL in Kconfig.
1749 if ($realfile =~ /Kconfig/ &&
1750 $line =~ /.\s*depends on\s+.*\bEXPERIMENTAL\b/) {
1751 WARN("CONFIG_EXPERIMENTAL",
1752 "Use of CONFIG_EXPERIMENTAL is deprecated. For alternatives, see https://lkml.org/lkml/2012/10/23/580\n");
1753 }
1754
1760 if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) && 1755 if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) &&
1761 ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) { 1756 ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) {
1762 my $flag = $1; 1757 my $flag = $1;
@@ -1774,15 +1769,15 @@ sub process {
1774# check we are in a valid source file if not then ignore this hunk 1769# check we are in a valid source file if not then ignore this hunk
1775 next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/); 1770 next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);
1776 1771
1777#80 column limit 1772#line length limit
1778 if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && 1773 if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
1779 $rawline !~ /^.\s*\*\s*\@$Ident\s/ && 1774 $rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
1780 !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ || 1775 !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ ||
1781 $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) && 1776 $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
1782 $length > 80) 1777 $length > $max_line_length)
1783 { 1778 {
1784 WARN("LONG_LINE", 1779 WARN("LONG_LINE",
1785 "line over 80 characters\n" . $herecurr); 1780 "line over $max_line_length characters\n" . $herecurr);
1786 } 1781 }
1787 1782
1788# Check for user-visible strings broken across lines, which breaks the ability 1783# Check for user-visible strings broken across lines, which breaks the ability
@@ -1890,8 +1885,10 @@ sub process {
1890 } 1885 }
1891 1886
1892 if ($realfile =~ m@^(drivers/net/|net/)@ && 1887 if ($realfile =~ m@^(drivers/net/|net/)@ &&
1893 $rawline !~ m@^\+[ \t]*(\/\*|\*\/)@ && 1888 $rawline !~ m@^\+[ \t]*\*/[ \t]*$@ && #trailing */
1894 $rawline =~ m@^\+[ \t]*.+\*\/[ \t]*$@) { 1889 $rawline !~ m@^\+.*/\*.*\*/[ \t]*$@ && #inline /*...*/
1890 $rawline !~ m@^\+.*\*{2,}/[ \t]*$@ && #trailing **/
1891 $rawline =~ m@^\+[ \t]*.+\*\/[ \t]*$@) { #non blank */
1895 WARN("NETWORKING_BLOCK_COMMENT_STYLE", 1892 WARN("NETWORKING_BLOCK_COMMENT_STYLE",
1896 "networking block comments put the trailing */ on a separate line\n" . $herecurr); 1893 "networking block comments put the trailing */ on a separate line\n" . $herecurr);
1897 } 1894 }
@@ -1910,6 +1907,12 @@ sub process {
1910# check we are in a valid C source file if not then ignore this hunk 1907# check we are in a valid C source file if not then ignore this hunk
1911 next if ($realfile !~ /\.(h|c)$/); 1908 next if ($realfile !~ /\.(h|c)$/);
1912 1909
1910# discourage the addition of CONFIG_EXPERIMENTAL in #if(def).
1911 if ($line =~ /^\+\s*\#\s*if.*\bCONFIG_EXPERIMENTAL\b/) {
1912 WARN("CONFIG_EXPERIMENTAL",
1913 "Use of CONFIG_EXPERIMENTAL is deprecated. For alternatives, see https://lkml.org/lkml/2012/10/23/580\n");
1914 }
1915
1913# check for RCS/CVS revision markers 1916# check for RCS/CVS revision markers
1914 if ($rawline =~ /^\+.*\$(Revision|Log|Id)(?:\$|)/) { 1917 if ($rawline =~ /^\+.*\$(Revision|Log|Id)(?:\$|)/) {
1915 WARN("CVS_KEYWORD", 1918 WARN("CVS_KEYWORD",
@@ -2904,12 +2907,17 @@ sub process {
2904 } 2907 }
2905 } 2908 }
2906 2909
2907#studly caps, commented out until figure out how to distinguish between use of existing and adding new 2910#CamelCase
2908# if (($line=~/[\w_][a-z\d]+[A-Z]/) and !($line=~/print/)) { 2911 while ($line =~ m{($Constant|$Lval)}g) {
2909# print "No studly caps, use _\n"; 2912 my $var = $1;
2910# print "$herecurr"; 2913 if ($var !~ /$Constant/ &&
2911# $clean = 0; 2914 $var =~ /[A-Z]\w*[a-z]|[a-z]\w*[A-Z]/ &&
2912# } 2915 !defined $camelcase{$var}) {
2916 $camelcase{$var} = 1;
2917 WARN("CAMELCASE",
2918 "Avoid CamelCase: <$var>\n" . $herecurr);
2919 }
2920 }
2913 2921
2914#no spaces allowed after \ in define 2922#no spaces allowed after \ in define
2915 if ($line=~/\#\s*define.*\\\s$/) { 2923 if ($line=~/\#\s*define.*\\\s$/) {
@@ -3011,6 +3019,17 @@ sub process {
3011 "Macros with complex values should be enclosed in parenthesis\n" . "$herectx"); 3019 "Macros with complex values should be enclosed in parenthesis\n" . "$herectx");
3012 } 3020 }
3013 } 3021 }
3022
3023# check for line continuations outside of #defines, preprocessor #, and asm
3024
3025 } else {
3026 if ($prevline !~ /^..*\\$/ &&
3027 $line !~ /^\+\s*\#.*\\$/ && # preprocessor
3028 $line !~ /^\+.*\b(__asm__|asm)\b.*\\$/ && # asm
3029 $line =~ /^\+.*\\$/) {
3030 WARN("LINE_CONTINUATIONS",
3031 "Avoid unnecessary line continuations\n" . $herecurr);
3032 }
3014 } 3033 }
3015 3034
3016# do {} while (0) macro tests: 3035# do {} while (0) macro tests:
@@ -3181,20 +3200,14 @@ sub process {
3181 } 3200 }
3182 } 3201 }
3183 3202
3184# don't include deprecated include files (uses RAW line) 3203# check for unnecessary blank lines around braces
3185 for my $inc (@dep_includes) { 3204 if (($line =~ /^..*}\s*$/ && $prevline =~ /^.\s*$/)) {
3186 if ($rawline =~ m@^.\s*\#\s*include\s*\<$inc>@) { 3205 CHK("BRACES",
3187 ERROR("DEPRECATED_INCLUDE", 3206 "Blank lines aren't necessary before a close brace '}'\n" . $hereprev);
3188 "Don't use <$inc>: see Documentation/feature-removal-schedule.txt\n" . $herecurr);
3189 }
3190 } 3207 }
3191 3208 if (($line =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) {
3192# don't use deprecated functions 3209 CHK("BRACES",
3193 for my $func (@dep_functions) { 3210 "Blank lines aren't necessary after an open brace '{'\n" . $hereprev);
3194 if ($line =~ /\b$func\b/) {
3195 ERROR("DEPRECATED_FUNCTION",
3196 "Don't use $func(): see Documentation/feature-removal-schedule.txt\n" . $herecurr);
3197 }
3198 } 3211 }
3199 3212
3200# no volatiles please 3213# no volatiles please
@@ -3211,20 +3224,12 @@ sub process {
3211 $herecurr); 3224 $herecurr);
3212 } 3225 }
3213 3226
3214# check for needless kfree() checks 3227# check for needless "if (<foo>) fn(<foo>)" uses
3215 if ($prevline =~ /\bif\s*\(([^\)]*)\)/) { 3228 if ($prevline =~ /\bif\s*\(\s*($Lval)\s*\)/) {
3216 my $expr = $1; 3229 my $expr = '\s*\(\s*' . quotemeta($1) . '\s*\)\s*;';
3217 if ($line =~ /\bkfree\(\Q$expr\E\);/) { 3230 if ($line =~ /\b(kfree|usb_free_urb|debugfs_remove(?:_recursive)?)$expr/) {
3218 WARN("NEEDLESS_KFREE", 3231 WARN('NEEDLESS_IF',
3219 "kfree(NULL) is safe this check is probably not required\n" . $hereprev); 3232 "$1(NULL) is safe this check is probably not required\n" . $hereprev);
3220 }
3221 }
3222# check for needless usb_free_urb() checks
3223 if ($prevline =~ /\bif\s*\(([^\)]*)\)/) {
3224 my $expr = $1;
3225 if ($line =~ /\busb_free_urb\(\Q$expr\E\);/) {
3226 WARN("NEEDLESS_USB_FREE_URB",
3227 "usb_free_urb(NULL) is safe this check is probably not required\n" . $hereprev);
3228 } 3233 }
3229 } 3234 }
3230 3235
@@ -3342,6 +3347,12 @@ sub process {
3342 "Avoid line continuations in quoted strings\n" . $herecurr); 3347 "Avoid line continuations in quoted strings\n" . $herecurr);
3343 } 3348 }
3344 3349
3350# check for struct spinlock declarations
3351 if ($line =~ /^.\s*\bstruct\s+spinlock\s+\w+\s*;/) {
3352 WARN("USE_SPINLOCK_T",
3353 "struct spinlock should be spinlock_t\n" . $herecurr);
3354 }
3355
3345# Check for misused memsets 3356# Check for misused memsets
3346 if ($^V && $^V ge 5.10.0 && 3357 if ($^V && $^V ge 5.10.0 &&
3347 defined $stat && 3358 defined $stat &&
@@ -3448,8 +3459,22 @@ sub process {
3448 3459
3449# check for multiple semicolons 3460# check for multiple semicolons
3450 if ($line =~ /;\s*;\s*$/) { 3461 if ($line =~ /;\s*;\s*$/) {
3451 WARN("ONE_SEMICOLON", 3462 WARN("ONE_SEMICOLON",
3452 "Statements terminations use 1 semicolon\n" . $herecurr); 3463 "Statements terminations use 1 semicolon\n" . $herecurr);
3464 }
3465
3466# check for switch/default statements without a break;
3467 if ($^V && $^V ge 5.10.0 &&
3468 defined $stat &&
3469 $stat =~ /^\+[$;\s]*(?:case[$;\s]+\w+[$;\s]*:[$;\s]*|)*[$;\s]*\bdefault[$;\s]*:[$;\s]*;/g) {
3470 my $ctx = '';
3471 my $herectx = $here . "\n";
3472 my $cnt = statement_rawlines($stat);
3473 for (my $n = 0; $n < $cnt; $n++) {
3474 $herectx .= raw_line($linenr, $n) . "\n";
3475 }
3476 WARN("DEFAULT_NO_BREAK",
3477 "switch default: should use break\n" . $herectx);
3453 } 3478 }
3454 3479
3455# check for gcc specific __FUNCTION__ 3480# check for gcc specific __FUNCTION__
diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile
index 6d1c6bb9f224..2a48022c41e7 100644
--- a/scripts/dtc/Makefile
+++ b/scripts/dtc/Makefile
@@ -27,3 +27,5 @@ HOSTCFLAGS_dtc-parser.tab.o := $(HOSTCFLAGS_DTC)
27# dependencies on generated files need to be listed explicitly 27# dependencies on generated files need to be listed explicitly
28$(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h 28$(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h
29 29
30# generated files need to be cleaned explicitly
31clean-files := dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h
diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
index 239d22d4207b..6c353ae8a451 100644
--- a/scripts/headers_install.pl
+++ b/scripts/headers_install.pl
@@ -42,6 +42,9 @@ foreach my $filename (@files) {
42 $line =~ s/(^|\s)(inline)\b/$1__$2__/g; 42 $line =~ s/(^|\s)(inline)\b/$1__$2__/g;
43 $line =~ s/(^|\s)(asm)\b(\s|[(]|$)/$1__$2__$3/g; 43 $line =~ s/(^|\s)(asm)\b(\s|[(]|$)/$1__$2__$3/g;
44 $line =~ s/(^|\s|[(])(volatile)\b(\s|[(]|$)/$1__$2__$3/g; 44 $line =~ s/(^|\s|[(])(volatile)\b(\s|[(]|$)/$1__$2__$3/g;
45 $line =~ s/#ifndef _UAPI/#ifndef /;
46 $line =~ s/#define _UAPI/#define /;
47 $line =~ s!#endif /[*] _UAPI!#endif /* !;
45 printf {$out} "%s", $line; 48 printf {$out} "%s", $line;
46 } 49 }
47 close $out; 50 close $out;
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index bd2e09895553..cdd48600e02a 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -12,7 +12,7 @@ extern "C" {
12 12
13#include <assert.h> 13#include <assert.h>
14#include <stdio.h> 14#include <stdio.h>
15#include <sys/queue.h> 15#include "list.h"
16#ifndef __cplusplus 16#ifndef __cplusplus
17#include <stdbool.h> 17#include <stdbool.h>
18#endif 18#endif
@@ -175,12 +175,11 @@ struct menu {
175#define MENU_ROOT 0x0002 175#define MENU_ROOT 0x0002
176 176
177struct jump_key { 177struct jump_key {
178 CIRCLEQ_ENTRY(jump_key) entries; 178 struct list_head entries;
179 size_t offset; 179 size_t offset;
180 struct menu *target; 180 struct menu *target;
181 int index; 181 int index;
182}; 182};
183CIRCLEQ_HEAD(jk_head, jump_key);
184 183
185#define JUMP_NB 9 184#define JUMP_NB 9
186 185
diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h
new file mode 100644
index 000000000000..0ae730be5f49
--- /dev/null
+++ b/scripts/kconfig/list.h
@@ -0,0 +1,91 @@
1#ifndef LIST_H
2#define LIST_H
3
4/*
5 * Copied from include/linux/...
6 */
7
8#undef offsetof
9#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
10
11/**
12 * container_of - cast a member of a structure out to the containing structure
13 * @ptr: the pointer to the member.
14 * @type: the type of the container struct this is embedded in.
15 * @member: the name of the member within the struct.
16 *
17 */
18#define container_of(ptr, type, member) ({ \
19 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
20 (type *)( (char *)__mptr - offsetof(type,member) );})
21
22
23struct list_head {
24 struct list_head *next, *prev;
25};
26
27
28#define LIST_HEAD_INIT(name) { &(name), &(name) }
29
30#define LIST_HEAD(name) \
31 struct list_head name = LIST_HEAD_INIT(name)
32
33/**
34 * list_entry - get the struct for this entry
35 * @ptr: the &struct list_head pointer.
36 * @type: the type of the struct this is embedded in.
37 * @member: the name of the list_struct within the struct.
38 */
39#define list_entry(ptr, type, member) \
40 container_of(ptr, type, member)
41
42/**
43 * list_for_each_entry - iterate over list of given type
44 * @pos: the type * to use as a loop cursor.
45 * @head: the head for your list.
46 * @member: the name of the list_struct within the struct.
47 */
48#define list_for_each_entry(pos, head, member) \
49 for (pos = list_entry((head)->next, typeof(*pos), member); \
50 &pos->member != (head); \
51 pos = list_entry(pos->member.next, typeof(*pos), member))
52
53/**
54 * list_empty - tests whether a list is empty
55 * @head: the list to test.
56 */
57static inline int list_empty(const struct list_head *head)
58{
59 return head->next == head;
60}
61
62/*
63 * Insert a new entry between two known consecutive entries.
64 *
65 * This is only for internal list manipulation where we know
66 * the prev/next entries already!
67 */
68static inline void __list_add(struct list_head *_new,
69 struct list_head *prev,
70 struct list_head *next)
71{
72 next->prev = _new;
73 _new->next = next;
74 _new->prev = prev;
75 prev->next = _new;
76}
77
78/**
79 * list_add_tail - add a new entry
80 * @new: new entry to be added
81 * @head: list head to add it before
82 *
83 * Insert a new entry before the specified head.
84 * This is useful for implementing queues.
85 */
86static inline void list_add_tail(struct list_head *_new, struct list_head *head)
87{
88 __list_add(_new, head->prev, head);
89}
90
91#endif
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index 1d1c08537f1e..ef1a7381f956 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -21,9 +21,9 @@ P(menu_get_root_menu,struct menu *,(struct menu *menu));
21P(menu_get_parent_menu,struct menu *,(struct menu *menu)); 21P(menu_get_parent_menu,struct menu *,(struct menu *menu));
22P(menu_has_help,bool,(struct menu *menu)); 22P(menu_has_help,bool,(struct menu *menu));
23P(menu_get_help,const char *,(struct menu *menu)); 23P(menu_get_help,const char *,(struct menu *menu));
24P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct jk_head 24P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct list_head
25 *head)); 25 *head));
26P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct jk_head 26P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct list_head
27 *head)); 27 *head));
28P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help)); 28P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help));
29 29
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 48f67448af7b..53975cf87608 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -312,7 +312,7 @@ static void set_config_filename(const char *config_filename)
312 312
313 313
314struct search_data { 314struct search_data {
315 struct jk_head *head; 315 struct list_head *head;
316 struct menu **targets; 316 struct menu **targets;
317 int *keys; 317 int *keys;
318}; 318};
@@ -323,7 +323,7 @@ static void update_text(char *buf, size_t start, size_t end, void *_data)
323 struct jump_key *pos; 323 struct jump_key *pos;
324 int k = 0; 324 int k = 0;
325 325
326 CIRCLEQ_FOREACH(pos, data->head, entries) { 326 list_for_each_entry(pos, data->head, entries) {
327 if (pos->offset >= start && pos->offset < end) { 327 if (pos->offset >= start && pos->offset < end) {
328 char header[4]; 328 char header[4];
329 329
@@ -375,7 +375,7 @@ again:
375 375
376 sym_arr = sym_re_search(dialog_input); 376 sym_arr = sym_re_search(dialog_input);
377 do { 377 do {
378 struct jk_head head = CIRCLEQ_HEAD_INITIALIZER(head); 378 LIST_HEAD(head);
379 struct menu *targets[JUMP_NB]; 379 struct menu *targets[JUMP_NB];
380 int keys[JUMP_NB + 1], i; 380 int keys[JUMP_NB + 1], i;
381 struct search_data data = { 381 struct search_data data = {
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index a3cade659f89..e98a05c8e508 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -508,7 +508,7 @@ const char *menu_get_help(struct menu *menu)
508} 508}
509 509
510static void get_prompt_str(struct gstr *r, struct property *prop, 510static void get_prompt_str(struct gstr *r, struct property *prop,
511 struct jk_head *head) 511 struct list_head *head)
512{ 512{
513 int i, j; 513 int i, j;
514 struct menu *submenu[8], *menu, *location = NULL; 514 struct menu *submenu[8], *menu, *location = NULL;
@@ -544,12 +544,13 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
544 } else 544 } else
545 jump->target = location; 545 jump->target = location;
546 546
547 if (CIRCLEQ_EMPTY(head)) 547 if (list_empty(head))
548 jump->index = 0; 548 jump->index = 0;
549 else 549 else
550 jump->index = CIRCLEQ_LAST(head)->index + 1; 550 jump->index = list_entry(head->prev, struct jump_key,
551 entries)->index + 1;
551 552
552 CIRCLEQ_INSERT_TAIL(head, jump, entries); 553 list_add_tail(&jump->entries, head);
553 } 554 }
554 555
555 if (i > 0) { 556 if (i > 0) {
@@ -573,7 +574,8 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
573/* 574/*
574 * head is optional and may be NULL 575 * head is optional and may be NULL
575 */ 576 */
576void get_symbol_str(struct gstr *r, struct symbol *sym, struct jk_head *head) 577void get_symbol_str(struct gstr *r, struct symbol *sym,
578 struct list_head *head)
577{ 579{
578 bool hit; 580 bool hit;
579 struct property *prop; 581 struct property *prop;
@@ -612,7 +614,7 @@ void get_symbol_str(struct gstr *r, struct symbol *sym, struct jk_head *head)
612 str_append(r, "\n\n"); 614 str_append(r, "\n\n");
613} 615}
614 616
615struct gstr get_relations_str(struct symbol **sym_arr, struct jk_head *head) 617struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head)
616{ 618{
617 struct symbol *sym; 619 struct symbol *sym;
618 struct gstr res = str_new(); 620 struct gstr res = str_new();
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 46e7aff80d1a..28b761567815 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -137,6 +137,8 @@ use strict;
137# should document the "Context:" of the function, e.g. whether the functions 137# should document the "Context:" of the function, e.g. whether the functions
138# can be called form interrupts. Unlike other sections you can end it with an 138# can be called form interrupts. Unlike other sections you can end it with an
139# empty line. 139# empty line.
140# A non-void function should have a "Return:" section describing the return
141# value(s).
140# Example-sections should contain the string EXAMPLE so that they are marked 142# Example-sections should contain the string EXAMPLE so that they are marked
141# appropriately in DocBook. 143# appropriately in DocBook.
142# 144#
@@ -315,6 +317,7 @@ my $section_default = "Description"; # default section
315my $section_intro = "Introduction"; 317my $section_intro = "Introduction";
316my $section = $section_default; 318my $section = $section_default;
317my $section_context = "Context"; 319my $section_context = "Context";
320my $section_return = "Return";
318 321
319my $undescribed = "-- undescribed --"; 322my $undescribed = "-- undescribed --";
320 323
@@ -2039,6 +2042,28 @@ sub check_sections($$$$$$) {
2039} 2042}
2040 2043
2041## 2044##
2045# Checks the section describing the return value of a function.
2046sub check_return_section {
2047 my $file = shift;
2048 my $declaration_name = shift;
2049 my $return_type = shift;
2050
2051 # Ignore an empty return type (It's a macro)
2052 # Ignore functions with a "void" return type. (But don't ignore "void *")
2053 if (($return_type eq "") || ($return_type =~ /void\s*\w*\s*$/)) {
2054 return;
2055 }
2056
2057 if (!defined($sections{$section_return}) ||
2058 $sections{$section_return} eq "") {
2059 print STDERR "Warning(${file}:$.): " .
2060 "No description found for return value of " .
2061 "'$declaration_name'\n";
2062 ++$warnings;
2063 }
2064}
2065
2066##
2042# takes a function prototype and the name of the current file being 2067# takes a function prototype and the name of the current file being
2043# processed and spits out all the details stored in the global 2068# processed and spits out all the details stored in the global
2044# arrays/hashes. 2069# arrays/hashes.
@@ -2109,6 +2134,15 @@ sub dump_function($$) {
2109 my $prms = join " ", @parameterlist; 2134 my $prms = join " ", @parameterlist;
2110 check_sections($file, $declaration_name, "function", $sectcheck, $prms, ""); 2135 check_sections($file, $declaration_name, "function", $sectcheck, $prms, "");
2111 2136
2137 # This check emits a lot of warnings at the moment, because many
2138 # functions don't have a 'Return' doc section. So until the number
2139 # of warnings goes sufficiently down, the check is only performed in
2140 # verbose mode.
2141 # TODO: always perform the check.
2142 if ($verbose) {
2143 check_return_section($file, $declaration_name, $return_type);
2144 }
2145
2112 output_declaration($declaration_name, 2146 output_declaration($declaration_name,
2113 'function', 2147 'function',
2114 {'function' => $declaration_name, 2148 {'function' => $declaration_name,
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 0d93856a03f4..ff36c508a10e 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -858,25 +858,23 @@ static void check_section(const char *modname, struct elf_info *elf,
858 858
859#define ALL_INIT_DATA_SECTIONS \ 859#define ALL_INIT_DATA_SECTIONS \
860 ".init.setup$", ".init.rodata$", \ 860 ".init.setup$", ".init.rodata$", \
861 ".devinit.rodata$", ".cpuinit.rodata$", ".meminit.rodata$", \ 861 ".cpuinit.rodata$", ".meminit.rodata$", \
862 ".init.data$", ".devinit.data$", ".cpuinit.data$", ".meminit.data$" 862 ".init.data$", ".cpuinit.data$", ".meminit.data$"
863#define ALL_EXIT_DATA_SECTIONS \ 863#define ALL_EXIT_DATA_SECTIONS \
864 ".exit.data$", ".devexit.data$", ".cpuexit.data$", ".memexit.data$" 864 ".exit.data$", ".cpuexit.data$", ".memexit.data$"
865 865
866#define ALL_INIT_TEXT_SECTIONS \ 866#define ALL_INIT_TEXT_SECTIONS \
867 ".init.text$", ".devinit.text$", ".cpuinit.text$", ".meminit.text$" 867 ".init.text$", ".cpuinit.text$", ".meminit.text$"
868#define ALL_EXIT_TEXT_SECTIONS \ 868#define ALL_EXIT_TEXT_SECTIONS \
869 ".exit.text$", ".devexit.text$", ".cpuexit.text$", ".memexit.text$" 869 ".exit.text$", ".cpuexit.text$", ".memexit.text$"
870 870
871#define ALL_PCI_INIT_SECTIONS \ 871#define ALL_PCI_INIT_SECTIONS \
872 ".pci_fixup_early$", ".pci_fixup_header$", ".pci_fixup_final$", \ 872 ".pci_fixup_early$", ".pci_fixup_header$", ".pci_fixup_final$", \
873 ".pci_fixup_enable$", ".pci_fixup_resume$", \ 873 ".pci_fixup_enable$", ".pci_fixup_resume$", \
874 ".pci_fixup_resume_early$", ".pci_fixup_suspend$" 874 ".pci_fixup_resume_early$", ".pci_fixup_suspend$"
875 875
876#define ALL_XXXINIT_SECTIONS DEV_INIT_SECTIONS, CPU_INIT_SECTIONS, \ 876#define ALL_XXXINIT_SECTIONS CPU_INIT_SECTIONS, MEM_INIT_SECTIONS
877 MEM_INIT_SECTIONS 877#define ALL_XXXEXIT_SECTIONS CPU_EXIT_SECTIONS, MEM_EXIT_SECTIONS
878#define ALL_XXXEXIT_SECTIONS DEV_EXIT_SECTIONS, CPU_EXIT_SECTIONS, \
879 MEM_EXIT_SECTIONS
880 878
881#define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS 879#define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS
882#define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS 880#define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS
@@ -885,12 +883,10 @@ static void check_section(const char *modname, struct elf_info *elf,
885#define TEXT_SECTIONS ".text$" 883#define TEXT_SECTIONS ".text$"
886 884
887#define INIT_SECTIONS ".init.*" 885#define INIT_SECTIONS ".init.*"
888#define DEV_INIT_SECTIONS ".devinit.*"
889#define CPU_INIT_SECTIONS ".cpuinit.*" 886#define CPU_INIT_SECTIONS ".cpuinit.*"
890#define MEM_INIT_SECTIONS ".meminit.*" 887#define MEM_INIT_SECTIONS ".meminit.*"
891 888
892#define EXIT_SECTIONS ".exit.*" 889#define EXIT_SECTIONS ".exit.*"
893#define DEV_EXIT_SECTIONS ".devexit.*"
894#define CPU_EXIT_SECTIONS ".cpuexit.*" 890#define CPU_EXIT_SECTIONS ".cpuexit.*"
895#define MEM_EXIT_SECTIONS ".memexit.*" 891#define MEM_EXIT_SECTIONS ".memexit.*"
896 892
@@ -979,7 +975,7 @@ const struct sectioncheck sectioncheck[] = {
979 .mismatch = DATA_TO_ANY_EXIT, 975 .mismatch = DATA_TO_ANY_EXIT,
980 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, 976 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
981}, 977},
982/* Do not reference init code/data from devinit/cpuinit/meminit code/data */ 978/* Do not reference init code/data from cpuinit/meminit code/data */
983{ 979{
984 .fromsec = { ALL_XXXINIT_SECTIONS, NULL }, 980 .fromsec = { ALL_XXXINIT_SECTIONS, NULL },
985 .tosec = { INIT_SECTIONS, NULL }, 981 .tosec = { INIT_SECTIONS, NULL },
@@ -1000,7 +996,7 @@ const struct sectioncheck sectioncheck[] = {
1000 .mismatch = XXXINIT_TO_SOME_INIT, 996 .mismatch = XXXINIT_TO_SOME_INIT,
1001 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, 997 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
1002}, 998},
1003/* Do not reference exit code/data from devexit/cpuexit/memexit code/data */ 999/* Do not reference exit code/data from cpuexit/memexit code/data */
1004{ 1000{
1005 .fromsec = { ALL_XXXEXIT_SECTIONS, NULL }, 1001 .fromsec = { ALL_XXXEXIT_SECTIONS, NULL },
1006 .tosec = { EXIT_SECTIONS, NULL }, 1002 .tosec = { EXIT_SECTIONS, NULL },
@@ -1089,7 +1085,7 @@ static const struct sectioncheck *section_mismatch(
1089 * Pattern 2: 1085 * Pattern 2:
1090 * Many drivers utilise a *driver container with references to 1086 * Many drivers utilise a *driver container with references to
1091 * add, remove, probe functions etc. 1087 * add, remove, probe functions etc.
1092 * These functions may often be marked __devinit and we do not want to 1088 * These functions may often be marked __cpuinit and we do not want to
1093 * warn here. 1089 * warn here.
1094 * the pattern is identified by: 1090 * the pattern is identified by:
1095 * tosec = init or exit section 1091 * tosec = init or exit section
diff --git a/scripts/sign-file b/scripts/sign-file
index 87ca59d36e7e..974a20b661b7 100755
--- a/scripts/sign-file
+++ b/scripts/sign-file
@@ -156,12 +156,12 @@ sub asn1_extract($$@)
156 156
157 if ($l == 0x1) { 157 if ($l == 0x1) {
158 $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1)); 158 $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1));
159 } elsif ($l = 0x2) { 159 } elsif ($l == 0x2) {
160 $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0], 2)); 160 $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0], 2));
161 } elsif ($l = 0x3) { 161 } elsif ($l == 0x3) {
162 $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1)) << 16; 162 $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1)) << 16;
163 $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0] + 1, 2)); 163 $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0] + 1, 2));
164 } elsif ($l = 0x4) { 164 } elsif ($l == 0x4) {
165 $len = unpack("N", substr(${$cursor->[2]}, $cursor->[0], 4)); 165 $len = unpack("N", substr(${$cursor->[2]}, $cursor->[0], 4));
166 } else { 166 } else {
167 die $x509, ": ", $cursor->[0], ": ASN.1 element too long (", $l, ")\n"; 167 die $x509, ": ", $cursor->[0], ": ASN.1 element too long (", $l, ")\n";
diff --git a/scripts/sortextable.c b/scripts/sortextable.c
index f19ddc47304c..1f10e89d15b4 100644
--- a/scripts/sortextable.c
+++ b/scripts/sortextable.c
@@ -248,6 +248,7 @@ do_file(char const *const fname)
248 case EM_S390: 248 case EM_S390:
249 custom_sort = sort_relative_table; 249 custom_sort = sort_relative_table;
250 break; 250 break;
251 case EM_ARM:
251 case EM_MIPS: 252 case EM_MIPS:
252 break; 253 break;
253 } /* end switch */ 254 } /* end switch */