aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/.gitignore1
-rw-r--r--scripts/Kbuild.include18
-rw-r--r--scripts/Makefile1
-rw-r--r--scripts/Makefile.build6
-rw-r--r--scripts/Makefile.lib2
-rw-r--r--scripts/Makefile.modpost12
-rw-r--r--scripts/basic/docproc.c34
-rw-r--r--scripts/basic/fixdep.c30
-rw-r--r--scripts/basic/hash.c4
-rwxr-xr-xscripts/checkincludes.pl71
-rwxr-xr-xscripts/checkkconfigsymbols.sh4
-rwxr-xr-xscripts/checkpatch.pl188
-rw-r--r--scripts/conmakehash.c6
-rw-r--r--scripts/dtc/.gitignore5
-rwxr-xr-xscripts/extract-ikconfig14
-rw-r--r--scripts/genksyms/genksyms.c6
-rwxr-xr-xscripts/get_maintainer.pl462
-rw-r--r--scripts/headers_install.pl2
-rw-r--r--scripts/kallsyms.c2
-rw-r--r--scripts/kconfig/Makefile34
-rw-r--r--scripts/kconfig/conf.c24
-rw-r--r--scripts/kconfig/confdata.c2
-rw-r--r--scripts/kconfig/expr.c6
-rw-r--r--scripts/kconfig/gconf.c21
-rw-r--r--scripts/kconfig/gconf.glade4
-rw-r--r--scripts/kconfig/kxgettext.c4
-rw-r--r--scripts/kconfig/lkc_proto.h2
-rw-r--r--scripts/kconfig/lxdialog/util.c2
-rw-r--r--scripts/kconfig/mconf.c80
-rw-r--r--scripts/kconfig/menu.c84
-rw-r--r--scripts/kconfig/qconf.cc10
-rw-r--r--scripts/kconfig/streamline_config.pl366
-rw-r--r--scripts/kconfig/symbol.c6
-rwxr-xr-xscripts/kernel-doc25
-rw-r--r--scripts/markup_oops.pl10
-rwxr-xr-xscripts/mkcompile_h12
-rw-r--r--scripts/mod/file2alias.c13
-rw-r--r--scripts/mod/modpost.c4
-rw-r--r--scripts/mod/sumversion.c2
-rw-r--r--scripts/module-common.lds8
-rw-r--r--scripts/package/Makefile11
-rw-r--r--scripts/package/builddeb4
-rwxr-xr-xscripts/package/mkspec2
-rw-r--r--scripts/pnmtologo.c4
-rwxr-xr-xscripts/recordmcount.pl13
-rw-r--r--scripts/selinux/mdp/mdp.c4
-rwxr-xr-xscripts/tags.sh3
-rw-r--r--scripts/tracing/power.pl108
48 files changed, 1277 insertions, 459 deletions
diff --git a/scripts/.gitignore b/scripts/.gitignore
index b939fbd01195..52cab46ae35a 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -7,3 +7,4 @@ pnmtologo
7bin2c 7bin2c
8unifdef 8unifdef
9binoffset 9binoffset
10ihex2fw
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index c29be8f90248..c67e73ecd5be 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -83,11 +83,12 @@ TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
83# is automatically cleaned up. 83# is automatically cleaned up.
84try-run = $(shell set -e; \ 84try-run = $(shell set -e; \
85 TMP="$(TMPOUT).$$$$.tmp"; \ 85 TMP="$(TMPOUT).$$$$.tmp"; \
86 TMPO="$(TMPOUT).$$$$.o"; \
86 if ($(1)) >/dev/null 2>&1; \ 87 if ($(1)) >/dev/null 2>&1; \
87 then echo "$(2)"; \ 88 then echo "$(2)"; \
88 else echo "$(3)"; \ 89 else echo "$(3)"; \
89 fi; \ 90 fi; \
90 rm -f "$$TMP") 91 rm -f "$$TMP" "$$TMPO")
91 92
92# as-option 93# as-option
93# Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,) 94# Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
@@ -99,18 +100,18 @@ as-option = $(call try-run,\
99# Usage: cflags-y += $(call as-instr,instr,option1,option2) 100# Usage: cflags-y += $(call as-instr,instr,option1,option2)
100 101
101as-instr = $(call try-run,\ 102as-instr = $(call try-run,\
102 echo -e "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -xassembler -o "$$TMP" -,$(2),$(3)) 103 /bin/echo -e "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -xassembler -o "$$TMP" -,$(2),$(3))
103 104
104# cc-option 105# cc-option
105# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) 106# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
106 107
107cc-option = $(call try-run,\ 108cc-option = $(call try-run,\
108 $(CC) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",$(1),$(2)) 109 $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",$(1),$(2))
109 110
110# cc-option-yn 111# cc-option-yn
111# Usage: flag := $(call cc-option-yn,-march=winchip-c6) 112# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
112cc-option-yn = $(call try-run,\ 113cc-option-yn = $(call try-run,\
113 $(CC) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",y,n) 114 $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",y,n)
114 115
115# cc-option-align 116# cc-option-align
116# Prefix align with either -falign or -malign 117# Prefix align with either -falign or -malign
@@ -130,10 +131,15 @@ cc-fullversion = $(shell $(CONFIG_SHELL) \
130# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) 131# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
131cc-ifversion = $(shell [ $(call cc-version, $(CC)) $(1) $(2) ] && echo $(3)) 132cc-ifversion = $(shell [ $(call cc-version, $(CC)) $(1) $(2) ] && echo $(3))
132 133
134# cc-ldoption
135# Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)
136cc-ldoption = $(call try-run,\
137 $(CC) $(1) -nostdlib -xc /dev/null -o "$$TMP",$(1),$(2))
138
133# ld-option 139# ld-option
134# Usage: ldflags += $(call ld-option, -Wl$(comma)--hash-style=both) 140# Usage: LDFLAGS += $(call ld-option, -X)
135ld-option = $(call try-run,\ 141ld-option = $(call try-run,\
136 $(CC) $(1) -nostdlib -xc /dev/null -o "$$TMP",$(1),$(2)) 142 $(CC) /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2))
137 143
138###### 144######
139 145
diff --git a/scripts/Makefile b/scripts/Makefile
index 9dd5b25a1d53..842dbc2d5aed 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -10,7 +10,6 @@
10hostprogs-$(CONFIG_KALLSYMS) += kallsyms 10hostprogs-$(CONFIG_KALLSYMS) += kallsyms
11hostprogs-$(CONFIG_LOGO) += pnmtologo 11hostprogs-$(CONFIG_LOGO) += pnmtologo
12hostprogs-$(CONFIG_VT) += conmakehash 12hostprogs-$(CONFIG_VT) += conmakehash
13hostprogs-$(CONFIG_PROM_CONSOLE) += conmakehash
14hostprogs-$(CONFIG_IKCONFIG) += bin2c 13hostprogs-$(CONFIG_IKCONFIG) += bin2c
15 14
16always := $(hostprogs-y) $(hostprogs-m) 15always := $(hostprogs-y) $(hostprogs-m)
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 5c4b7a400c18..341b58902ffc 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -206,7 +206,7 @@ cmd_modversions = \
206endif 206endif
207 207
208ifdef CONFIG_FTRACE_MCOUNT_RECORD 208ifdef CONFIG_FTRACE_MCOUNT_RECORD
209cmd_record_mcount = perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ 209cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
210 "$(if $(CONFIG_64BIT),64,32)" \ 210 "$(if $(CONFIG_64BIT),64,32)" \
211 "$(OBJDUMP)" "$(OBJCOPY)" "$(CC)" "$(LD)" "$(NM)" "$(RM)" "$(MV)" \ 211 "$(OBJDUMP)" "$(OBJCOPY)" "$(CC)" "$(LD)" "$(NM)" "$(RM)" "$(MV)" \
212 "$(if $(part-of-module),1,0)" "$(@)"; 212 "$(if $(part-of-module),1,0)" "$(@)";
@@ -216,6 +216,7 @@ define rule_cc_o_c
216 $(call echo-cmd,checksrc) $(cmd_checksrc) \ 216 $(call echo-cmd,checksrc) $(cmd_checksrc) \
217 $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \ 217 $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \
218 $(cmd_modversions) \ 218 $(cmd_modversions) \
219 $(call echo-cmd,record_mcount) \
219 $(cmd_record_mcount) \ 220 $(cmd_record_mcount) \
220 scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \ 221 scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \
221 $(dot-target).tmp; \ 222 $(dot-target).tmp; \
@@ -269,7 +270,8 @@ targets += $(extra-y) $(MAKECMDGOALS) $(always)
269# Linker scripts preprocessor (.lds.S -> .lds) 270# Linker scripts preprocessor (.lds.S -> .lds)
270# --------------------------------------------------------------------------- 271# ---------------------------------------------------------------------------
271quiet_cmd_cpp_lds_S = LDS $@ 272quiet_cmd_cpp_lds_S = LDS $@
272 cmd_cpp_lds_S = $(CPP) $(cpp_flags) -D__ASSEMBLY__ -o $@ $< 273 cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -C -U$(ARCH) \
274 -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<
273 275
274$(obj)/%.lds: $(src)/%.lds.S FORCE 276$(obj)/%.lds: $(src)/%.lds.S FORCE
275 $(call if_changed_dep,cpp_lds_S) 277 $(call if_changed_dep,cpp_lds_S)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 7a7778746ea6..ffdafb26f539 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -208,7 +208,7 @@ cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -f -9 > $@) || \
208 208
209# Bzip2 and LZMA do not include size in file... so we have to fake that; 209# Bzip2 and LZMA do not include size in file... so we have to fake that;
210# append the size as a 32-bit littleendian number as gzip does. 210# append the size as a 32-bit littleendian number as gzip does.
211size_append = echo -ne $(shell \ 211size_append = /bin/echo -ne $(shell \
212dec_size=0; \ 212dec_size=0; \
213for F in $1; do \ 213for F in $1; do \
214 fsize=$$(stat -c "%s" $$F); \ 214 fsize=$$(stat -c "%s" $$F); \
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index f4053dc7b5d6..8f14c81abbc7 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -13,7 +13,6 @@
13# 2) modpost is then used to 13# 2) modpost is then used to
14# 3) create one <module>.mod.c file pr. module 14# 3) create one <module>.mod.c file pr. module
15# 4) create one Module.symvers file with CRC for all exported symbols 15# 4) create one Module.symvers file with CRC for all exported symbols
16# 4a) [CONFIG_MARKERS] create one Module.markers file listing defined markers
17# 5) compile all <module>.mod.c files 16# 5) compile all <module>.mod.c files
18# 6) final link of the module to a <module.ko> file 17# 6) final link of the module to a <module.ko> file
19 18
@@ -59,10 +58,6 @@ include scripts/Makefile.lib
59 58
60kernelsymfile := $(objtree)/Module.symvers 59kernelsymfile := $(objtree)/Module.symvers
61modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers 60modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers
62kernelmarkersfile := $(objtree)/Module.markers
63modulemarkersfile := $(firstword $(KBUILD_EXTMOD))/Module.markers
64
65markersfile = $(if $(KBUILD_EXTMOD),$(modulemarkersfile),$(kernelmarkersfile))
66 61
67# Step 1), find all modules listed in $(MODVERDIR)/ 62# Step 1), find all modules listed in $(MODVERDIR)/
68__modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod))) 63__modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod)))
@@ -85,8 +80,6 @@ modpost = scripts/mod/modpost \
85 $(if $(KBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(KBUILD_EXTRA_SYMBOLS))) \ 80 $(if $(KBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(KBUILD_EXTRA_SYMBOLS))) \
86 $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ 81 $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
87 $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \ 82 $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \
88 $(if $(CONFIG_MARKERS),-K $(kernelmarkersfile)) \
89 $(if $(CONFIG_MARKERS),-M $(markersfile)) \
90 $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) \ 83 $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) \
91 $(if $(cross_build),-c) 84 $(if $(cross_build),-c)
92 85
@@ -101,17 +94,12 @@ quiet_cmd_kernel-mod = MODPOST $@
101 cmd_kernel-mod = $(modpost) $@ 94 cmd_kernel-mod = $(modpost) $@
102 95
103vmlinux.o: FORCE 96vmlinux.o: FORCE
104 @rm -fr $(kernelmarkersfile)
105 $(call cmd,kernel-mod) 97 $(call cmd,kernel-mod)
106 98
107# Declare generated files as targets for modpost 99# Declare generated files as targets for modpost
108$(symverfile): __modpost ; 100$(symverfile): __modpost ;
109$(modules:.ko=.mod.c): __modpost ; 101$(modules:.ko=.mod.c): __modpost ;
110 102
111ifdef CONFIG_MARKERS
112$(markersfile): __modpost ;
113endif
114
115 103
116# Step 5), compile all *.mod.c files 104# Step 5), compile all *.mod.c files
117 105
diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c
index 99ca7a698687..79ab973fb43a 100644
--- a/scripts/basic/docproc.c
+++ b/scripts/basic/docproc.c
@@ -71,7 +71,7 @@ FILELINE * docsection;
71 71
72static char *srctree, *kernsrctree; 72static char *srctree, *kernsrctree;
73 73
74void usage (void) 74static void usage (void)
75{ 75{
76 fprintf(stderr, "Usage: docproc {doc|depend} file\n"); 76 fprintf(stderr, "Usage: docproc {doc|depend} file\n");
77 fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n"); 77 fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n");
@@ -84,7 +84,7 @@ void usage (void)
84/* 84/*
85 * Execute kernel-doc with parameters given in svec 85 * Execute kernel-doc with parameters given in svec
86 */ 86 */
87void exec_kernel_doc(char **svec) 87static void exec_kernel_doc(char **svec)
88{ 88{
89 pid_t pid; 89 pid_t pid;
90 int ret; 90 int ret;
@@ -129,7 +129,7 @@ struct symfile
129struct symfile symfilelist[MAXFILES]; 129struct symfile symfilelist[MAXFILES];
130int symfilecnt = 0; 130int symfilecnt = 0;
131 131
132void add_new_symbol(struct symfile *sym, char * symname) 132static void add_new_symbol(struct symfile *sym, char * symname)
133{ 133{
134 sym->symbollist = 134 sym->symbollist =
135 realloc(sym->symbollist, (sym->symbolcnt + 1) * sizeof(char *)); 135 realloc(sym->symbollist, (sym->symbolcnt + 1) * sizeof(char *));
@@ -137,14 +137,14 @@ void add_new_symbol(struct symfile *sym, char * symname)
137} 137}
138 138
139/* Add a filename to the list */ 139/* Add a filename to the list */
140struct symfile * add_new_file(char * filename) 140static struct symfile * add_new_file(char * filename)
141{ 141{
142 symfilelist[symfilecnt++].filename = strdup(filename); 142 symfilelist[symfilecnt++].filename = strdup(filename);
143 return &symfilelist[symfilecnt - 1]; 143 return &symfilelist[symfilecnt - 1];
144} 144}
145 145
146/* Check if file already are present in the list */ 146/* Check if file already are present in the list */
147struct symfile * filename_exist(char * filename) 147static struct symfile * filename_exist(char * filename)
148{ 148{
149 int i; 149 int i;
150 for (i=0; i < symfilecnt; i++) 150 for (i=0; i < symfilecnt; i++)
@@ -157,20 +157,20 @@ struct symfile * filename_exist(char * filename)
157 * List all files referenced within the template file. 157 * List all files referenced within the template file.
158 * Files are separated by tabs. 158 * Files are separated by tabs.
159 */ 159 */
160void adddep(char * file) { printf("\t%s", file); } 160static void adddep(char * file) { printf("\t%s", file); }
161void adddep2(char * file, char * line) { line = line; adddep(file); } 161static void adddep2(char * file, char * line) { line = line; adddep(file); }
162void noaction(char * line) { line = line; } 162static void noaction(char * line) { line = line; }
163void noaction2(char * file, char * line) { file = file; line = line; } 163static void noaction2(char * file, char * line) { file = file; line = line; }
164 164
165/* Echo the line without further action */ 165/* Echo the line without further action */
166void printline(char * line) { printf("%s", line); } 166static void printline(char * line) { printf("%s", line); }
167 167
168/* 168/*
169 * Find all symbols in filename that are exported with EXPORT_SYMBOL & 169 * Find all symbols in filename that are exported with EXPORT_SYMBOL &
170 * EXPORT_SYMBOL_GPL (& EXPORT_SYMBOL_GPL_FUTURE implicitly). 170 * EXPORT_SYMBOL_GPL (& EXPORT_SYMBOL_GPL_FUTURE implicitly).
171 * All symbols located are stored in symfilelist. 171 * All symbols located are stored in symfilelist.
172 */ 172 */
173void find_export_symbols(char * filename) 173static void find_export_symbols(char * filename)
174{ 174{
175 FILE * fp; 175 FILE * fp;
176 struct symfile *sym; 176 struct symfile *sym;
@@ -227,7 +227,7 @@ void find_export_symbols(char * filename)
227 * intfunc uses -nofunction 227 * intfunc uses -nofunction
228 * extfunc uses -function 228 * extfunc uses -function
229 */ 229 */
230void docfunctions(char * filename, char * type) 230static void docfunctions(char * filename, char * type)
231{ 231{
232 int i,j; 232 int i,j;
233 int symcnt = 0; 233 int symcnt = 0;
@@ -258,15 +258,15 @@ void docfunctions(char * filename, char * type)
258 fflush(stdout); 258 fflush(stdout);
259 free(vec); 259 free(vec);
260} 260}
261void intfunc(char * filename) { docfunctions(filename, NOFUNCTION); } 261static void intfunc(char * filename) { docfunctions(filename, NOFUNCTION); }
262void extfunc(char * filename) { docfunctions(filename, FUNCTION); } 262static void extfunc(char * filename) { docfunctions(filename, FUNCTION); }
263 263
264/* 264/*
265 * Document specific function(s) in a file. 265 * Document specific function(s) in a file.
266 * Call kernel-doc with the following parameters: 266 * Call kernel-doc with the following parameters:
267 * kernel-doc -docbook -function function1 [-function function2] 267 * kernel-doc -docbook -function function1 [-function function2]
268 */ 268 */
269void singfunc(char * filename, char * line) 269static void singfunc(char * filename, char * line)
270{ 270{
271 char *vec[200]; /* Enough for specific functions */ 271 char *vec[200]; /* Enough for specific functions */
272 int i, idx = 0; 272 int i, idx = 0;
@@ -297,7 +297,7 @@ void singfunc(char * filename, char * line)
297 * Call kernel-doc with the following parameters: 297 * Call kernel-doc with the following parameters:
298 * kernel-doc -docbook -function "doc section" filename 298 * kernel-doc -docbook -function "doc section" filename
299 */ 299 */
300void docsect(char *filename, char *line) 300static void docsect(char *filename, char *line)
301{ 301{
302 char *vec[6]; /* kerneldoc -docbook -function "section" file NULL */ 302 char *vec[6]; /* kerneldoc -docbook -function "section" file NULL */
303 char *s; 303 char *s;
@@ -324,7 +324,7 @@ void docsect(char *filename, char *line)
324 * 5) Lines containing !P 324 * 5) Lines containing !P
325 * 6) Default lines - lines not matching the above 325 * 6) Default lines - lines not matching the above
326 */ 326 */
327void parse_file(FILE *infile) 327static void parse_file(FILE *infile)
328{ 328{
329 char line[MAXLINESZ]; 329 char line[MAXLINESZ];
330 char * s; 330 char * s;
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index 72c15205bb2b..6bf21f83837d 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -16,8 +16,7 @@
16 * tells make when to remake a file. 16 * tells make when to remake a file.
17 * 17 *
18 * To use this list as-is however has the drawback that virtually 18 * To use this list as-is however has the drawback that virtually
19 * every file in the kernel includes <linux/config.h> which then again 19 * every file in the kernel includes <linux/autoconf.h>.
20 * includes <linux/autoconf.h>
21 * 20 *
22 * If the user re-runs make *config, linux/autoconf.h will be 21 * If the user re-runs make *config, linux/autoconf.h will be
23 * regenerated. make notices that and will rebuild every file which 22 * regenerated. make notices that and will rebuild every file which
@@ -125,8 +124,7 @@ char *target;
125char *depfile; 124char *depfile;
126char *cmdline; 125char *cmdline;
127 126
128void usage(void) 127static void usage(void)
129
130{ 128{
131 fprintf(stderr, "Usage: fixdep <depfile> <target> <cmdline>\n"); 129 fprintf(stderr, "Usage: fixdep <depfile> <target> <cmdline>\n");
132 exit(1); 130 exit(1);
@@ -135,7 +133,7 @@ void usage(void)
135/* 133/*
136 * Print out the commandline prefixed with cmd_<target filename> := 134 * Print out the commandline prefixed with cmd_<target filename> :=
137 */ 135 */
138void print_cmdline(void) 136static void print_cmdline(void)
139{ 137{
140 printf("cmd_%s := %s\n\n", target, cmdline); 138 printf("cmd_%s := %s\n\n", target, cmdline);
141} 139}
@@ -148,7 +146,7 @@ int len_config = 0;
148 * Grow the configuration string to a desired length. 146 * Grow the configuration string to a desired length.
149 * Usually the first growth is plenty. 147 * Usually the first growth is plenty.
150 */ 148 */
151void grow_config(int len) 149static void grow_config(int len)
152{ 150{
153 while (len_config + len > size_config) { 151 while (len_config + len > size_config) {
154 if (size_config == 0) 152 if (size_config == 0)
@@ -164,7 +162,7 @@ void grow_config(int len)
164/* 162/*
165 * Lookup a value in the configuration string. 163 * Lookup a value in the configuration string.
166 */ 164 */
167int is_defined_config(const char * name, int len) 165static int is_defined_config(const char * name, int len)
168{ 166{
169 const char * pconfig; 167 const char * pconfig;
170 const char * plast = str_config + len_config - len; 168 const char * plast = str_config + len_config - len;
@@ -180,7 +178,7 @@ int is_defined_config(const char * name, int len)
180/* 178/*
181 * Add a new value to the configuration string. 179 * Add a new value to the configuration string.
182 */ 180 */
183void define_config(const char * name, int len) 181static void define_config(const char * name, int len)
184{ 182{
185 grow_config(len + 1); 183 grow_config(len + 1);
186 184
@@ -192,7 +190,7 @@ void define_config(const char * name, int len)
192/* 190/*
193 * Clear the set of configuration strings. 191 * Clear the set of configuration strings.
194 */ 192 */
195void clear_config(void) 193static void clear_config(void)
196{ 194{
197 len_config = 0; 195 len_config = 0;
198 define_config("", 0); 196 define_config("", 0);
@@ -201,7 +199,7 @@ void clear_config(void)
201/* 199/*
202 * Record the use of a CONFIG_* word. 200 * Record the use of a CONFIG_* word.
203 */ 201 */
204void use_config(char *m, int slen) 202static void use_config(char *m, int slen)
205{ 203{
206 char s[PATH_MAX]; 204 char s[PATH_MAX];
207 char *p; 205 char *p;
@@ -222,7 +220,7 @@ void use_config(char *m, int slen)
222 printf(" $(wildcard include/config/%s.h) \\\n", s); 220 printf(" $(wildcard include/config/%s.h) \\\n", s);
223} 221}
224 222
225void parse_config_file(char *map, size_t len) 223static void parse_config_file(char *map, size_t len)
226{ 224{
227 int *end = (int *) (map + len); 225 int *end = (int *) (map + len);
228 /* start at +1, so that p can never be < map */ 226 /* start at +1, so that p can never be < map */
@@ -256,7 +254,7 @@ void parse_config_file(char *map, size_t len)
256} 254}
257 255
258/* test is s ends in sub */ 256/* test is s ends in sub */
259int strrcmp(char *s, char *sub) 257static int strrcmp(char *s, char *sub)
260{ 258{
261 int slen = strlen(s); 259 int slen = strlen(s);
262 int sublen = strlen(sub); 260 int sublen = strlen(sub);
@@ -267,7 +265,7 @@ int strrcmp(char *s, char *sub)
267 return memcmp(s + slen - sublen, sub, sublen); 265 return memcmp(s + slen - sublen, sub, sublen);
268} 266}
269 267
270void do_config_file(char *filename) 268static void do_config_file(char *filename)
271{ 269{
272 struct stat st; 270 struct stat st;
273 int fd; 271 int fd;
@@ -298,7 +296,7 @@ void do_config_file(char *filename)
298 close(fd); 296 close(fd);
299} 297}
300 298
301void parse_dep_file(void *map, size_t len) 299static void parse_dep_file(void *map, size_t len)
302{ 300{
303 char *m = map; 301 char *m = map;
304 char *end = m + len; 302 char *end = m + len;
@@ -338,7 +336,7 @@ void parse_dep_file(void *map, size_t len)
338 printf("$(deps_%s):\n", target); 336 printf("$(deps_%s):\n", target);
339} 337}
340 338
341void print_deps(void) 339static void print_deps(void)
342{ 340{
343 struct stat st; 341 struct stat st;
344 int fd; 342 int fd;
@@ -370,7 +368,7 @@ void print_deps(void)
370 close(fd); 368 close(fd);
371} 369}
372 370
373void traps(void) 371static void traps(void)
374{ 372{
375 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF"; 373 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
376 int *p = (int *)test; 374 int *p = (int *)test;
diff --git a/scripts/basic/hash.c b/scripts/basic/hash.c
index 3299ad7fc8c0..2ef5d3f666b8 100644
--- a/scripts/basic/hash.c
+++ b/scripts/basic/hash.c
@@ -21,7 +21,7 @@ static void usage(void)
21 * http://www.cse.yorku.ca/~oz/hash.html 21 * http://www.cse.yorku.ca/~oz/hash.html
22 */ 22 */
23 23
24unsigned int djb2_hash(char *str) 24static unsigned int djb2_hash(char *str)
25{ 25{
26 unsigned long hash = 5381; 26 unsigned long hash = 5381;
27 int c; 27 int c;
@@ -34,7 +34,7 @@ unsigned int djb2_hash(char *str)
34 return (unsigned int)(hash & ((1 << DYNAMIC_DEBUG_HASH_BITS) - 1)); 34 return (unsigned int)(hash & ((1 << DYNAMIC_DEBUG_HASH_BITS) - 1));
35} 35}
36 36
37unsigned int r5_hash(char *str) 37static unsigned int r5_hash(char *str)
38{ 38{
39 unsigned long hash = 0; 39 unsigned long hash = 0;
40 int c; 40 int c;
diff --git a/scripts/checkincludes.pl b/scripts/checkincludes.pl
index 8e6b716c191c..676ddc07d6fa 100755
--- a/scripts/checkincludes.pl
+++ b/scripts/checkincludes.pl
@@ -1,24 +1,85 @@
1#!/usr/bin/perl 1#!/usr/bin/perl
2# 2#
3# checkincludes: Find files included more than once in (other) files. 3# checkincludes: find/remove files included more than once
4#
4# Copyright abandoned, 2000, Niels Kristian Bech Jensen <nkbj@image.dk>. 5# Copyright abandoned, 2000, Niels Kristian Bech Jensen <nkbj@image.dk>.
6# Copyright 2009 Luis R. Rodriguez <mcgrof@gmail.com>
7#
8# This script checks for duplicate includes. It also has support
9# to remove them in place. Note that this will not take into
10# consideration macros so you should run this only if you know
11# you do have real dups and do not have them under #ifdef's. You
12# could also just review the results.
13
14sub usage {
15 print "Usage: checkincludes.pl [-r]\n";
16 print "By default we just warn of duplicates\n";
17 print "To remove duplicated includes in place use -r\n";
18 exit 1;
19}
20
21my $remove = 0;
22
23if ($#ARGV < 0) {
24 usage();
25}
26
27if ($#ARGV >= 1) {
28 if ($ARGV[0] =~ /^-/) {
29 if ($ARGV[0] eq "-r") {
30 $remove = 1;
31 shift;
32 } else {
33 usage();
34 }
35 }
36}
5 37
6foreach $file (@ARGV) { 38foreach $file (@ARGV) {
7 open(FILE, $file) or die "Cannot open $file: $!.\n"; 39 open(FILE, $file) or die "Cannot open $file: $!.\n";
8 40
9 my %includedfiles = (); 41 my %includedfiles = ();
42 my @file_lines = ();
10 43
11 while (<FILE>) { 44 while (<FILE>) {
12 if (m/^\s*#\s*include\s*[<"](\S*)[>"]/o) { 45 if (m/^\s*#\s*include\s*[<"](\S*)[>"]/o) {
13 ++$includedfiles{$1}; 46 ++$includedfiles{$1};
14 } 47 }
48 push(@file_lines, $_);
15 } 49 }
16 50
17 foreach $filename (keys %includedfiles) { 51 close(FILE);
18 if ($includedfiles{$filename} > 1) { 52
19 print "$file: $filename is included more than once.\n"; 53 if (!$remove) {
54 foreach $filename (keys %includedfiles) {
55 if ($includedfiles{$filename} > 1) {
56 print "$file: $filename is included more than once.\n";
57 }
20 } 58 }
59 next;
21 } 60 }
22 61
62 open(FILE,">$file") || die("Cannot write to $file: $!");
63
64 my $dups = 0;
65 foreach (@file_lines) {
66 if (m/^\s*#\s*include\s*[<"](\S*)[>"]/o) {
67 foreach $filename (keys %includedfiles) {
68 if ($1 eq $filename) {
69 if ($includedfiles{$filename} > 1) {
70 $includedfiles{$filename}--;
71 $dups++;
72 } else {
73 print FILE $_;
74 }
75 }
76 }
77 } else {
78 print FILE $_;
79 }
80 }
81 if ($dups > 0) {
82 print "$file: removed $dups duplicate includes\n";
83 }
23 close(FILE); 84 close(FILE);
24} 85}
diff --git a/scripts/checkkconfigsymbols.sh b/scripts/checkkconfigsymbols.sh
index 39677c82747a..46be3c5a62b7 100755
--- a/scripts/checkkconfigsymbols.sh
+++ b/scripts/checkkconfigsymbols.sh
@@ -9,7 +9,7 @@ paths="$@"
9# Doing this once at the beginning saves a lot of time, on a cache-hot tree. 9# Doing this once at the beginning saves a lot of time, on a cache-hot tree.
10Kconfigs="`find . -name 'Kconfig' -o -name 'Kconfig*[^~]'`" 10Kconfigs="`find . -name 'Kconfig' -o -name 'Kconfig*[^~]'`"
11 11
12echo -e "File list \tundefined symbol used" 12/bin/echo -e "File list \tundefined symbol used"
13find $paths -name '*.[chS]' -o -name 'Makefile' -o -name 'Makefile*[^~]'| while read i 13find $paths -name '*.[chS]' -o -name 'Makefile' -o -name 'Makefile*[^~]'| while read i
14do 14do
15 # Output the bare Kconfig variable and the filename; the _MODULE part at 15 # Output the bare Kconfig variable and the filename; the _MODULE part at
@@ -54,6 +54,6 @@ while read symb files; do
54 # beyond the purpose of this script. 54 # beyond the purpose of this script.
55 symb_bare=`echo $symb | sed -e 's/_MODULE//'` 55 symb_bare=`echo $symb | sed -e 's/_MODULE//'`
56 if ! grep -q "\<$symb_bare\>" $Kconfigs; then 56 if ! grep -q "\<$symb_bare\>" $Kconfigs; then
57 echo -e "$files: \t$symb" 57 /bin/echo -e "$files: \t$symb"
58 fi 58 fi
59done|sort 59done|sort
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2d5ece798c4c..bc4114f1ab30 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2,7 +2,7 @@
2# (c) 2001, Dave Jones. <davej@redhat.com> (the file handling bit) 2# (c) 2001, Dave Jones. <davej@redhat.com> (the file handling bit)
3# (c) 2005, Joel Schopp <jschopp@austin.ibm.com> (the ugly bit) 3# (c) 2005, Joel Schopp <jschopp@austin.ibm.com> (the ugly bit)
4# (c) 2007,2008, Andy Whitcroft <apw@uk.ibm.com> (new conditions, test suite) 4# (c) 2007,2008, Andy Whitcroft <apw@uk.ibm.com> (new conditions, test suite)
5# (c) 2008, Andy Whitcroft <apw@canonical.com> 5# (c) 2008,2009, Andy Whitcroft <apw@canonical.com>
6# Licensed under the terms of the GNU GPL License version 2 6# Licensed under the terms of the GNU GPL License version 2
7 7
8use strict; 8use strict;
@@ -10,7 +10,7 @@ use strict;
10my $P = $0; 10my $P = $0;
11$P =~ s@.*/@@g; 11$P =~ s@.*/@@g;
12 12
13my $V = '0.28'; 13my $V = '0.30';
14 14
15use Getopt::Long qw(:config no_auto_abbrev); 15use Getopt::Long qw(:config no_auto_abbrev);
16 16
@@ -28,6 +28,41 @@ my $mailback = 0;
28my $summary_file = 0; 28my $summary_file = 0;
29my $root; 29my $root;
30my %debug; 30my %debug;
31my $help = 0;
32
33sub help {
34 my ($exitcode) = @_;
35
36 print << "EOM";
37Usage: $P [OPTION]... [FILE]...
38Version: $V
39
40Options:
41 -q, --quiet quiet
42 --no-tree run without a kernel tree
43 --no-signoff do not check for 'Signed-off-by' line
44 --patch treat FILE as patchfile (default)
45 --emacs emacs compile window format
46 --terse one line per report
47 -f, --file treat FILE as regular source file
48 --subjective, --strict enable more subjective tests
49 --root=PATH PATH to the kernel tree root
50 --no-summary suppress the per-file summary
51 --mailback only produce a report in case of warnings/errors
52 --summary-file include the filename in summary
53 --debug KEY=[0|1] turn on/off debugging of KEY, where KEY is one of
54 'values', 'possible', 'type', and 'attr' (default
55 is all off)
56 --test-only=WORD report only warnings/errors containing WORD
57 literally
58 -h, --help, --version display this help and exit
59
60When FILE is - read standard input.
61EOM
62
63 exit($exitcode);
64}
65
31GetOptions( 66GetOptions(
32 'q|quiet+' => \$quiet, 67 'q|quiet+' => \$quiet,
33 'tree!' => \$tree, 68 'tree!' => \$tree,
@@ -35,7 +70,7 @@ GetOptions(
35 'patch!' => \$chk_patch, 70 'patch!' => \$chk_patch,
36 'emacs!' => \$emacs, 71 'emacs!' => \$emacs,
37 'terse!' => \$terse, 72 'terse!' => \$terse,
38 'file!' => \$file, 73 'f|file!' => \$file,
39 'subjective!' => \$check, 74 'subjective!' => \$check,
40 'strict!' => \$check, 75 'strict!' => \$check,
41 'root=s' => \$root, 76 'root=s' => \$root,
@@ -45,22 +80,16 @@ GetOptions(
45 80
46 'debug=s' => \%debug, 81 'debug=s' => \%debug,
47 'test-only=s' => \$tst_only, 82 'test-only=s' => \$tst_only,
48) or exit; 83 'h|help' => \$help,
84 'version' => \$help
85) or help(1);
86
87help(0) if ($help);
49 88
50my $exit = 0; 89my $exit = 0;
51 90
52if ($#ARGV < 0) { 91if ($#ARGV < 0) {
53 print "usage: $P [options] patchfile\n"; 92 print "$P: no input files\n";
54 print "version: $V\n";
55 print "options: -q => quiet\n";
56 print " --no-tree => run without a kernel tree\n";
57 print " --terse => one line per report\n";
58 print " --emacs => emacs compile window format\n";
59 print " --file => check a source file\n";
60 print " --strict => enable more subjective tests\n";
61 print " --root => path to the kernel tree root\n";
62 print " --no-summary => suppress the per-file summary\n";
63 print " --summary-file => include the filename in summary\n";
64 exit(1); 93 exit(1);
65} 94}
66 95
@@ -101,7 +130,10 @@ if ($tree) {
101 130
102my $emitted_corrupt = 0; 131my $emitted_corrupt = 0;
103 132
104our $Ident = qr{[A-Za-z_][A-Za-z\d_]*}; 133our $Ident = qr{
134 [A-Za-z_][A-Za-z\d_]*
135 (?:\s*\#\#\s*[A-Za-z_][A-Za-z\d_]*)*
136 }x;
105our $Storage = qr{extern|static|asmlinkage}; 137our $Storage = qr{extern|static|asmlinkage};
106our $Sparse = qr{ 138our $Sparse = qr{
107 __user| 139 __user|
@@ -153,7 +185,7 @@ our $UTF8 = qr {
153}x; 185}x;
154 186
155our $typeTypedefs = qr{(?x: 187our $typeTypedefs = qr{(?x:
156 (?:__)?(?:u|s|be|le)(?:\d|\d\d)| 188 (?:__)?(?:u|s|be|le)(?:8|16|32|64)|
157 atomic_t 189 atomic_t
158)}; 190)};
159 191
@@ -356,6 +388,13 @@ sub sanitise_line {
356 $off++; 388 $off++;
357 next; 389 next;
358 } 390 }
391 if ($sanitise_quote eq '' && substr($line, $off, 2) eq '//') {
392 $sanitise_quote = '//';
393
394 substr($res, $off, 2, $sanitise_quote);
395 $off++;
396 next;
397 }
359 398
360 # A \ in a string means ignore the next character. 399 # A \ in a string means ignore the next character.
361 if (($sanitise_quote eq "'" || $sanitise_quote eq '"') && 400 if (($sanitise_quote eq "'" || $sanitise_quote eq '"') &&
@@ -379,6 +418,8 @@ sub sanitise_line {
379 #print "c<$c> SQ<$sanitise_quote>\n"; 418 #print "c<$c> SQ<$sanitise_quote>\n";
380 if ($off != 0 && $sanitise_quote eq '*/' && $c ne "\t") { 419 if ($off != 0 && $sanitise_quote eq '*/' && $c ne "\t") {
381 substr($res, $off, 1, $;); 420 substr($res, $off, 1, $;);
421 } elsif ($off != 0 && $sanitise_quote eq '//' && $c ne "\t") {
422 substr($res, $off, 1, $;);
382 } elsif ($off != 0 && $sanitise_quote && $c ne "\t") { 423 } elsif ($off != 0 && $sanitise_quote && $c ne "\t") {
383 substr($res, $off, 1, 'X'); 424 substr($res, $off, 1, 'X');
384 } else { 425 } else {
@@ -386,6 +427,10 @@ sub sanitise_line {
386 } 427 }
387 } 428 }
388 429
430 if ($sanitise_quote eq '//') {
431 $sanitise_quote = '';
432 }
433
389 # The pathname on a #include may be surrounded by '<' and '>'. 434 # The pathname on a #include may be surrounded by '<' and '>'.
390 if ($res =~ /^.\s*\#\s*include\s+\<(.*)\>/) { 435 if ($res =~ /^.\s*\#\s*include\s+\<(.*)\>/) {
391 my $clean = 'X' x length($1); 436 my $clean = 'X' x length($1);
@@ -955,23 +1000,25 @@ sub annotate_values {
955 1000
956sub possible { 1001sub possible {
957 my ($possible, $line) = @_; 1002 my ($possible, $line) = @_;
958 1003 my $notPermitted = qr{(?:
959 print "CHECK<$possible> ($line)\n" if ($dbg_possible > 2);
960 if ($possible !~ /(?:
961 ^(?: 1004 ^(?:
962 $Modifier| 1005 $Modifier|
963 $Storage| 1006 $Storage|
964 $Type| 1007 $Type|
965 DEFINE_\S+| 1008 DEFINE_\S+
1009 )$|
1010 ^(?:
966 goto| 1011 goto|
967 return| 1012 return|
968 case| 1013 case|
969 else| 1014 else|
970 asm|__asm__| 1015 asm|__asm__|
971 do 1016 do
972 )$| 1017 )(?:\s|$)|
973 ^(?:typedef|struct|enum)\b 1018 ^(?:typedef|struct|enum)\b
974 )/x) { 1019 )}x;
1020 warn "CHECK<$possible> ($line)\n" if ($dbg_possible > 2);
1021 if ($possible !~ $notPermitted) {
975 # Check for modifiers. 1022 # Check for modifiers.
976 $possible =~ s/\s*$Storage\s*//g; 1023 $possible =~ s/\s*$Storage\s*//g;
977 $possible =~ s/\s*$Sparse\s*//g; 1024 $possible =~ s/\s*$Sparse\s*//g;
@@ -980,8 +1027,10 @@ sub possible {
980 } elsif ($possible =~ /\s/) { 1027 } elsif ($possible =~ /\s/) {
981 $possible =~ s/\s*$Type\s*//g; 1028 $possible =~ s/\s*$Type\s*//g;
982 for my $modifier (split(' ', $possible)) { 1029 for my $modifier (split(' ', $possible)) {
983 warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible); 1030 if ($modifier !~ $notPermitted) {
984 push(@modifierList, $modifier); 1031 warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible);
1032 push(@modifierList, $modifier);
1033 }
985 } 1034 }
986 1035
987 } else { 1036 } else {
@@ -1096,6 +1145,7 @@ sub process {
1096 # suppression flags 1145 # suppression flags
1097 my %suppress_ifbraces; 1146 my %suppress_ifbraces;
1098 my %suppress_whiletrailers; 1147 my %suppress_whiletrailers;
1148 my %suppress_export;
1099 1149
1100 # Pre-scan the patch sanitizing the lines. 1150 # Pre-scan the patch sanitizing the lines.
1101 # Pre-scan the patch looking for any __setup documentation. 1151 # Pre-scan the patch looking for any __setup documentation.
@@ -1188,7 +1238,6 @@ sub process {
1188 $linenr++; 1238 $linenr++;
1189 1239
1190 my $rawline = $rawlines[$linenr - 1]; 1240 my $rawline = $rawlines[$linenr - 1];
1191 my $hunk_line = ($realcnt != 0);
1192 1241
1193#extract the line range in the file after the patch is applied 1242#extract the line range in the file after the patch is applied
1194 if ($line=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) { 1243 if ($line=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
@@ -1205,6 +1254,7 @@ sub process {
1205 1254
1206 %suppress_ifbraces = (); 1255 %suppress_ifbraces = ();
1207 %suppress_whiletrailers = (); 1256 %suppress_whiletrailers = ();
1257 %suppress_export = ();
1208 next; 1258 next;
1209 1259
1210# track the line number as we move through the hunk, note that 1260# track the line number as we move through the hunk, note that
@@ -1228,6 +1278,8 @@ sub process {
1228 $realcnt--; 1278 $realcnt--;
1229 } 1279 }
1230 1280
1281 my $hunk_line = ($realcnt != 0);
1282
1231#make up the handle for any error we report on this line 1283#make up the handle for any error we report on this line
1232 $prefix = "$filename:$realline: " if ($emacs && $file); 1284 $prefix = "$filename:$realline: " if ($emacs && $file);
1233 $prefix = "$filename:$linenr: " if ($emacs && !$file); 1285 $prefix = "$filename:$linenr: " if ($emacs && !$file);
@@ -1336,6 +1388,18 @@ sub process {
1336 WARN("adding a line without newline at end of file\n" . $herecurr); 1388 WARN("adding a line without newline at end of file\n" . $herecurr);
1337 } 1389 }
1338 1390
1391# Blackfin: use hi/lo macros
1392 if ($realfile =~ m@arch/blackfin/.*\.S$@) {
1393 if ($line =~ /\.[lL][[:space:]]*=.*&[[:space:]]*0x[fF][fF][fF][fF]/) {
1394 my $herevet = "$here\n" . cat_vet($line) . "\n";
1395 ERROR("use the LO() macro, not (... & 0xFFFF)\n" . $herevet);
1396 }
1397 if ($line =~ /\.[hH][[:space:]]*=.*>>[[:space:]]*16/) {
1398 my $herevet = "$here\n" . cat_vet($line) . "\n";
1399 ERROR("use the HI() macro, not (... >> 16)\n" . $herevet);
1400 }
1401 }
1402
1339# check we are in a valid source file C or perl if not then ignore this hunk 1403# check we are in a valid source file C or perl if not then ignore this hunk
1340 next if ($realfile !~ /\.(h|c|pl)$/); 1404 next if ($realfile !~ /\.(h|c|pl)$/);
1341 1405
@@ -1355,14 +1419,33 @@ sub process {
1355 WARN("CVS style keyword markers, these will _not_ be updated\n". $herecurr); 1419 WARN("CVS style keyword markers, these will _not_ be updated\n". $herecurr);
1356 } 1420 }
1357 1421
1422# Blackfin: don't use __builtin_bfin_[cs]sync
1423 if ($line =~ /__builtin_bfin_csync/) {
1424 my $herevet = "$here\n" . cat_vet($line) . "\n";
1425 ERROR("use the CSYNC() macro in asm/blackfin.h\n" . $herevet);
1426 }
1427 if ($line =~ /__builtin_bfin_ssync/) {
1428 my $herevet = "$here\n" . cat_vet($line) . "\n";
1429 ERROR("use the SSYNC() macro in asm/blackfin.h\n" . $herevet);
1430 }
1431
1358# Check for potential 'bare' types 1432# Check for potential 'bare' types
1359 my ($stat, $cond, $line_nr_next, $remain_next, $off_next); 1433 my ($stat, $cond, $line_nr_next, $remain_next, $off_next,
1434 $realline_next);
1360 if ($realcnt && $line =~ /.\s*\S/) { 1435 if ($realcnt && $line =~ /.\s*\S/) {
1361 ($stat, $cond, $line_nr_next, $remain_next, $off_next) = 1436 ($stat, $cond, $line_nr_next, $remain_next, $off_next) =
1362 ctx_statement_block($linenr, $realcnt, 0); 1437 ctx_statement_block($linenr, $realcnt, 0);
1363 $stat =~ s/\n./\n /g; 1438 $stat =~ s/\n./\n /g;
1364 $cond =~ s/\n./\n /g; 1439 $cond =~ s/\n./\n /g;
1365 1440
1441 # Find the real next line.
1442 $realline_next = $line_nr_next;
1443 if (defined $realline_next &&
1444 (!defined $lines[$realline_next - 1] ||
1445 substr($lines[$realline_next - 1], $off_next) =~ /^\s*$/)) {
1446 $realline_next++;
1447 }
1448
1366 my $s = $stat; 1449 my $s = $stat;
1367 $s =~ s/{.*$//s; 1450 $s =~ s/{.*$//s;
1368 1451
@@ -1372,6 +1455,8 @@ sub process {
1372 # Ignore functions being called 1455 # Ignore functions being called
1373 } elsif ($s =~ /^.\s*$Ident\s*\(/s) { 1456 } elsif ($s =~ /^.\s*$Ident\s*\(/s) {
1374 1457
1458 } elsif ($s =~ /^.\s*else\b/s) {
1459
1375 # declarations always start with types 1460 # declarations always start with types
1376 } elsif ($prev_values eq 'E' && $s =~ /^.\s*(?:$Storage\s+)?(?:$Inline\s+)?(?:const\s+)?((?:\s*$Ident)+?)\b(?:\s+$Sparse)?\s*\**\s*(?:$Ident|\(\*[^\)]*\))(?:\s*$Modifier)?\s*(?:;|=|,|\()/s) { 1461 } elsif ($prev_values eq 'E' && $s =~ /^.\s*(?:$Storage\s+)?(?:$Inline\s+)?(?:const\s+)?((?:\s*$Ident)+?)\b(?:\s+$Sparse)?\s*\**\s*(?:$Ident|\(\*[^\)]*\))(?:\s*$Modifier)?\s*(?:;|=|,|\()/s) {
1377 my $type = $1; 1462 my $type = $1;
@@ -1532,8 +1617,9 @@ sub process {
1532 $s =~ /^\s*#\s*?/ || 1617 $s =~ /^\s*#\s*?/ ||
1533 $s =~ /^\s*$Ident\s*:/) { 1618 $s =~ /^\s*$Ident\s*:/) {
1534 $continuation = ($s =~ /^.*?\\\n/) ? 1 : 0; 1619 $continuation = ($s =~ /^.*?\\\n/) ? 1 : 0;
1535 $s =~ s/^.*?\n//; 1620 if ($s =~ s/^.*?\n//) {
1536 $cond_lines++; 1621 $cond_lines++;
1622 }
1537 } 1623 }
1538 } 1624 }
1539 1625
@@ -1594,8 +1680,8 @@ sub process {
1594 } 1680 }
1595 1681
1596# check for initialisation to aggregates open brace on the next line 1682# check for initialisation to aggregates open brace on the next line
1597 if ($prevline =~ /$Declare\s*$Ident\s*=\s*$/ && 1683 if ($line =~ /^.\s*{/ &&
1598 $line =~ /^.\s*{/) { 1684 $prevline =~ /(?:^|[^=])=\s*$/) {
1599 ERROR("that open brace { should be on the previous line\n" . $hereprev); 1685 ERROR("that open brace { should be on the previous line\n" . $hereprev);
1600 } 1686 }
1601 1687
@@ -1620,21 +1706,40 @@ sub process {
1620 $line =~ s@//.*@@; 1706 $line =~ s@//.*@@;
1621 $opline =~ s@//.*@@; 1707 $opline =~ s@//.*@@;
1622 1708
1623#EXPORT_SYMBOL should immediately follow its function closing }. 1709# EXPORT_SYMBOL should immediately follow the thing it is exporting, consider
1624 if (($line =~ /EXPORT_SYMBOL.*\((.*)\)/) || 1710# the whole statement.
1625 ($line =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) { 1711#print "APW <$lines[$realline_next - 1]>\n";
1712 if (defined $realline_next &&
1713 exists $lines[$realline_next - 1] &&
1714 !defined $suppress_export{$realline_next} &&
1715 ($lines[$realline_next - 1] =~ /EXPORT_SYMBOL.*\((.*)\)/ ||
1716 $lines[$realline_next - 1] =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) {
1626 my $name = $1; 1717 my $name = $1;
1627 if ($prevline !~ /(?: 1718 if ($stat !~ /(?:
1628 ^.}| 1719 \n.}\s*$|
1629 ^.DEFINE_$Ident\(\Q$name\E\)| 1720 ^.DEFINE_$Ident\(\Q$name\E\)|
1630 ^.DECLARE_$Ident\(\Q$name\E\)| 1721 ^.DECLARE_$Ident\(\Q$name\E\)|
1631 ^.LIST_HEAD\(\Q$name\E\)| 1722 ^.LIST_HEAD\(\Q$name\E\)|
1632 ^.$Type\s*\(\s*\*\s*\Q$name\E\s*\)\s*\(| 1723 ^.(?:$Storage\s+)?$Type\s*\(\s*\*\s*\Q$name\E\s*\)\s*\(|
1633 \b\Q$name\E(?:\s+$Attribute)?\s*(?:;|=|\[) 1724 \b\Q$name\E(?:\s+$Attribute)*\s*(?:;|=|\[|\()
1634 )/x) { 1725 )/x) {
1635 WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr); 1726#print "FOO A<$lines[$realline_next - 1]> stat<$stat> name<$name>\n";
1727 $suppress_export{$realline_next} = 2;
1728 } else {
1729 $suppress_export{$realline_next} = 1;
1636 } 1730 }
1637 } 1731 }
1732 if (!defined $suppress_export{$linenr} &&
1733 $prevline =~ /^.\s*$/ &&
1734 ($line =~ /EXPORT_SYMBOL.*\((.*)\)/ ||
1735 $line =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) {
1736#print "FOO B <$lines[$linenr - 1]>\n";
1737 $suppress_export{$linenr} = 2;
1738 }
1739 if (defined $suppress_export{$linenr} &&
1740 $suppress_export{$linenr} == 2) {
1741 WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr);
1742 }
1638 1743
1639# check for external initialisers. 1744# check for external initialisers.
1640 if ($line =~ /^.$Type\s*$Ident\s*(?:\s+$Modifier)*\s*=\s*(0|NULL|false)\s*;/) { 1745 if ($line =~ /^.$Type\s*$Ident\s*(?:\s+$Modifier)*\s*=\s*(0|NULL|false)\s*;/) {
@@ -1891,7 +1996,7 @@ sub process {
1891 # A unary '*' may be const 1996 # A unary '*' may be const
1892 1997
1893 } elsif ($ctx =~ /.xW/) { 1998 } elsif ($ctx =~ /.xW/) {
1894 ERROR("Aspace prohibited after that '$op' $at\n" . $hereptr); 1999 ERROR("space prohibited after that '$op' $at\n" . $hereptr);
1895 } 2000 }
1896 2001
1897 # unary ++ and unary -- are allowed no space on one side. 2002 # unary ++ and unary -- are allowed no space on one side.
@@ -2243,7 +2348,8 @@ sub process {
2243 DECLARE_PER_CPU| 2348 DECLARE_PER_CPU|
2244 DEFINE_PER_CPU| 2349 DEFINE_PER_CPU|
2245 __typeof__\(| 2350 __typeof__\(|
2246 \.$Ident\s*=\s* 2351 \.$Ident\s*=\s*|
2352 ^\"|\"$
2247 }x; 2353 }x;
2248 #print "REST<$rest> dstat<$dstat>\n"; 2354 #print "REST<$rest> dstat<$dstat>\n";
2249 if ($rest ne '') { 2355 if ($rest ne '') {
diff --git a/scripts/conmakehash.c b/scripts/conmakehash.c
index e0c6891a9ad4..263a44d57fa9 100644
--- a/scripts/conmakehash.c
+++ b/scripts/conmakehash.c
@@ -24,14 +24,14 @@
24 24
25typedef unsigned short unicode; 25typedef unsigned short unicode;
26 26
27void usage(char *argv0) 27static void usage(char *argv0)
28{ 28{
29 fprintf(stderr, "Usage: \n" 29 fprintf(stderr, "Usage: \n"
30 " %s chartable [hashsize] [hashstep] [maxhashlevel]\n", argv0); 30 " %s chartable [hashsize] [hashstep] [maxhashlevel]\n", argv0);
31 exit(EX_USAGE); 31 exit(EX_USAGE);
32} 32}
33 33
34int getunicode(char **p0) 34static int getunicode(char **p0)
35{ 35{
36 char *p = *p0; 36 char *p = *p0;
37 37
@@ -49,7 +49,7 @@ unicode unitable[MAX_FONTLEN][255];
49 /* Massive overkill, but who cares? */ 49 /* Massive overkill, but who cares? */
50int unicount[MAX_FONTLEN]; 50int unicount[MAX_FONTLEN];
51 51
52void addpair(int fp, int un) 52static void addpair(int fp, int un)
53{ 53{
54 int i; 54 int i;
55 55
diff --git a/scripts/dtc/.gitignore b/scripts/dtc/.gitignore
new file mode 100644
index 000000000000..095acb49a374
--- /dev/null
+++ b/scripts/dtc/.gitignore
@@ -0,0 +1,5 @@
1dtc
2dtc-lexer.lex.c
3dtc-parser.tab.c
4dtc-parser.tab.h
5
diff --git a/scripts/extract-ikconfig b/scripts/extract-ikconfig
index 72997c353cb3..de233ff43c1c 100755
--- a/scripts/extract-ikconfig
+++ b/scripts/extract-ikconfig
@@ -17,6 +17,10 @@ dump_config() {
17 return 17 return
18 fi 18 fi
19 end=`$binoffset $file $IKCFG_ED 2>/dev/null` 19 end=`$binoffset $file $IKCFG_ED 2>/dev/null`
20 [ "$?" != "0" ] && end="-1"
21 if [ "$end" -eq "-1" ]; then
22 return
23 fi
20 24
21 start=`expr $start + 8` 25 start=`expr $start + 8`
22 size=`expr $end - $start` 26 size=`expr $end - $start`
@@ -55,6 +59,8 @@ dump_config "$image"
55GZHDR1="0x1f 0x8b 0x08 0x00" 59GZHDR1="0x1f 0x8b 0x08 0x00"
56GZHDR2="0x1f 0x8b 0x08 0x08" 60GZHDR2="0x1f 0x8b 0x08 0x08"
57 61
62ELFHDR="0x7f 0x45 0x4c 0x46"
63
58# vmlinux.gz: Check for a compressed images 64# vmlinux.gz: Check for a compressed images
59off=`$binoffset "$image" $GZHDR1 2>/dev/null` 65off=`$binoffset "$image" $GZHDR1 2>/dev/null`
60[ "$?" != "0" ] && off="-1" 66[ "$?" != "0" ] && off="-1"
@@ -69,6 +75,14 @@ elif [ "$off" -ne "-1" ]; then
69 (dd ibs="$off" skip=1 count=0 && dd bs=512k) <"$image" 2>/dev/null | \ 75 (dd ibs="$off" skip=1 count=0 && dd bs=512k) <"$image" 2>/dev/null | \
70 zcat >"$TMPFILE" 76 zcat >"$TMPFILE"
71 dump_config "$TMPFILE" 77 dump_config "$TMPFILE"
78
79# check if this is simply an ELF file
80else
81 off=`$binoffset "$image" $ELFHDR 2>/dev/null`
82 [ "$?" != "0" ] && off="-1"
83 if [ "$off" -eq "0" ]; then
84 dump_config "$image"
85 fi
72fi 86fi
73 87
74echo "ERROR: Unable to extract kernel configuration information." 88echo "ERROR: Unable to extract kernel configuration information."
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
index 3a8297b5184c..af6b8363a2d5 100644
--- a/scripts/genksyms/genksyms.c
+++ b/scripts/genksyms/genksyms.c
@@ -176,7 +176,7 @@ static int is_unknown_symbol(struct symbol *sym)
176 strcmp(defn->string, "{") == 0); 176 strcmp(defn->string, "{") == 0);
177} 177}
178 178
179struct symbol *__add_symbol(const char *name, enum symbol_type type, 179static struct symbol *__add_symbol(const char *name, enum symbol_type type,
180 struct string_list *defn, int is_extern, 180 struct string_list *defn, int is_extern,
181 int is_reference) 181 int is_reference)
182{ 182{
@@ -265,7 +265,7 @@ struct symbol *add_symbol(const char *name, enum symbol_type type,
265 return __add_symbol(name, type, defn, is_extern, 0); 265 return __add_symbol(name, type, defn, is_extern, 0);
266} 266}
267 267
268struct symbol *add_reference_symbol(const char *name, enum symbol_type type, 268static struct symbol *add_reference_symbol(const char *name, enum symbol_type type,
269 struct string_list *defn, int is_extern) 269 struct string_list *defn, int is_extern)
270{ 270{
271 return __add_symbol(name, type, defn, is_extern, 1); 271 return __add_symbol(name, type, defn, is_extern, 1);
@@ -313,7 +313,7 @@ static int equal_list(struct string_list *a, struct string_list *b)
313 313
314#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) 314#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
315 315
316struct string_list *read_node(FILE *f) 316static struct string_list *read_node(FILE *f)
317{ 317{
318 char buffer[256]; 318 char buffer[256];
319 struct string_list node = { 319 struct string_list node = {
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index 3e733146cd51..102b76608f35 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -13,7 +13,7 @@
13use strict; 13use strict;
14 14
15my $P = $0; 15my $P = $0;
16my $V = '0.16'; 16my $V = '0.21';
17 17
18use Getopt::Long qw(:config no_auto_abbrev); 18use Getopt::Long qw(:config no_auto_abbrev);
19 19
@@ -27,14 +27,19 @@ my $email_git = 1;
27my $email_git_penguin_chiefs = 0; 27my $email_git_penguin_chiefs = 0;
28my $email_git_min_signatures = 1; 28my $email_git_min_signatures = 1;
29my $email_git_max_maintainers = 5; 29my $email_git_max_maintainers = 5;
30my $email_git_min_percent = 5;
30my $email_git_since = "1-year-ago"; 31my $email_git_since = "1-year-ago";
32my $email_git_blame = 0;
33my $email_remove_duplicates = 1;
31my $output_multiline = 1; 34my $output_multiline = 1;
32my $output_separator = ", "; 35my $output_separator = ", ";
33my $scm = 0; 36my $scm = 0;
34my $web = 0; 37my $web = 0;
35my $subsystem = 0; 38my $subsystem = 0;
36my $status = 0; 39my $status = 0;
40my $keywords = 1;
37my $from_filename = 0; 41my $from_filename = 0;
42my $pattern_depth = 0;
38my $version = 0; 43my $version = 0;
39my $help = 0; 44my $help = 0;
40 45
@@ -65,7 +70,10 @@ if (!GetOptions(
65 'git-chief-penguins!' => \$email_git_penguin_chiefs, 70 'git-chief-penguins!' => \$email_git_penguin_chiefs,
66 'git-min-signatures=i' => \$email_git_min_signatures, 71 'git-min-signatures=i' => \$email_git_min_signatures,
67 'git-max-maintainers=i' => \$email_git_max_maintainers, 72 'git-max-maintainers=i' => \$email_git_max_maintainers,
73 'git-min-percent=i' => \$email_git_min_percent,
68 'git-since=s' => \$email_git_since, 74 'git-since=s' => \$email_git_since,
75 'git-blame!' => \$email_git_blame,
76 'remove-duplicates!' => \$email_remove_duplicates,
69 'm!' => \$email_maintainer, 77 'm!' => \$email_maintainer,
70 'n!' => \$email_usename, 78 'n!' => \$email_usename,
71 'l!' => \$email_list, 79 'l!' => \$email_list,
@@ -76,6 +84,8 @@ if (!GetOptions(
76 'status!' => \$status, 84 'status!' => \$status,
77 'scm!' => \$scm, 85 'scm!' => \$scm,
78 'web!' => \$web, 86 'web!' => \$web,
87 'pattern-depth=i' => \$pattern_depth,
88 'k|keywords!' => \$keywords,
79 'f|file' => \$from_filename, 89 'f|file' => \$from_filename,
80 'v|version' => \$version, 90 'v|version' => \$version,
81 'h|help' => \$help, 91 'h|help' => \$help,
@@ -99,14 +109,19 @@ if ($#ARGV < 0) {
99 die "$P: argument missing: patchfile or -f file please\n"; 109 die "$P: argument missing: patchfile or -f file please\n";
100} 110}
101 111
112if ($output_separator ne ", ") {
113 $output_multiline = 0;
114}
115
102my $selections = $email + $scm + $status + $subsystem + $web; 116my $selections = $email + $scm + $status + $subsystem + $web;
103if ($selections == 0) { 117if ($selections == 0) {
104 usage(); 118 usage();
105 die "$P: Missing required option: email, scm, status, subsystem or web\n"; 119 die "$P: Missing required option: email, scm, status, subsystem or web\n";
106} 120}
107 121
108if ($email && ($email_maintainer + $email_list + $email_subscriber_list 122if ($email &&
109 + $email_git + $email_git_penguin_chiefs) == 0) { 123 ($email_maintainer + $email_list + $email_subscriber_list +
124 $email_git + $email_git_penguin_chiefs + $email_git_blame) == 0) {
110 usage(); 125 usage();
111 die "$P: Please select at least 1 email option\n"; 126 die "$P: Please select at least 1 email option\n";
112} 127}
@@ -119,6 +134,8 @@ if (!top_of_kernel_tree($lk_path)) {
119## Read MAINTAINERS for type/value pairs 134## Read MAINTAINERS for type/value pairs
120 135
121my @typevalue = (); 136my @typevalue = ();
137my %keyword_hash;
138
122open(MAINT, "<${lk_path}MAINTAINERS") || die "$P: Can't open MAINTAINERS\n"; 139open(MAINT, "<${lk_path}MAINTAINERS") || die "$P: Can't open MAINTAINERS\n";
123while (<MAINT>) { 140while (<MAINT>) {
124 my $line = $_; 141 my $line = $_;
@@ -132,6 +149,12 @@ while (<MAINT>) {
132 $value =~ s@\.@\\\.@g; ##Convert . to \. 149 $value =~ s@\.@\\\.@g; ##Convert . to \.
133 $value =~ s/\*/\.\*/g; ##Convert * to .* 150 $value =~ s/\*/\.\*/g; ##Convert * to .*
134 $value =~ s/\?/\./g; ##Convert ? to . 151 $value =~ s/\?/\./g; ##Convert ? to .
152 ##if pattern is a directory and it lacks a trailing slash, add one
153 if ((-d $value)) {
154 $value =~ s@([^/])$@$1/@;
155 }
156 } elsif ($type eq "K") {
157 $keyword_hash{@typevalue} = $value;
135 } 158 }
136 push(@typevalue, "$type:$value"); 159 push(@typevalue, "$type:$value");
137 } elsif (!/^(\s)*$/) { 160 } elsif (!/^(\s)*$/) {
@@ -141,26 +164,81 @@ while (<MAINT>) {
141} 164}
142close(MAINT); 165close(MAINT);
143 166
167my %mailmap;
168
169if ($email_remove_duplicates) {
170 open(MAILMAP, "<${lk_path}.mailmap") || warn "$P: Can't open .mailmap\n";
171 while (<MAILMAP>) {
172 my $line = $_;
173
174 next if ($line =~ m/^\s*#/);
175 next if ($line =~ m/^\s*$/);
176
177 my ($name, $address) = parse_email($line);
178 $line = format_email($name, $address);
179
180 next if ($line =~ m/^\s*$/);
181
182 if (exists($mailmap{$name})) {
183 my $obj = $mailmap{$name};
184 push(@$obj, $address);
185 } else {
186 my @arr = ($address);
187 $mailmap{$name} = \@arr;
188 }
189 }
190 close(MAILMAP);
191}
192
144## use the filenames on the command line or find the filenames in the patchfiles 193## use the filenames on the command line or find the filenames in the patchfiles
145 194
146my @files = (); 195my @files = ();
196my @range = ();
197my @keyword_tvi = ();
147 198
148foreach my $file (@ARGV) { 199foreach my $file (@ARGV) {
149 next if ((-d $file)); 200 ##if $file is a directory and it lacks a trailing slash, add one
150 if (!(-f $file)) { 201 if ((-d $file)) {
202 $file =~ s@([^/])$@$1/@;
203 } elsif (!(-f $file)) {
151 die "$P: file '${file}' not found\n"; 204 die "$P: file '${file}' not found\n";
152 } 205 }
153 if ($from_filename) { 206 if ($from_filename) {
154 push(@files, $file); 207 push(@files, $file);
208 if (-f $file && $keywords) {
209 open(FILE, "<$file") or die "$P: Can't open ${file}\n";
210 while (<FILE>) {
211 my $patch_line = $_;
212 foreach my $line (keys %keyword_hash) {
213 if ($patch_line =~ m/^.*$keyword_hash{$line}/x) {
214 push(@keyword_tvi, $line);
215 }
216 }
217 }
218 close(FILE);
219 }
155 } else { 220 } else {
156 my $file_cnt = @files; 221 my $file_cnt = @files;
222 my $lastfile;
157 open(PATCH, "<$file") or die "$P: Can't open ${file}\n"; 223 open(PATCH, "<$file") or die "$P: Can't open ${file}\n";
158 while (<PATCH>) { 224 while (<PATCH>) {
225 my $patch_line = $_;
159 if (m/^\+\+\+\s+(\S+)/) { 226 if (m/^\+\+\+\s+(\S+)/) {
160 my $filename = $1; 227 my $filename = $1;
161 $filename =~ s@^[^/]*/@@; 228 $filename =~ s@^[^/]*/@@;
162 $filename =~ s@\n@@; 229 $filename =~ s@\n@@;
230 $lastfile = $filename;
163 push(@files, $filename); 231 push(@files, $filename);
232 } elsif (m/^\@\@ -(\d+),(\d+)/) {
233 if ($email_git_blame) {
234 push(@range, "$lastfile:$1:$2");
235 }
236 } elsif ($keywords) {
237 foreach my $line (keys %keyword_hash) {
238 if ($patch_line =~ m/^[+-].*$keyword_hash{$line}/x) {
239 push(@keyword_tvi, $line);
240 }
241 }
164 } 242 }
165 } 243 }
166 close(PATCH); 244 close(PATCH);
@@ -193,6 +271,7 @@ foreach my $file (@files) {
193 if ($type eq 'X') { 271 if ($type eq 'X') {
194 if (file_match_pattern($file, $value)) { 272 if (file_match_pattern($file, $value)) {
195 $exclude = 1; 273 $exclude = 1;
274 last;
196 } 275 }
197 } 276 }
198 } 277 }
@@ -200,35 +279,52 @@ foreach my $file (@files) {
200 279
201 if (!$exclude) { 280 if (!$exclude) {
202 my $tvi = 0; 281 my $tvi = 0;
282 my %hash;
203 foreach my $line (@typevalue) { 283 foreach my $line (@typevalue) {
204 if ($line =~ m/^(\C):\s*(.*)/) { 284 if ($line =~ m/^(\C):\s*(.*)/) {
205 my $type = $1; 285 my $type = $1;
206 my $value = $2; 286 my $value = $2;
207 if ($type eq 'F') { 287 if ($type eq 'F') {
208 if (file_match_pattern($file, $value)) { 288 if (file_match_pattern($file, $value)) {
209 add_categories($tvi); 289 my $value_pd = ($value =~ tr@/@@);
290 my $file_pd = ($file =~ tr@/@@);
291 $value_pd++ if (substr($value,-1,1) ne "/");
292 if ($pattern_depth == 0 ||
293 (($file_pd - $value_pd) < $pattern_depth)) {
294 $hash{$tvi} = $value_pd;
295 }
210 } 296 }
211 } 297 }
212 } 298 }
213 $tvi++; 299 $tvi++;
214 } 300 }
301 foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) {
302 add_categories($line);
303 }
215 } 304 }
216 305
217 if ($email && $email_git) { 306 if ($email && $email_git) {
218 recent_git_signoffs($file); 307 recent_git_signoffs($file);
219 } 308 }
220 309
310 if ($email && $email_git_blame) {
311 git_assign_blame($file);
312 }
313}
314
315if ($keywords) {
316 @keyword_tvi = sort_and_uniq(@keyword_tvi);
317 foreach my $line (@keyword_tvi) {
318 add_categories($line);
319 }
221} 320}
222 321
223if ($email) { 322if ($email) {
224 foreach my $chief (@penguin_chief) { 323 foreach my $chief (@penguin_chief) {
225 if ($chief =~ m/^(.*):(.*)/) { 324 if ($chief =~ m/^(.*):(.*)/) {
226 my $email_address; 325 my $email_address;
227 if ($email_usename) { 326
228 $email_address = format_email($1, $2); 327 $email_address = format_email($1, $2);
229 } else {
230 $email_address = $2;
231 }
232 if ($email_git_penguin_chiefs) { 328 if ($email_git_penguin_chiefs) {
233 push(@email_to, $email_address); 329 push(@email_to, $email_address);
234 } else { 330 } else {
@@ -250,22 +346,22 @@ if ($email || $email_list) {
250} 346}
251 347
252if ($scm) { 348if ($scm) {
253 @scm = sort_and_uniq(@scm); 349 @scm = uniq(@scm);
254 output(@scm); 350 output(@scm);
255} 351}
256 352
257if ($status) { 353if ($status) {
258 @status = sort_and_uniq(@status); 354 @status = uniq(@status);
259 output(@status); 355 output(@status);
260} 356}
261 357
262if ($subsystem) { 358if ($subsystem) {
263 @subsystem = sort_and_uniq(@subsystem); 359 @subsystem = uniq(@subsystem);
264 output(@subsystem); 360 output(@subsystem);
265} 361}
266 362
267if ($web) { 363if ($web) {
268 @web = sort_and_uniq(@web); 364 @web = uniq(@web);
269 output(@web); 365 output(@web);
270} 366}
271 367
@@ -292,7 +388,7 @@ sub file_match_pattern {
292sub usage { 388sub usage {
293 print <<EOT; 389 print <<EOT;
294usage: $P [options] patchfile 390usage: $P [options] patchfile
295 $P [options] -f file 391 $P [options] -f file|directory
296version: $V 392version: $V
297 393
298MAINTAINER field selection options: 394MAINTAINER field selection options:
@@ -301,11 +397,14 @@ MAINTAINER field selection options:
301 --git-chief-penguins => include ${penguin_chiefs} 397 --git-chief-penguins => include ${penguin_chiefs}
302 --git-min-signatures => number of signatures required (default: 1) 398 --git-min-signatures => number of signatures required (default: 1)
303 --git-max-maintainers => maximum maintainers to add (default: 5) 399 --git-max-maintainers => maximum maintainers to add (default: 5)
400 --git-min-percent => minimum percentage of commits required (default: 5)
304 --git-since => git history to use (default: 1-year-ago) 401 --git-since => git history to use (default: 1-year-ago)
402 --git-blame => use git blame to find modified commits for patch or file
305 --m => include maintainer(s) if any 403 --m => include maintainer(s) if any
306 --n => include name 'Full Name <addr\@domain.tld>' 404 --n => include name 'Full Name <addr\@domain.tld>'
307 --l => include list(s) if any 405 --l => include list(s) if any
308 --s => include subscriber only list(s) if any 406 --s => include subscriber only list(s) if any
407 --remove-duplicates => minimize duplicate email names/addresses
309 --scm => print SCM tree(s) if any 408 --scm => print SCM tree(s) if any
310 --status => print status if any 409 --status => print status if any
311 --subsystem => print subsystem name if any 410 --subsystem => print subsystem name if any
@@ -313,15 +412,29 @@ MAINTAINER field selection options:
313 412
314Output type options: 413Output type options:
315 --separator [, ] => separator for multiple entries on 1 line 414 --separator [, ] => separator for multiple entries on 1 line
415 using --separator also sets --nomultiline if --separator is not [, ]
316 --multiline => print 1 entry per line 416 --multiline => print 1 entry per line
317 417
318Default options:
319 [--email --git --m --n --l --multiline]
320
321Other options: 418Other options:
419 --pattern-depth => Number of pattern directory traversals (default: 0 (all))
420 --keywords => scan patch for keywords (default: 1 (on))
322 --version => show version 421 --version => show version
323 --help => show this help information 422 --help => show this help information
324 423
424Default options:
425 [--email --git --m --n --l --multiline --pattern-depth=0 --remove-duplicates]
426
427Notes:
428 Using "-f directory" may give unexpected results:
429 Used with "--git", git signators for _all_ files in and below
430 directory are examined as git recurses directories.
431 Any specified X: (exclude) pattern matches are _not_ ignored.
432 Used with "--nogit", directory is used as a pattern match,
433 no individual file within the directory or subdirectory
434 is matched.
435 Used with "--git-blame", does not iterate all files in directory
436 Using "--git-blame" is slow and may add old committers and authors
437 that are no longer active maintainers to the output.
325EOT 438EOT
326} 439}
327 440
@@ -352,30 +465,99 @@ sub top_of_kernel_tree {
352 return 0; 465 return 0;
353} 466}
354 467
355sub format_email { 468sub parse_email {
356 my ($name, $email) = @_; 469 my ($formatted_email) = @_;
470
471 my $name = "";
472 my $address = "";
473
474 if ($formatted_email =~ /^([^<]+)<(.+\@.*)>.*$/) {
475 $name = $1;
476 $address = $2;
477 } elsif ($formatted_email =~ /^\s*<(.+\@\S*)>.*$/) {
478 $address = $1;
479 } elsif ($formatted_email =~ /^(.+\@\S*).*$/) {
480 $address = $1;
481 }
357 482
358 $name =~ s/^\s+|\s+$//g; 483 $name =~ s/^\s+|\s+$//g;
359 $name =~ s/^\"|\"$//g; 484 $name =~ s/^\"|\"$//g;
360 $email =~ s/^\s+|\s+$//g; 485 $address =~ s/^\s+|\s+$//g;
361 486
362 my $formatted_email = ""; 487 if ($name =~ /[^a-z0-9 \.\-]/i) { ##has "must quote" chars
488 $name =~ s/(?<!\\)"/\\"/g; ##escape quotes
489 $name = "\"$name\"";
490 }
491
492 return ($name, $address);
493}
494
495sub format_email {
496 my ($name, $address) = @_;
497
498 my $formatted_email;
499
500 $name =~ s/^\s+|\s+$//g;
501 $name =~ s/^\"|\"$//g;
502 $address =~ s/^\s+|\s+$//g;
363 503
364 if ($name =~ /[^a-z0-9 \.\-]/i) { ##has "must quote" chars 504 if ($name =~ /[^a-z0-9 \.\-]/i) { ##has "must quote" chars
365 $name =~ s/(?<!\\)"/\\"/g; ##escape quotes 505 $name =~ s/(?<!\\)"/\\"/g; ##escape quotes
366 $formatted_email = "\"${name}\"\ \<${email}\>"; 506 $name = "\"$name\"";
507 }
508
509 if ($email_usename) {
510 if ("$name" eq "") {
511 $formatted_email = "$address";
512 } else {
513 $formatted_email = "$name <${address}>";
514 }
367 } else { 515 } else {
368 $formatted_email = "${name} \<${email}\>"; 516 $formatted_email = $address;
369 } 517 }
518
370 return $formatted_email; 519 return $formatted_email;
371} 520}
372 521
373sub add_categories { 522sub find_starting_index {
374 my ($index) = @_; 523 my ($index) = @_;
375 524
376 $index = $index - 1; 525 while ($index > 0) {
377 while ($index >= 0) {
378 my $tv = $typevalue[$index]; 526 my $tv = $typevalue[$index];
527 if (!($tv =~ m/^(\C):\s*(.*)/)) {
528 last;
529 }
530 $index--;
531 }
532
533 return $index;
534}
535
536sub find_ending_index {
537 my ($index) = @_;
538
539 while ($index < @typevalue) {
540 my $tv = $typevalue[$index];
541 if (!($tv =~ m/^(\C):\s*(.*)/)) {
542 last;
543 }
544 $index++;
545 }
546
547 return $index;
548}
549
550sub add_categories {
551 my ($index) = @_;
552
553 my $i;
554 my $start = find_starting_index($index);
555 my $end = find_ending_index($index);
556
557 push(@subsystem, $typevalue[$start]);
558
559 for ($i = $start + 1; $i < $end; $i++) {
560 my $tv = $typevalue[$i];
379 if ($tv =~ m/^(\C):\s*(.*)/) { 561 if ($tv =~ m/^(\C):\s*(.*)/) {
380 my $ptype = $1; 562 my $ptype = $1;
381 my $pvalue = $2; 563 my $pvalue = $2;
@@ -396,19 +578,19 @@ sub add_categories {
396 } 578 }
397 } 579 }
398 } elsif ($ptype eq "M") { 580 } elsif ($ptype eq "M") {
399 my $p_used = 0; 581 my ($name, $address) = parse_email($pvalue);
400 if ($index >= 0) { 582 if ($name eq "") {
401 my $tv = $typevalue[$index - 1]; 583 if ($i > 0) {
402 if ($tv =~ m/^(\C):\s*(.*)/) { 584 my $tv = $typevalue[$i - 1];
403 if ($1 eq "P") { 585 if ($tv =~ m/^(\C):\s*(.*)/) {
404 if ($email_usename) { 586 if ($1 eq "P") {
405 push_email_address(format_email($2, $pvalue)); 587 $name = $2;
406 $p_used = 1; 588 $pvalue = format_email($name, $address);
407 } 589 }
408 } 590 }
409 } 591 }
410 } 592 }
411 if (!$p_used) { 593 if ($email_maintainer) {
412 push_email_addresses($pvalue); 594 push_email_addresses($pvalue);
413 } 595 }
414 } elsif ($ptype eq "T") { 596 } elsif ($ptype eq "T") {
@@ -418,31 +600,41 @@ sub add_categories {
418 } elsif ($ptype eq "S") { 600 } elsif ($ptype eq "S") {
419 push(@status, $pvalue); 601 push(@status, $pvalue);
420 } 602 }
421
422 $index--;
423 } else {
424 push(@subsystem,$tv);
425 $index = -1;
426 } 603 }
427 } 604 }
428} 605}
429 606
607my %email_hash_name;
608my %email_hash_address;
609
610sub email_inuse {
611 my ($name, $address) = @_;
612
613 return 1 if (($name eq "") && ($address eq ""));
614 return 1 if (($name ne "") && exists($email_hash_name{$name}));
615 return 1 if (($address ne "") && exists($email_hash_address{$address}));
616
617 return 0;
618}
619
430sub push_email_address { 620sub push_email_address {
431 my ($email_address) = @_; 621 my ($line) = @_;
622
623 my ($name, $address) = parse_email($line);
432 624
433 my $email_name = ""; 625 if ($address eq "") {
434 if ($email_address =~ m/([^<]+)<(.*\@.*)>$/) { 626 return 0;
435 $email_name = $1;
436 $email_address = $2;
437 } 627 }
438 628
439 if ($email_maintainer) { 629 if (!$email_remove_duplicates) {
440 if ($email_usename && $email_name) { 630 push(@email_to, format_email($name, $address));
441 push(@email_to, format_email($email_name, $email_address)); 631 } elsif (!email_inuse($name, $address)) {
442 } else { 632 push(@email_to, format_email($name, $address));
443 push(@email_to, $email_address); 633 $email_hash_name{$name}++;
444 } 634 $email_hash_address{$address}++;
445 } 635 }
636
637 return 1;
446} 638}
447 639
448sub push_email_addresses { 640sub push_email_addresses {
@@ -458,7 +650,9 @@ sub push_email_addresses {
458 push_email_address($entry); 650 push_email_address($entry);
459 } 651 }
460 } else { 652 } else {
461 warn("Invalid MAINTAINERS address: '" . $address . "'\n"); 653 if (!push_email_address($address)) {
654 warn("Invalid MAINTAINERS address: '" . $address . "'\n");
655 }
462 } 656 }
463} 657}
464 658
@@ -474,6 +668,32 @@ sub which {
474 return ""; 668 return "";
475} 669}
476 670
671sub mailmap {
672 my @lines = @_;
673 my %hash;
674
675 foreach my $line (@lines) {
676 my ($name, $address) = parse_email($line);
677 if (!exists($hash{$name})) {
678 $hash{$name} = $address;
679 } elsif ($address ne $hash{$name}) {
680 $address = $hash{$name};
681 $line = format_email($name, $address);
682 }
683 if (exists($mailmap{$name})) {
684 my $obj = $mailmap{$name};
685 foreach my $map_address (@$obj) {
686 if (($map_address eq $address) &&
687 ($map_address ne $hash{$name})) {
688 $line = format_email($name, $hash{$name});
689 }
690 }
691 }
692 }
693
694 return @lines;
695}
696
477sub recent_git_signoffs { 697sub recent_git_signoffs {
478 my ($file) = @_; 698 my ($file) = @_;
479 699
@@ -482,6 +702,8 @@ sub recent_git_signoffs {
482 my $output = ""; 702 my $output = "";
483 my $count = 0; 703 my $count = 0;
484 my @lines = (); 704 my @lines = ();
705 my %hash;
706 my $total_sign_offs;
485 707
486 if (which("git") eq "") { 708 if (which("git") eq "") {
487 warn("$P: git not found. Add --nogit to options?\n"); 709 warn("$P: git not found. Add --nogit to options?\n");
@@ -494,44 +716,120 @@ sub recent_git_signoffs {
494 } 716 }
495 717
496 $cmd = "git log --since=${email_git_since} -- ${file}"; 718 $cmd = "git log --since=${email_git_since} -- ${file}";
497 $cmd .= " | grep -Ei \"^[-_ a-z]+by:.*\\\@.*\$\""; 719
720 $output = `${cmd}`;
721 $output =~ s/^\s*//gm;
722
723 @lines = split("\n", $output);
724
725 @lines = grep(/^[-_ a-z]+by:.*\@.*$/i, @lines);
498 if (!$email_git_penguin_chiefs) { 726 if (!$email_git_penguin_chiefs) {
499 $cmd .= " | grep -Ev \"${penguin_chiefs}\""; 727 @lines = grep(!/${penguin_chiefs}/i, @lines);
500 } 728 }
501 $cmd .= " | cut -f2- -d\":\""; 729 # cut -f2- -d":"
502 $cmd .= " | sort | uniq -c | sort -rn"; 730 s/.*:\s*(.+)\s*/$1/ for (@lines);
731
732 $total_sign_offs = @lines;
733
734 if ($email_remove_duplicates) {
735 @lines = mailmap(@lines);
736 }
737
738 @lines = sort(@lines);
739
740 # uniq -c
741 $hash{$_}++ for @lines;
742
743 # sort -rn
744 foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) {
745 my $sign_offs = $hash{$line};
746 $count++;
747 last if ($sign_offs < $email_git_min_signatures ||
748 $count > $email_git_max_maintainers ||
749 $sign_offs * 100 / $total_sign_offs < $email_git_min_percent);
750 push_email_address($line);
751 }
752}
753
754sub save_commits {
755 my ($cmd, @commits) = @_;
756 my $output;
757 my @lines = ();
503 758
504 $output = `${cmd}`; 759 $output = `${cmd}`;
505 $output =~ s/^\s*//gm;
506 760
507 @lines = split("\n", $output); 761 @lines = split("\n", $output);
508 foreach my $line (@lines) { 762 foreach my $line (@lines) {
509 if ($line =~ m/([0-9]+)\s+(.*)/) { 763 if ($line =~ m/^(\w+) /) {
510 my $sign_offs = $1; 764 push (@commits, $1);
511 $line = $2;
512 $count++;
513 if ($sign_offs < $email_git_min_signatures ||
514 $count > $email_git_max_maintainers) {
515 last;
516 }
517 } else {
518 die("$P: Unexpected git output: ${line}\n");
519 } 765 }
520 if ($line =~ m/(.+)<(.+)>/) { 766 }
521 my $git_name = $1; 767 return @commits;
522 my $git_addr = $2; 768}
523 if ($email_usename) { 769
524 push(@email_to, format_email($git_name, $git_addr)); 770sub git_assign_blame {
525 } else { 771 my ($file) = @_;
526 push(@email_to, $git_addr); 772
527 } 773 my @lines = ();
528 } elsif ($line =~ m/<(.+)>/) { 774 my @commits = ();
529 my $git_addr = $1; 775 my $cmd;
530 push(@email_to, $git_addr); 776 my $output;
531 } else { 777 my %hash;
532 push(@email_to, $line); 778 my $total_sign_offs;
779 my $count;
780
781 if (@range) {
782 foreach my $file_range_diff (@range) {
783 next if (!($file_range_diff =~ m/(.+):(.+):(.+)/));
784 my $diff_file = $1;
785 my $diff_start = $2;
786 my $diff_length = $3;
787 next if (!("$file" eq "$diff_file"));
788 $cmd = "git blame -l -L $diff_start,+$diff_length $file";
789 @commits = save_commits($cmd, @commits);
790 }
791 } else {
792 if (-f $file) {
793 $cmd = "git blame -l $file";
794 @commits = save_commits($cmd, @commits);
533 } 795 }
534 } 796 }
797
798 $total_sign_offs = 0;
799 @commits = uniq(@commits);
800 foreach my $commit (@commits) {
801 $cmd = "git log -1 ${commit}";
802
803 $output = `${cmd}`;
804 $output =~ s/^\s*//gm;
805 @lines = split("\n", $output);
806
807 @lines = grep(/^[-_ a-z]+by:.*\@.*$/i, @lines);
808 if (!$email_git_penguin_chiefs) {
809 @lines = grep(!/${penguin_chiefs}/i, @lines);
810 }
811
812 # cut -f2- -d":"
813 s/.*:\s*(.+)\s*/$1/ for (@lines);
814
815 $total_sign_offs += @lines;
816
817 if ($email_remove_duplicates) {
818 @lines = mailmap(@lines);
819 }
820
821 $hash{$_}++ for @lines;
822 }
823
824 $count = 0;
825 foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) {
826 my $sign_offs = $hash{$line};
827 $count++;
828 last if ($sign_offs < $email_git_min_signatures ||
829 $count > $email_git_max_maintainers ||
830 $sign_offs * 100 / $total_sign_offs < $email_git_min_percent);
831 push_email_address($line);
832 }
535} 833}
536 834
537sub uniq { 835sub uniq {
diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
index c6ae4052ab43..b89ca2c58fdb 100644
--- a/scripts/headers_install.pl
+++ b/scripts/headers_install.pl
@@ -20,7 +20,7 @@ use strict;
20 20
21my ($readdir, $installdir, $arch, @files) = @ARGV; 21my ($readdir, $installdir, $arch, @files) = @ARGV;
22 22
23my $unifdef = "scripts/unifdef -U__KERNEL__"; 23my $unifdef = "scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__";
24 24
25foreach my $file (@files) { 25foreach my $file (@files) {
26 local *INFILE; 26 local *INFILE;
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index 64343cc084b4..86c3896a1e01 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -585,7 +585,7 @@ static int prefix_underscores_count(const char *str)
585{ 585{
586 const char *tail = str; 586 const char *tail = str;
587 587
588 while (*tail != '_') 588 while (*tail == '_')
589 tail++; 589 tail++;
590 590
591 return tail - str; 591 return tail - str;
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 5ddf8becd7a2..6d69c7ccdcc7 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -2,7 +2,8 @@
2# Kernel configuration targets 2# Kernel configuration targets
3# These targets are used from top-level makefile 3# These targets are used from top-level makefile
4 4
5PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config 5PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config \
6 localmodconfig localyesconfig
6 7
7ifdef KBUILD_KCONFIG 8ifdef KBUILD_KCONFIG
8Kconfig := $(KBUILD_KCONFIG) 9Kconfig := $(KBUILD_KCONFIG)
@@ -28,6 +29,35 @@ oldconfig: $(obj)/conf
28silentoldconfig: $(obj)/conf 29silentoldconfig: $(obj)/conf
29 $< -s $(Kconfig) 30 $< -s $(Kconfig)
30 31
32localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
33 $(Q)perl $< $(Kconfig) > .tmp.config
34 $(Q)if [ -f .config ]; then \
35 cmp -s .tmp.config .config || \
36 (mv -f .config .config.old.1; \
37 mv -f .tmp.config .config; \
38 $(obj)/conf -s $(Kconfig); \
39 mv -f .config.old.1 .config.old) \
40 else \
41 mv -f .tmp.config .config; \
42 $(obj)/conf -s $(Kconfig); \
43 fi
44 $(Q)rm -f .tmp.config
45
46localyesconfig: $(obj)/streamline_config.pl $(obj)/conf
47 $(Q)perl $< $(Kconfig) > .tmp.config
48 $(Q)sed -i s/=m/=y/ .tmp.config
49 $(Q)if [ -f .config ]; then \
50 cmp -s .tmp.config .config || \
51 (mv -f .config .config.old.1; \
52 mv -f .tmp.config .config; \
53 $(obj)/conf -s $(Kconfig); \
54 mv -f .config.old.1 .config.old) \
55 else \
56 mv -f .tmp.config .config; \
57 $(obj)/conf -s $(Kconfig); \
58 fi
59 $(Q)rm -f .tmp.config
60
31# Create new linux.pot file 61# Create new linux.pot file
32# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files 62# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
33# The symlink is used to repair a deficiency in arch/um 63# The symlink is used to repair a deficiency in arch/um
@@ -83,6 +113,8 @@ help:
83 @echo ' xconfig - Update current config utilising a QT based front-end' 113 @echo ' xconfig - Update current config utilising a QT based front-end'
84 @echo ' gconfig - Update current config utilising a GTK based front-end' 114 @echo ' gconfig - Update current config utilising a GTK based front-end'
85 @echo ' oldconfig - Update current config utilising a provided .config as base' 115 @echo ' oldconfig - Update current config utilising a provided .config as base'
116 @echo ' localmodconfig - Update current config disabling modules not loaded'
117 @echo ' localyesconfig - Update current config converting local mods to core'
86 @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps' 118 @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
87 @echo ' randconfig - New config with random answer to all options' 119 @echo ' randconfig - New config with random answer to all options'
88 @echo ' defconfig - New config with default answer to all options' 120 @echo ' defconfig - New config with default answer to all options'
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 3baaaecd6b13..9960d1c303f8 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -38,14 +38,14 @@ static int conf_cnt;
38static char line[128]; 38static char line[128];
39static struct menu *rootEntry; 39static struct menu *rootEntry;
40 40
41static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n"); 41static void print_help(struct menu *menu)
42
43static const char *get_help(struct menu *menu)
44{ 42{
45 if (menu_has_help(menu)) 43 struct gstr help = str_new();
46 return _(menu_get_help(menu)); 44
47 else 45 menu_get_ext_help(menu, &help);
48 return nohelp_text; 46
47 printf("\n%s\n", str_get(&help));
48 str_free(&help);
49} 49}
50 50
51static void strip(char *str) 51static void strip(char *str)
@@ -121,7 +121,7 @@ static int conf_askvalue(struct symbol *sym, const char *def)
121 return 1; 121 return 1;
122} 122}
123 123
124int conf_string(struct menu *menu) 124static int conf_string(struct menu *menu)
125{ 125{
126 struct symbol *sym = menu->sym; 126 struct symbol *sym = menu->sym;
127 const char *def; 127 const char *def;
@@ -140,7 +140,7 @@ int conf_string(struct menu *menu)
140 case '?': 140 case '?':
141 /* print help */ 141 /* print help */
142 if (line[1] == '\n') { 142 if (line[1] == '\n') {
143 printf("\n%s\n", get_help(menu)); 143 print_help(menu);
144 def = NULL; 144 def = NULL;
145 break; 145 break;
146 } 146 }
@@ -220,7 +220,7 @@ static int conf_sym(struct menu *menu)
220 if (sym_set_tristate_value(sym, newval)) 220 if (sym_set_tristate_value(sym, newval))
221 return 0; 221 return 0;
222help: 222help:
223 printf("\n%s\n", get_help(menu)); 223 print_help(menu);
224 } 224 }
225} 225}
226 226
@@ -307,7 +307,7 @@ static int conf_choice(struct menu *menu)
307 fgets(line, 128, stdin); 307 fgets(line, 128, stdin);
308 strip(line); 308 strip(line);
309 if (line[0] == '?') { 309 if (line[0] == '?') {
310 printf("\n%s\n", get_help(menu)); 310 print_help(menu);
311 continue; 311 continue;
312 } 312 }
313 if (!line[0]) 313 if (!line[0])
@@ -331,7 +331,7 @@ static int conf_choice(struct menu *menu)
331 if (!child) 331 if (!child)
332 continue; 332 continue;
333 if (line[strlen(line) - 1] == '?') { 333 if (line[strlen(line) - 1] == '?') {
334 printf("\n%s\n", get_help(child)); 334 print_help(child);
335 continue; 335 continue;
336 } 336 }
337 sym_set_choice_value(sym, child->sym); 337 sym_set_choice_value(sym, child->sym);
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index a04da3459f0f..b55e72ff2fc6 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -560,7 +560,7 @@ int conf_write(const char *name)
560 return 0; 560 return 0;
561} 561}
562 562
563int conf_split_config(void) 563static int conf_split_config(void)
564{ 564{
565 const char *name; 565 const char *name;
566 char path[128]; 566 char path[128];
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c
index 579ece4fa584..edd3f39a080a 100644
--- a/scripts/kconfig/expr.c
+++ b/scripts/kconfig/expr.c
@@ -348,7 +348,7 @@ struct expr *expr_trans_bool(struct expr *e)
348/* 348/*
349 * e1 || e2 -> ? 349 * e1 || e2 -> ?
350 */ 350 */
351struct expr *expr_join_or(struct expr *e1, struct expr *e2) 351static struct expr *expr_join_or(struct expr *e1, struct expr *e2)
352{ 352{
353 struct expr *tmp; 353 struct expr *tmp;
354 struct symbol *sym1, *sym2; 354 struct symbol *sym1, *sym2;
@@ -412,7 +412,7 @@ struct expr *expr_join_or(struct expr *e1, struct expr *e2)
412 return NULL; 412 return NULL;
413} 413}
414 414
415struct expr *expr_join_and(struct expr *e1, struct expr *e2) 415static struct expr *expr_join_and(struct expr *e1, struct expr *e2)
416{ 416{
417 struct expr *tmp; 417 struct expr *tmp;
418 struct symbol *sym1, *sym2; 418 struct symbol *sym1, *sym2;
@@ -1098,6 +1098,8 @@ void expr_fprint(struct expr *e, FILE *out)
1098static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str) 1098static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str)
1099{ 1099{
1100 str_append((struct gstr*)data, str); 1100 str_append((struct gstr*)data, str);
1101 if (sym)
1102 str_printf((struct gstr*)data, " [=%s]", sym_get_string_value(sym));
1101} 1103}
1102 1104
1103void expr_gstr_print(struct expr *e, struct gstr *gs) 1105void expr_gstr_print(struct expr *e, struct gstr *gs)
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
index 199b22bb49e2..65464366fe38 100644
--- a/scripts/kconfig/gconf.c
+++ b/scripts/kconfig/gconf.c
@@ -456,19 +456,9 @@ static void text_insert_help(struct menu *menu)
456 GtkTextBuffer *buffer; 456 GtkTextBuffer *buffer;
457 GtkTextIter start, end; 457 GtkTextIter start, end;
458 const char *prompt = _(menu_get_prompt(menu)); 458 const char *prompt = _(menu_get_prompt(menu));
459 gchar *name; 459 struct gstr help = str_new();
460 const char *help;
461 460
462 help = menu_get_help(menu); 461 menu_get_ext_help(menu, &help);
463
464 /* Gettextize if the help text not empty */
465 if ((help != 0) && (help[0] != 0))
466 help = _(help);
467
468 if (menu->sym && menu->sym->name)
469 name = g_strdup_printf(menu->sym->name);
470 else
471 name = g_strdup("");
472 462
473 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w)); 463 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
474 gtk_text_buffer_get_bounds(buffer, &start, &end); 464 gtk_text_buffer_get_bounds(buffer, &start, &end);
@@ -478,14 +468,11 @@ static void text_insert_help(struct menu *menu)
478 gtk_text_buffer_get_end_iter(buffer, &end); 468 gtk_text_buffer_get_end_iter(buffer, &end);
479 gtk_text_buffer_insert_with_tags(buffer, &end, prompt, -1, tag1, 469 gtk_text_buffer_insert_with_tags(buffer, &end, prompt, -1, tag1,
480 NULL); 470 NULL);
481 gtk_text_buffer_insert_at_cursor(buffer, " ", 1);
482 gtk_text_buffer_get_end_iter(buffer, &end);
483 gtk_text_buffer_insert_with_tags(buffer, &end, name, -1, tag1,
484 NULL);
485 gtk_text_buffer_insert_at_cursor(buffer, "\n\n", 2); 471 gtk_text_buffer_insert_at_cursor(buffer, "\n\n", 2);
486 gtk_text_buffer_get_end_iter(buffer, &end); 472 gtk_text_buffer_get_end_iter(buffer, &end);
487 gtk_text_buffer_insert_with_tags(buffer, &end, help, -1, tag2, 473 gtk_text_buffer_insert_with_tags(buffer, &end, str_get(&help), -1, tag2,
488 NULL); 474 NULL);
475 str_free(&help);
489} 476}
490 477
491 478
diff --git a/scripts/kconfig/gconf.glade b/scripts/kconfig/gconf.glade
index 803233fdd6dd..b1c86c19292c 100644
--- a/scripts/kconfig/gconf.glade
+++ b/scripts/kconfig/gconf.glade
@@ -547,7 +547,7 @@
547 <property name="headers_visible">True</property> 547 <property name="headers_visible">True</property>
548 <property name="rules_hint">False</property> 548 <property name="rules_hint">False</property>
549 <property name="reorderable">False</property> 549 <property name="reorderable">False</property>
550 <property name="enable_search">True</property> 550 <property name="enable_search">False</property>
551 <signal name="cursor_changed" handler="on_treeview2_cursor_changed" last_modification_time="Sun, 12 Jan 2003 15:58:22 GMT"/> 551 <signal name="cursor_changed" handler="on_treeview2_cursor_changed" last_modification_time="Sun, 12 Jan 2003 15:58:22 GMT"/>
552 <signal name="button_press_event" handler="on_treeview1_button_press_event" last_modification_time="Sun, 12 Jan 2003 16:03:52 GMT"/> 552 <signal name="button_press_event" handler="on_treeview1_button_press_event" last_modification_time="Sun, 12 Jan 2003 16:03:52 GMT"/>
553 <signal name="key_press_event" handler="on_treeview2_key_press_event" last_modification_time="Sun, 12 Jan 2003 16:11:44 GMT"/> 553 <signal name="key_press_event" handler="on_treeview2_key_press_event" last_modification_time="Sun, 12 Jan 2003 16:11:44 GMT"/>
@@ -582,7 +582,7 @@
582 <property name="headers_visible">True</property> 582 <property name="headers_visible">True</property>
583 <property name="rules_hint">False</property> 583 <property name="rules_hint">False</property>
584 <property name="reorderable">False</property> 584 <property name="reorderable">False</property>
585 <property name="enable_search">True</property> 585 <property name="enable_search">False</property>
586 <signal name="cursor_changed" handler="on_treeview2_cursor_changed" last_modification_time="Sun, 12 Jan 2003 15:57:55 GMT"/> 586 <signal name="cursor_changed" handler="on_treeview2_cursor_changed" last_modification_time="Sun, 12 Jan 2003 15:57:55 GMT"/>
587 <signal name="button_press_event" handler="on_treeview2_button_press_event" last_modification_time="Sun, 12 Jan 2003 15:57:58 GMT"/> 587 <signal name="button_press_event" handler="on_treeview2_button_press_event" last_modification_time="Sun, 12 Jan 2003 15:57:58 GMT"/>
588 <signal name="key_press_event" handler="on_treeview2_key_press_event" last_modification_time="Sun, 12 Jan 2003 15:58:01 GMT"/> 588 <signal name="key_press_event" handler="on_treeview2_key_press_event" last_modification_time="Sun, 12 Jan 2003 15:58:01 GMT"/>
diff --git a/scripts/kconfig/kxgettext.c b/scripts/kconfig/kxgettext.c
index 8d9ce22b0fc5..dcc3fcc0cc9a 100644
--- a/scripts/kconfig/kxgettext.c
+++ b/scripts/kconfig/kxgettext.c
@@ -166,7 +166,7 @@ static int message__add(const char *msg, char *option, char *file, int lineno)
166 return rc; 166 return rc;
167} 167}
168 168
169void menu_build_message_list(struct menu *menu) 169static void menu_build_message_list(struct menu *menu)
170{ 170{
171 struct menu *child; 171 struct menu *child;
172 172
@@ -211,7 +211,7 @@ static void message__print_gettext_msgid_msgstr(struct message *self)
211 "msgstr \"\"\n", self->msg); 211 "msgstr \"\"\n", self->msg);
212} 212}
213 213
214void menu__xgettext(void) 214static void menu__xgettext(void)
215{ 215{
216 struct message *m = message__list; 216 struct message *m = message__list;
217 217
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index 8e69461313d1..ffeb532b2cff 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -17,6 +17,8 @@ P(menu_get_root_menu,struct menu *,(struct menu *menu));
17P(menu_get_parent_menu,struct menu *,(struct menu *menu)); 17P(menu_get_parent_menu,struct menu *,(struct menu *menu));
18P(menu_has_help,bool,(struct menu *menu)); 18P(menu_has_help,bool,(struct menu *menu));
19P(menu_get_help,const char *,(struct menu *menu)); 19P(menu_get_help,const char *,(struct menu *menu));
20P(get_symbol_str,void,(struct gstr *r, struct symbol *sym));
21P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help));
20 22
21/* symbol.c */ 23/* symbol.c */
22P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]); 24P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]);
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c
index 86d95cca46a7..f2375ad7ebc9 100644
--- a/scripts/kconfig/lxdialog/util.c
+++ b/scripts/kconfig/lxdialog/util.c
@@ -19,6 +19,8 @@
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 20 */
21 21
22#include <stdarg.h>
23
22#include "dialog.h" 24#include "dialog.h"
23 25
24struct dialog_info dlg; 26struct dialog_info dlg;
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 3bcacb4bfd3a..d82953573588 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -199,8 +199,6 @@ inputbox_instructions_string[] = N_(
199setmod_text[] = N_( 199setmod_text[] = N_(
200 "This feature depends on another which has been configured as a module.\n" 200 "This feature depends on another which has been configured as a module.\n"
201 "As a result, this feature will be built as a module."), 201 "As a result, this feature will be built as a module."),
202nohelp_text[] = N_(
203 "There is no help available for this kernel option.\n"),
204load_config_text[] = N_( 202load_config_text[] = N_(
205 "Enter the name of the configuration file you wish to load. " 203 "Enter the name of the configuration file you wish to load. "
206 "Accept the name shown to restore the configuration you " 204 "Accept the name shown to restore the configuration you "
@@ -284,66 +282,6 @@ static void show_textbox(const char *title, const char *text, int r, int c);
284static void show_helptext(const char *title, const char *text); 282static void show_helptext(const char *title, const char *text);
285static void show_help(struct menu *menu); 283static void show_help(struct menu *menu);
286 284
287static void get_prompt_str(struct gstr *r, struct property *prop)
288{
289 int i, j;
290 struct menu *submenu[8], *menu;
291
292 str_printf(r, _("Prompt: %s\n"), _(prop->text));
293 str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name,
294 prop->menu->lineno);
295 if (!expr_is_yes(prop->visible.expr)) {
296 str_append(r, _(" Depends on: "));
297 expr_gstr_print(prop->visible.expr, r);
298 str_append(r, "\n");
299 }
300 menu = prop->menu->parent;
301 for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent)
302 submenu[i++] = menu;
303 if (i > 0) {
304 str_printf(r, _(" Location:\n"));
305 for (j = 4; --i >= 0; j += 2) {
306 menu = submenu[i];
307 str_printf(r, "%*c-> %s", j, ' ', _(menu_get_prompt(menu)));
308 if (menu->sym) {
309 str_printf(r, " (%s [=%s])", menu->sym->name ?
310 menu->sym->name : _("<choice>"),
311 sym_get_string_value(menu->sym));
312 }
313 str_append(r, "\n");
314 }
315 }
316}
317
318static void get_symbol_str(struct gstr *r, struct symbol *sym)
319{
320 bool hit;
321 struct property *prop;
322
323 if (sym && sym->name)
324 str_printf(r, "Symbol: %s [=%s]\n", sym->name,
325 sym_get_string_value(sym));
326 for_all_prompts(sym, prop)
327 get_prompt_str(r, prop);
328 hit = false;
329 for_all_properties(sym, prop, P_SELECT) {
330 if (!hit) {
331 str_append(r, " Selects: ");
332 hit = true;
333 } else
334 str_printf(r, " && ");
335 expr_gstr_print(prop->expr, r);
336 }
337 if (hit)
338 str_append(r, "\n");
339 if (sym->rev_dep.expr) {
340 str_append(r, _(" Selected by: "));
341 expr_gstr_print(sym->rev_dep.expr, r);
342 str_append(r, "\n");
343 }
344 str_append(r, "\n\n");
345}
346
347static struct gstr get_relations_str(struct symbol **sym_arr) 285static struct gstr get_relations_str(struct symbol **sym_arr)
348{ 286{
349 struct symbol *sym; 287 struct symbol *sym;
@@ -699,19 +637,9 @@ static void show_helptext(const char *title, const char *text)
699static void show_help(struct menu *menu) 637static void show_help(struct menu *menu)
700{ 638{
701 struct gstr help = str_new(); 639 struct gstr help = str_new();
702 struct symbol *sym = menu->sym; 640
703 641 menu_get_ext_help(menu, &help);
704 if (menu_has_help(menu)) 642
705 {
706 if (sym->name) {
707 str_printf(&help, "CONFIG_%s:\n\n", sym->name);
708 str_append(&help, _(menu_get_help(menu)));
709 str_append(&help, "\n");
710 }
711 } else {
712 str_append(&help, nohelp_text);
713 }
714 get_symbol_str(&help, sym);
715 show_helptext(_(menu_get_prompt(menu)), str_get(&help)); 643 show_helptext(_(menu_get_prompt(menu)), str_get(&help));
716 str_free(&help); 644 str_free(&help);
717} 645}
@@ -888,6 +816,8 @@ int main(int ac, char **av)
888 single_menu_mode = 1; 816 single_menu_mode = 1;
889 } 817 }
890 818
819 initscr();
820
891 getyx(stdscr, saved_y, saved_x); 821 getyx(stdscr, saved_y, saved_x);
892 if (init_dialog(NULL)) { 822 if (init_dialog(NULL)) {
893 fprintf(stderr, N_("Your display is too small to run Menuconfig!\n")); 823 fprintf(stderr, N_("Your display is too small to run Menuconfig!\n"));
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 07ff8d105c9d..059a2465c574 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -9,6 +9,9 @@
9#define LKC_DIRECT_LINK 9#define LKC_DIRECT_LINK
10#include "lkc.h" 10#include "lkc.h"
11 11
12static const char nohelp_text[] = N_(
13 "There is no help available for this kernel option.\n");
14
12struct menu rootmenu; 15struct menu rootmenu;
13static struct menu **last_entry_ptr; 16static struct menu **last_entry_ptr;
14 17
@@ -74,7 +77,7 @@ void menu_end_menu(void)
74 current_menu = current_menu->parent; 77 current_menu = current_menu->parent;
75} 78}
76 79
77struct expr *menu_check_dep(struct expr *e) 80static struct expr *menu_check_dep(struct expr *e)
78{ 81{
79 if (!e) 82 if (!e)
80 return e; 83 return e;
@@ -184,7 +187,7 @@ static int menu_range_valid_sym(struct symbol *sym, struct symbol *sym2)
184 (sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name)); 187 (sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name));
185} 188}
186 189
187void sym_check_prop(struct symbol *sym) 190static void sym_check_prop(struct symbol *sym)
188{ 191{
189 struct property *prop; 192 struct property *prop;
190 struct symbol *sym2; 193 struct symbol *sym2;
@@ -451,3 +454,80 @@ const char *menu_get_help(struct menu *menu)
451 else 454 else
452 return ""; 455 return "";
453} 456}
457
458static void get_prompt_str(struct gstr *r, struct property *prop)
459{
460 int i, j;
461 struct menu *submenu[8], *menu;
462
463 str_printf(r, _("Prompt: %s\n"), _(prop->text));
464 str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name,
465 prop->menu->lineno);
466 if (!expr_is_yes(prop->visible.expr)) {
467 str_append(r, _(" Depends on: "));
468 expr_gstr_print(prop->visible.expr, r);
469 str_append(r, "\n");
470 }
471 menu = prop->menu->parent;
472 for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent)
473 submenu[i++] = menu;
474 if (i > 0) {
475 str_printf(r, _(" Location:\n"));
476 for (j = 4; --i >= 0; j += 2) {
477 menu = submenu[i];
478 str_printf(r, "%*c-> %s", j, ' ', _(menu_get_prompt(menu)));
479 if (menu->sym) {
480 str_printf(r, " (%s [=%s])", menu->sym->name ?
481 menu->sym->name : _("<choice>"),
482 sym_get_string_value(menu->sym));
483 }
484 str_append(r, "\n");
485 }
486 }
487}
488
489void get_symbol_str(struct gstr *r, struct symbol *sym)
490{
491 bool hit;
492 struct property *prop;
493
494 if (sym && sym->name)
495 str_printf(r, "Symbol: %s [=%s]\n", sym->name,
496 sym_get_string_value(sym));
497 for_all_prompts(sym, prop)
498 get_prompt_str(r, prop);
499 hit = false;
500 for_all_properties(sym, prop, P_SELECT) {
501 if (!hit) {
502 str_append(r, " Selects: ");
503 hit = true;
504 } else
505 str_printf(r, " && ");
506 expr_gstr_print(prop->expr, r);
507 }
508 if (hit)
509 str_append(r, "\n");
510 if (sym->rev_dep.expr) {
511 str_append(r, _(" Selected by: "));
512 expr_gstr_print(sym->rev_dep.expr, r);
513 str_append(r, "\n");
514 }
515 str_append(r, "\n\n");
516}
517
518void menu_get_ext_help(struct menu *menu, struct gstr *help)
519{
520 struct symbol *sym = menu->sym;
521
522 if (menu_has_help(menu)) {
523 if (sym->name) {
524 str_printf(help, "CONFIG_%s:\n\n", sym->name);
525 str_append(help, _(menu_get_help(menu)));
526 str_append(help, "\n");
527 }
528 } else {
529 str_append(help, nohelp_text);
530 }
531 if (sym)
532 get_symbol_str(help, sym);
533}
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index ce7d508c7520..00c51507cfcc 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -1042,12 +1042,10 @@ void ConfigInfoView::menuInfo(void)
1042 if (showDebug()) 1042 if (showDebug())
1043 debug = debug_info(sym); 1043 debug = debug_info(sym);
1044 1044
1045 help = menu_get_help(menu); 1045 struct gstr help_gstr = str_new();
1046 /* Gettextize if the help text not empty */ 1046 menu_get_ext_help(menu, &help_gstr);
1047 if (help.isEmpty()) 1047 help = print_filter(str_get(&help_gstr));
1048 help = print_filter(menu_get_help(menu)); 1048 str_free(&help_gstr);
1049 else
1050 help = print_filter(_(menu_get_help(menu)));
1051 } else if (menu->prompt) { 1049 } else if (menu->prompt) {
1052 head += "<big><b>"; 1050 head += "<big><b>";
1053 head += print_filter(_(menu->prompt->text)); 1051 head += print_filter(_(menu->prompt->text));
diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
new file mode 100644
index 000000000000..95984db8e1e0
--- /dev/null
+++ b/scripts/kconfig/streamline_config.pl
@@ -0,0 +1,366 @@
1#!/usr/bin/perl -w
2#
3# Copywrite 2005-2009 - Steven Rostedt
4# Licensed under the terms of the GNU GPL License version 2
5#
6# It's simple enough to figure out how this works.
7# If not, then you can ask me at stripconfig@goodmis.org
8#
9# What it does?
10#
11# If you have installed a Linux kernel from a distribution
12# that turns on way too many modules than you need, and
13# you only want the modules you use, then this program
14# is perfect for you.
15#
16# It gives you the ability to turn off all the modules that are
17# not loaded on your system.
18#
19# Howto:
20#
21# 1. Boot up the kernel that you want to stream line the config on.
22# 2. Change directory to the directory holding the source of the
23# kernel that you just booted.
24# 3. Copy the configuraton file to this directory as .config
25# 4. Have all your devices that you need modules for connected and
26# operational (make sure that their corresponding modules are loaded)
27# 5. Run this script redirecting the output to some other file
28# like config_strip.
29# 6. Back up your old config (if you want too).
30# 7. copy the config_strip file to .config
31# 8. Run "make oldconfig"
32#
33# Now your kernel is ready to be built with only the modules that
34# are loaded.
35#
36# Here's what I did with my Debian distribution.
37#
38# cd /usr/src/linux-2.6.10
39# cp /boot/config-2.6.10-1-686-smp .config
40# ~/bin/streamline_config > config_strip
41# mv .config config_sav
42# mv config_strip .config
43# make oldconfig
44#
45my $config = ".config";
46my $linuxpath = ".";
47
48my $uname = `uname -r`;
49chomp $uname;
50
51my @searchconfigs = (
52 {
53 "file" => ".config",
54 "exec" => "cat",
55 },
56 {
57 "file" => "/proc/config.gz",
58 "exec" => "zcat",
59 },
60 {
61 "file" => "/boot/config-$uname",
62 "exec" => "cat",
63 },
64 {
65 "file" => "/boot/vmlinuz-$uname",
66 "exec" => "scripts/extract-ikconfig",
67 "test" => "scripts/extract-ikconfig",
68 },
69 {
70 "file" => "vmlinux",
71 "exec" => "scripts/extract-ikconfig",
72 "test" => "scripts/extract-ikconfig",
73 },
74 {
75 "file" => "/lib/modules/$uname/kernel/kernel/configs.ko",
76 "exec" => "scripts/extract-ikconfig",
77 "test" => "scripts/extract-ikconfig",
78 },
79 {
80 "file" => "kernel/configs.ko",
81 "exec" => "scripts/extract-ikconfig",
82 "test" => "scripts/extract-ikconfig",
83 },
84 {
85 "file" => "kernel/configs.o",
86 "exec" => "scripts/extract-ikconfig",
87 "test" => "scripts/extract-ikconfig",
88 },
89);
90
91sub find_config {
92 foreach my $conf (@searchconfigs) {
93 my $file = $conf->{"file"};
94
95 next if ( ! -f "$file");
96
97 if (defined($conf->{"test"})) {
98 `$conf->{"test"} $conf->{"file"} 2>/dev/null`;
99 next if ($?);
100 }
101
102 my $exec = $conf->{"exec"};
103
104 print STDERR "using config: '$file'\n";
105
106 open(CIN, "$exec $file |") || die "Failed to run $exec $file";
107 return;
108 }
109 die "No config file found";
110}
111
112find_config;
113
114my @makefiles = `find $linuxpath -name Makefile`;
115my %depends;
116my %selects;
117my %prompts;
118my %objects;
119my $var;
120my $cont = 0;
121
122# Get the top level Kconfig file (passed in)
123my $kconfig = $ARGV[0];
124
125# prevent recursion
126my %read_kconfigs;
127
128sub read_kconfig {
129 my ($kconfig) = @_;
130
131 my $state = "NONE";
132 my $config;
133 my @kconfigs;
134
135 open(KIN, $kconfig) || die "Can't open $kconfig";
136 while (<KIN>) {
137 chomp;
138
139 # collect any Kconfig sources
140 if (/^source\s*"(.*)"/) {
141 $kconfigs[$#kconfigs+1] = $1;
142 }
143
144 # configs found
145 if (/^\s*config\s+(\S+)\s*$/) {
146 $state = "NEW";
147 $config = $1;
148
149 # collect the depends for the config
150 } elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) {
151 $state = "DEP";
152 $depends{$config} = $1;
153 } elsif ($state eq "DEP" && /^\s*depends\s+on\s+(.*)$/) {
154 $depends{$config} .= " " . $1;
155
156 # Get the configs that select this config
157 } elsif ($state ne "NONE" && /^\s*select\s+(\S+)/) {
158 if (defined($selects{$1})) {
159 $selects{$1} .= " " . $config;
160 } else {
161 $selects{$1} = $config;
162 }
163
164 # configs without prompts must be selected
165 } elsif ($state ne "NONE" && /^\s*tristate\s\S/) {
166 # note if the config has a prompt
167 $prompt{$config} = 1;
168
169 # stop on "help"
170 } elsif (/^\s*help\s*$/) {
171 $state = "NONE";
172 }
173 }
174 close(KIN);
175
176 # read in any configs that were found.
177 foreach $kconfig (@kconfigs) {
178 if (!defined($read_kconfigs{$kconfig})) {
179 $read_kconfigs{$kconfig} = 1;
180 read_kconfig($kconfig);
181 }
182 }
183}
184
185if ($kconfig) {
186 read_kconfig($kconfig);
187}
188
189# Read all Makefiles to map the configs to the objects
190foreach my $makefile (@makefiles) {
191 chomp $makefile;
192
193 open(MIN,$makefile) || die "Can't open $makefile";
194 while (<MIN>) {
195 my $objs;
196
197 # is this a line after a line with a backslash?
198 if ($cont && /(\S.*)$/) {
199 $objs = $1;
200 }
201 $cont = 0;
202
203 # collect objects after obj-$(CONFIG_FOO_BAR)
204 if (/obj-\$\((CONFIG_[^\)]*)\)\s*[+:]?=\s*(.*)/) {
205 $var = $1;
206 $objs = $2;
207 }
208 if (defined($objs)) {
209 # test if the line ends with a backslash
210 if ($objs =~ m,(.*)\\$,) {
211 $objs = $1;
212 $cont = 1;
213 }
214
215 foreach my $obj (split /\s+/,$objs) {
216 $obj =~ s/-/_/g;
217 if ($obj =~ /(.*)\.o$/) {
218 # Objects may bes enabled by more than one config.
219 # Store configs in an array.
220 my @arr;
221
222 if (defined($objects{$1})) {
223 @arr = @{$objects{$1}};
224 }
225
226 $arr[$#arr+1] = $var;
227
228 # The objects have a hash mapping to a reference
229 # of an array of configs.
230 $objects{$1} = \@arr;
231 }
232 }
233 }
234 }
235 close(MIN);
236}
237
238my %modules;
239
240# see what modules are loaded on this system
241open(LIN,"/sbin/lsmod|") || die "Cant lsmod";
242while (<LIN>) {
243 next if (/^Module/); # Skip the first line.
244 if (/^(\S+)/) {
245 $modules{$1} = 1;
246 }
247}
248close (LIN);
249
250# add to the configs hash all configs that are needed to enable
251# a loaded module.
252my %configs;
253foreach my $module (keys(%modules)) {
254 if (defined($objects{$module})) {
255 @arr = @{$objects{$module}};
256 foreach my $conf (@arr) {
257 $configs{$conf} = $module;
258 }
259 } else {
260 # Most likely, someone has a custom (binary?) module loaded.
261 print STDERR "$module config not found!!\n";
262 }
263}
264
265my $valid = "A-Za-z_0-9";
266my $repeat = 1;
267
268#
269# Note, we do not care about operands (like: &&, ||, !) we want to add any
270# config that is in the depend list of another config. This script does
271# not enable configs that are not already enabled. If we come across a
272# config A that depends on !B, we can still add B to the list of depends
273# to keep on. If A was on in the original config, B would not have been
274# and B would not be turned on by this script.
275#
276sub parse_config_dep_select
277{
278 my ($p) = @_;
279
280 while ($p =~ /[$valid]/) {
281
282 if ($p =~ /^[^$valid]*([$valid]+)/) {
283 my $conf = "CONFIG_" . $1;
284
285 $p =~ s/^[^$valid]*[$valid]+//;
286
287 if (!defined($configs{$conf})) {
288 # We must make sure that this config has its
289 # dependencies met.
290 $repeat = 1; # do again
291 $configs{$conf} = 1;
292 }
293 } else {
294 die "this should never happen";
295 }
296 }
297}
298
299while ($repeat) {
300 $repeat = 0;
301
302 foreach my $config (keys %configs) {
303 $config =~ s/^CONFIG_//;
304
305 if (defined($depends{$config})) {
306 # This config has dependencies. Make sure they are also included
307 parse_config_dep_select $depends{$config};
308 }
309
310 if (defined($prompt{$config}) || !defined($selects{$config})) {
311 next;
312 }
313
314 # config has no prompt and must be selected.
315 parse_config_dep_select $selects{$config};
316 }
317}
318
319my %setconfigs;
320
321# Finally, read the .config file and turn off any module enabled that
322# we could not find a reason to keep enabled.
323while(<CIN>) {
324
325 if (/CONFIG_IKCONFIG/) {
326 if (/# CONFIG_IKCONFIG is not set/) {
327 # enable IKCONFIG at least as a module
328 print "CONFIG_IKCONFIG=m\n";
329 # don't ask about PROC
330 print "# CONFIG_IKCONFIG_PROC is not set\n";
331 } else {
332 print;
333 }
334 next;
335 }
336
337 if (/^(CONFIG.*)=(m|y)/) {
338 if (defined($configs{$1})) {
339 $setconfigs{$1} = $2;
340 } elsif ($2 eq "m") {
341 print "# $1 is not set\n";
342 next;
343 }
344 }
345 print;
346}
347close(CIN);
348
349# Integrity check, make sure all modules that we want enabled do
350# indeed have their configs set.
351loop:
352foreach my $module (keys(%modules)) {
353 if (defined($objects{$module})) {
354 my @arr = @{$objects{$module}};
355 foreach my $conf (@arr) {
356 if (defined($setconfigs{$conf})) {
357 next loop;
358 }
359 }
360 print STDERR "module $module did not have configs";
361 foreach my $conf (@arr) {
362 print STDERR " " , $conf;
363 }
364 print STDERR "\n";
365 }
366}
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 18f3e5c33634..6c8fbbb66ebc 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -36,7 +36,7 @@ tristate modules_val;
36 36
37struct expr *sym_env_list; 37struct expr *sym_env_list;
38 38
39void sym_add_default(struct symbol *sym, const char *def) 39static void sym_add_default(struct symbol *sym, const char *def)
40{ 40{
41 struct property *prop = prop_alloc(P_DEFAULT, sym); 41 struct property *prop = prop_alloc(P_DEFAULT, sym);
42 42
@@ -125,7 +125,7 @@ struct property *sym_get_default_prop(struct symbol *sym)
125 return NULL; 125 return NULL;
126} 126}
127 127
128struct property *sym_get_range_prop(struct symbol *sym) 128static struct property *sym_get_range_prop(struct symbol *sym)
129{ 129{
130 struct property *prop; 130 struct property *prop;
131 131
@@ -943,7 +943,7 @@ const char *prop_get_type_name(enum prop_type type)
943 return "unknown"; 943 return "unknown";
944} 944}
945 945
946void prop_add_env(const char *env) 946static void prop_add_env(const char *env)
947{ 947{
948 struct symbol *sym, *sym2; 948 struct symbol *sym, *sym2;
949 struct property *prop; 949 struct property *prop;
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index ed591e9b7d1d..ea9f8a58678f 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1426,6 +1426,8 @@ sub dump_struct($$) {
1426 # strip comments: 1426 # strip comments:
1427 $members =~ s/\/\*.*?\*\///gos; 1427 $members =~ s/\/\*.*?\*\///gos;
1428 $nested =~ s/\/\*.*?\*\///gos; 1428 $nested =~ s/\/\*.*?\*\///gos;
1429 # strip kmemcheck_bitfield_{begin,end}.*;
1430 $members =~ s/kmemcheck_bitfield_.*?;//gos;
1429 1431
1430 create_parameterlist($members, ';', $file); 1432 create_parameterlist($members, ';', $file);
1431 check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested); 1433 check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested);
@@ -1468,8 +1470,6 @@ sub dump_enum($$) {
1468 } 1470 }
1469 1471
1470 } 1472 }
1471 # strip kmemcheck_bitfield_{begin,end}.*;
1472 $members =~ s/kmemcheck_bitfield_.*?;//gos;
1473 1473
1474 output_declaration($declaration_name, 1474 output_declaration($declaration_name,
1475 'enum', 1475 'enum',
@@ -1995,6 +1995,7 @@ sub process_file($) {
1995 my $identifier; 1995 my $identifier;
1996 my $func; 1996 my $func;
1997 my $descr; 1997 my $descr;
1998 my $in_purpose = 0;
1998 my $initial_section_counter = $section_counter; 1999 my $initial_section_counter = $section_counter;
1999 2000
2000 if (defined($ENV{'SRCTREE'})) { 2001 if (defined($ENV{'SRCTREE'})) {
@@ -2044,6 +2045,7 @@ sub process_file($) {
2044 $descr =~ s/\s*$//; 2045 $descr =~ s/\s*$//;
2045 $descr =~ s/\s+/ /; 2046 $descr =~ s/\s+/ /;
2046 $declaration_purpose = xml_escape($descr); 2047 $declaration_purpose = xml_escape($descr);
2048 $in_purpose = 1;
2047 } else { 2049 } else {
2048 $declaration_purpose = ""; 2050 $declaration_purpose = "";
2049 } 2051 }
@@ -2090,6 +2092,7 @@ sub process_file($) {
2090 } 2092 }
2091 2093
2092 $in_doc_sect = 1; 2094 $in_doc_sect = 1;
2095 $in_purpose = 0;
2093 $contents = $newcontents; 2096 $contents = $newcontents;
2094 if ($contents ne "") { 2097 if ($contents ne "") {
2095 while ((substr($contents, 0, 1) eq " ") || 2098 while ((substr($contents, 0, 1) eq " ") ||
@@ -2119,11 +2122,19 @@ sub process_file($) {
2119 } elsif (/$doc_content/) { 2122 } elsif (/$doc_content/) {
2120 # miguel-style comment kludge, look for blank lines after 2123 # miguel-style comment kludge, look for blank lines after
2121 # @parameter line to signify start of description 2124 # @parameter line to signify start of description
2122 if ($1 eq "" && 2125 if ($1 eq "") {
2123 ($section =~ m/^@/ || $section eq $section_context)) { 2126 if ($section =~ m/^@/ || $section eq $section_context) {
2124 dump_section($file, $section, xml_escape($contents)); 2127 dump_section($file, $section, xml_escape($contents));
2125 $section = $section_default; 2128 $section = $section_default;
2126 $contents = ""; 2129 $contents = "";
2130 } else {
2131 $contents .= "\n";
2132 }
2133 $in_purpose = 0;
2134 } elsif ($in_purpose == 1) {
2135 # Continued declaration purpose
2136 chomp($declaration_purpose);
2137 $declaration_purpose .= " " . xml_escape($1);
2127 } else { 2138 } else {
2128 $contents .= $1 . "\n"; 2139 $contents .= $1 . "\n";
2129 } 2140 }
diff --git a/scripts/markup_oops.pl b/scripts/markup_oops.pl
index 528492bcba5b..5f0fcb712e29 100644
--- a/scripts/markup_oops.pl
+++ b/scripts/markup_oops.pl
@@ -1,6 +1,7 @@
1#!/usr/bin/perl 1#!/usr/bin/perl
2 2
3use File::Basename; 3use File::Basename;
4use Math::BigInt;
4 5
5# Copyright 2008, Intel Corporation 6# Copyright 2008, Intel Corporation
6# 7#
@@ -172,8 +173,8 @@ while (<STDIN>) {
172 parse_x86_regs($line); 173 parse_x86_regs($line);
173} 174}
174 175
175my $decodestart = hex($target) - hex($func_offset); 176my $decodestart = Math::BigInt->from_hex("0x$target") - Math::BigInt->from_hex("0x$func_offset");
176my $decodestop = hex($target) + 8192; 177my $decodestop = Math::BigInt->from_hex("0x$target") + 8192;
177if ($target eq "0") { 178if ($target eq "0") {
178 print "No oops found!\n"; 179 print "No oops found!\n";
179 print "Usage: \n"; 180 print "Usage: \n";
@@ -183,10 +184,7 @@ if ($target eq "0") {
183 184
184# if it's a module, we need to find the .ko file and calculate a load offset 185# if it's a module, we need to find the .ko file and calculate a load offset
185if ($module ne "") { 186if ($module ne "") {
186 my $dir = dirname($filename); 187 my $modulefile = `modinfo $module | grep '^filename:' | awk '{ print \$2 }'`;
187 $dir = $dir . "/";
188 my $mod = $module . ".ko";
189 my $modulefile = `find $dir -name $mod | head -1`;
190 chomp($modulefile); 188 chomp($modulefile);
191 $filename = $modulefile; 189 $filename = $modulefile;
192 if ($filename eq "") { 190 if ($filename eq "") {
diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
index 6a12dd9f1181..bce3d0fe6fbd 100755
--- a/scripts/mkcompile_h
+++ b/scripts/mkcompile_h
@@ -1,3 +1,5 @@
1#!/bin/sh
2
1TARGET=$1 3TARGET=$1
2ARCH=$2 4ARCH=$2
3SMP=$3 5SMP=$3
@@ -50,7 +52,7 @@ UTS_VERSION="$UTS_VERSION $CONFIG_FLAGS $TIMESTAMP"
50# Truncate to maximum length 52# Truncate to maximum length
51 53
52UTS_LEN=64 54UTS_LEN=64
53UTS_TRUNCATE="sed -e s/\(.\{1,$UTS_LEN\}\).*/\1/" 55UTS_TRUNCATE="cut -b -$UTS_LEN"
54 56
55# Generate a temporary compile.h 57# Generate a temporary compile.h
56 58
@@ -66,9 +68,13 @@ UTS_TRUNCATE="sed -e s/\(.\{1,$UTS_LEN\}\).*/\1/"
66 echo \#define LINUX_COMPILE_HOST \"`hostname | $UTS_TRUNCATE`\" 68 echo \#define LINUX_COMPILE_HOST \"`hostname | $UTS_TRUNCATE`\"
67 69
68 if [ -x /bin/dnsdomainname ]; then 70 if [ -x /bin/dnsdomainname ]; then
69 echo \#define LINUX_COMPILE_DOMAIN \"`dnsdomainname | $UTS_TRUNCATE`\" 71 domain=`dnsdomainname 2> /dev/null`
70 elif [ -x /bin/domainname ]; then 72 elif [ -x /bin/domainname ]; then
71 echo \#define LINUX_COMPILE_DOMAIN \"`domainname | $UTS_TRUNCATE`\" 73 domain=`domainname 2> /dev/null`
74 fi
75
76 if [ -n "$domain" ]; then
77 echo \#define LINUX_COMPILE_DOMAIN \"`echo $domain | $UTS_TRUNCATE`\"
72 else 78 else
73 echo \#define LINUX_COMPILE_DOMAIN 79 echo \#define LINUX_COMPILE_DOMAIN
74 fi 80 fi
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 40e0045876ee..62a9025cdcc7 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -657,6 +657,15 @@ static int do_i2c_entry(const char *filename, struct i2c_device_id *id,
657 return 1; 657 return 1;
658} 658}
659 659
660/* Looks like: spi:S */
661static int do_spi_entry(const char *filename, struct spi_device_id *id,
662 char *alias)
663{
664 sprintf(alias, SPI_MODULE_PREFIX "%s", id->name);
665
666 return 1;
667}
668
660static const struct dmifield { 669static const struct dmifield {
661 const char *prefix; 670 const char *prefix;
662 int field; 671 int field;
@@ -853,6 +862,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
853 do_table(symval, sym->st_size, 862 do_table(symval, sym->st_size,
854 sizeof(struct i2c_device_id), "i2c", 863 sizeof(struct i2c_device_id), "i2c",
855 do_i2c_entry, mod); 864 do_i2c_entry, mod);
865 else if (sym_is(symname, "__mod_spi_device_table"))
866 do_table(symval, sym->st_size,
867 sizeof(struct spi_device_id), "spi",
868 do_spi_entry, mod);
856 else if (sym_is(symname, "__mod_dmi_device_table")) 869 else if (sym_is(symname, "__mod_dmi_device_table"))
857 do_table(symval, sym->st_size, 870 do_table(symval, sym->st_size,
858 sizeof(struct dmi_system_id), "dmi", 871 sizeof(struct dmi_system_id), "dmi",
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 4522948a012e..801a16a17545 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -691,7 +691,7 @@ static int number_prefix(const char *sym)
691 * The $ syntax is for sections where ld append a dot number 691 * The $ syntax is for sections where ld append a dot number
692 * to make section name unique. 692 * to make section name unique.
693 */ 693 */
694int match(const char *sym, const char * const pat[]) 694static int match(const char *sym, const char * const pat[])
695{ 695{
696 const char *p; 696 const char *p;
697 while (*pat) { 697 while (*pat) {
@@ -1746,7 +1746,7 @@ static void add_header(struct buffer *b, struct module *mod)
1746 buf_printf(b, "};\n"); 1746 buf_printf(b, "};\n");
1747} 1747}
1748 1748
1749void add_staging_flag(struct buffer *b, const char *name) 1749static void add_staging_flag(struct buffer *b, const char *name)
1750{ 1750{
1751 static const char *staging_dir = "drivers/staging"; 1751 static const char *staging_dir = "drivers/staging";
1752 1752
diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
index aadc5223dcdb..ecf9c7dc1825 100644
--- a/scripts/mod/sumversion.c
+++ b/scripts/mod/sumversion.c
@@ -334,8 +334,6 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md)
334 deps_drivers/net/dummy.o := \ 334 deps_drivers/net/dummy.o := \
335 drivers/net/dummy.c \ 335 drivers/net/dummy.c \
336 $(wildcard include/config/net/fastroute.h) \ 336 $(wildcard include/config/net/fastroute.h) \
337 include/linux/config.h \
338 $(wildcard include/config/h.h) \
339 include/linux/module.h \ 337 include/linux/module.h \
340 338
341 Sum all files in the same dir or subdirs. 339 Sum all files in the same dir or subdirs.
diff --git a/scripts/module-common.lds b/scripts/module-common.lds
new file mode 100644
index 000000000000..47a1f9ae0ede
--- /dev/null
+++ b/scripts/module-common.lds
@@ -0,0 +1,8 @@
1/*
2 * Common module linker script, always used when linking a module.
3 * Archs are free to supply their own linker scripts. ld will
4 * combine them automatically.
5 */
6SECTIONS {
7 /DISCARD/ : { *(.discard) }
8}
diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index fa4a0a17b7e0..f67cc885c807 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -18,6 +18,9 @@
18# e) generate the rpm files, based on kernel.spec 18# e) generate the rpm files, based on kernel.spec
19# - Use /. to avoid tar packing just the symlink 19# - Use /. to avoid tar packing just the symlink
20 20
21# Note that the rpm-pkg target cannot be used with KBUILD_OUTPUT,
22# but the binrpm-pkg target can; for some reason O= gets ignored.
23
21# Do we have rpmbuild, otherwise fall back to the older rpm 24# Do we have rpmbuild, otherwise fall back to the older rpm
22RPM := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ 25RPM := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \
23 else echo rpm; fi) 26 else echo rpm; fi)
@@ -33,6 +36,12 @@ $(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile
33 $(CONFIG_SHELL) $(MKSPEC) > $@ 36 $(CONFIG_SHELL) $(MKSPEC) > $@
34 37
35rpm-pkg rpm: $(objtree)/kernel.spec FORCE 38rpm-pkg rpm: $(objtree)/kernel.spec FORCE
39 @if test -n "$(KBUILD_OUTPUT)"; then \
40 echo "Building source + binary RPM is not possible outside the"; \
41 echo "kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \
42 echo "binrpm-pkg target instead."; \
43 false; \
44 fi
36 $(MAKE) clean 45 $(MAKE) clean
37 $(PREV) ln -sf $(srctree) $(KERNELPATH) 46 $(PREV) ln -sf $(srctree) $(KERNELPATH)
38 $(CONFIG_SHELL) $(srctree)/scripts/setlocalversion > $(objtree)/.scmversion 47 $(CONFIG_SHELL) $(srctree)/scripts/setlocalversion > $(objtree)/.scmversion
@@ -61,7 +70,7 @@ binrpm-pkg: $(objtree)/binkernel.spec FORCE
61 set -e; \ 70 set -e; \
62 mv -f $(objtree)/.tmp_version $(objtree)/.version 71 mv -f $(objtree)/.tmp_version $(objtree)/.version
63 72
64 $(RPM) $(RPMOPTS) --define "_builddir $(srctree)" --target \ 73 $(RPM) $(RPMOPTS) --define "_builddir $(objtree)" --target \
65 $(UTS_MACHINE) -bb $< 74 $(UTS_MACHINE) -bb $<
66 75
67clean-files += $(objtree)/binkernel.spec 76clean-files += $(objtree)/binkernel.spec
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 01c2d13dd020..8b357b0bd250 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -16,6 +16,8 @@ create_package() {
16 local pname="$1" pdir="$2" 16 local pname="$1" pdir="$2"
17 17
18 cp debian/copyright "$pdir/usr/share/doc/$pname/" 18 cp debian/copyright "$pdir/usr/share/doc/$pname/"
19 cp debian/changelog "$pdir/usr/share/doc/$pname/changelog.Debian"
20 gzip -9 "$pdir/usr/share/doc/$pname/changelog.Debian"
19 21
20 # Fix ownership and permissions 22 # Fix ownership and permissions
21 chown -R root:root "$pdir" 23 chown -R root:root "$pdir"
@@ -87,7 +89,7 @@ for script in postinst postrm preinst prerm ; do
87set -e 89set -e
88 90
89# Pass maintainer script parameters to hook scripts 91# Pass maintainer script parameters to hook scripts
90export DEB_MAINT_PARAMS="\$@" 92export DEB_MAINT_PARAMS="\$*"
91 93
92test -d $debhookdir/$script.d && run-parts --arg="$version" $debhookdir/$script.d 94test -d $debhookdir/$script.d && run-parts --arg="$version" $debhookdir/$script.d
93exit 0 95exit 0
diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index 3d93f8c81252..47bdd2f99b78 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -70,7 +70,7 @@ echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules'
70echo 'mkdir -p $RPM_BUILD_ROOT/lib/firmware' 70echo 'mkdir -p $RPM_BUILD_ROOT/lib/firmware'
71echo "%endif" 71echo "%endif"
72 72
73echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{_smp_mflags} modules_install' 73echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{_smp_mflags} KBUILD_SRC= modules_install'
74echo "%ifarch ia64" 74echo "%ifarch ia64"
75echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE" 75echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE"
76echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/" 76echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/"
diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
index 64f5ddb09ea6..5c113123ed9f 100644
--- a/scripts/pnmtologo.c
+++ b/scripts/pnmtologo.c
@@ -237,7 +237,7 @@ static void write_header(void)
237 fprintf(out, " * Linux logo %s\n", logoname); 237 fprintf(out, " * Linux logo %s\n", logoname);
238 fputs(" */\n\n", out); 238 fputs(" */\n\n", out);
239 fputs("#include <linux/linux_logo.h>\n\n", out); 239 fputs("#include <linux/linux_logo.h>\n\n", out);
240 fprintf(out, "static const unsigned char %s_data[] __initconst = {\n", 240 fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
241 logoname); 241 logoname);
242} 242}
243 243
@@ -374,7 +374,7 @@ static void write_logo_clut224(void)
374 fputs("\n};\n\n", out); 374 fputs("\n};\n\n", out);
375 375
376 /* write logo clut */ 376 /* write logo clut */
377 fprintf(out, "static const unsigned char %s_clut[] __initconst = {\n", 377 fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
378 logoname); 378 logoname);
379 write_hex_cnt = 0; 379 write_hex_cnt = 0;
380 for (i = 0; i < logo_clutsize; i++) { 380 for (i = 0; i < logo_clutsize; i++) {
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index 7109e2b5bc0a..090d300d7394 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -57,7 +57,6 @@
57# call mcount (offset: 0x5) 57# call mcount (offset: 0x5)
58# [...] 58# [...]
59# ret 59# ret
60# .globl my_func
61# other_func: 60# other_func:
62# [...] 61# [...]
63# call mcount (offset: 0x1b) 62# call mcount (offset: 0x1b)
@@ -393,7 +392,7 @@ while (<IN>) {
393 $read_function = 0; 392 $read_function = 0;
394 } 393 }
395 # print out any recorded offsets 394 # print out any recorded offsets
396 update_funcs() if ($text_found); 395 update_funcs() if (defined($ref_func));
397 396
398 # reset all markers and arrays 397 # reset all markers and arrays
399 $text_found = 0; 398 $text_found = 0;
@@ -403,7 +402,6 @@ while (<IN>) {
403 # section found, now is this a start of a function? 402 # section found, now is this a start of a function?
404 } elsif ($read_function && /$function_regex/) { 403 } elsif ($read_function && /$function_regex/) {
405 $text_found = 1; 404 $text_found = 1;
406 $offset = hex $1;
407 $text = $2; 405 $text = $2;
408 406
409 # if this is either a local function or a weak function 407 # if this is either a local function or a weak function
@@ -412,10 +410,15 @@ while (<IN>) {
412 if (!defined($locals{$text}) && !defined($weak{$text})) { 410 if (!defined($locals{$text}) && !defined($weak{$text})) {
413 $ref_func = $text; 411 $ref_func = $text;
414 $read_function = 0; 412 $read_function = 0;
413 $offset = hex $1;
415 } else { 414 } else {
416 # if we already have a function, and this is weak, skip it 415 # if we already have a function, and this is weak, skip it
417 if (!defined($ref_func) || !defined($weak{$text})) { 416 if (!defined($ref_func) && !defined($weak{$text}) &&
417 # PPC64 can have symbols that start with .L and
418 # gcc considers these special. Don't use them!
419 $text !~ /^\.L/) {
418 $ref_func = $text; 420 $ref_func = $text;
421 $offset = hex $1;
419 } 422 }
420 } 423 }
421 } elsif ($read_headers && /$mcount_section/) { 424 } elsif ($read_headers && /$mcount_section/) {
@@ -440,7 +443,7 @@ while (<IN>) {
440} 443}
441 444
442# dump out anymore offsets that may have been found 445# dump out anymore offsets that may have been found
443update_funcs() if ($text_found); 446update_funcs() if (defined($ref_func));
444 447
445# If we did not find any mcount callers, we are done (do nothing). 448# If we did not find any mcount callers, we are done (do nothing).
446if (!$opened) { 449if (!$opened) {
diff --git a/scripts/selinux/mdp/mdp.c b/scripts/selinux/mdp/mdp.c
index ca757d486187..b4ced8562587 100644
--- a/scripts/selinux/mdp/mdp.c
+++ b/scripts/selinux/mdp/mdp.c
@@ -31,13 +31,13 @@
31 31
32#include "flask.h" 32#include "flask.h"
33 33
34void usage(char *name) 34static void usage(char *name)
35{ 35{
36 printf("usage: %s [-m] policy_file context_file\n", name); 36 printf("usage: %s [-m] policy_file context_file\n", name);
37 exit(1); 37 exit(1);
38} 38}
39 39
40void find_common_name(char *cname, char *dest, int len) 40static void find_common_name(char *cname, char *dest, int len)
41{ 41{
42 char *start, *end; 42 char *start, *end;
43 43
diff --git a/scripts/tags.sh b/scripts/tags.sh
index 4a34ec591e8c..d52f7a01557c 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -101,7 +101,8 @@ exuberant()
101 -I ____cacheline_aligned_in_smp \ 101 -I ____cacheline_aligned_in_smp \
102 -I ____cacheline_internodealigned_in_smp \ 102 -I ____cacheline_internodealigned_in_smp \
103 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ 103 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \
104 --extra=+f --c-kinds=+px \ 104 -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \
105 --extra=+f --c-kinds=-px \
105 --regex-asm='/^ENTRY\(([^)]*)\).*/\1/' \ 106 --regex-asm='/^ENTRY\(([^)]*)\).*/\1/' \
106 --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' 107 --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/'
107 108
diff --git a/scripts/tracing/power.pl b/scripts/tracing/power.pl
deleted file mode 100644
index 4f729b3501e0..000000000000
--- a/scripts/tracing/power.pl
+++ /dev/null
@@ -1,108 +0,0 @@
1#!/usr/bin/perl
2
3# Copyright 2008, Intel Corporation
4#
5# This file is part of the Linux kernel
6#
7# This program file is free software; you can redistribute it and/or modify it
8# under the terms of the GNU General Public License as published by the
9# Free Software Foundation; version 2 of the License.
10#
11# This program is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14# for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program in a file named COPYING; if not, write to the
18# Free Software Foundation, Inc.,
19# 51 Franklin Street, Fifth Floor,
20# Boston, MA 02110-1301 USA
21#
22# Authors:
23# Arjan van de Ven <arjan@linux.intel.com>
24
25
26#
27# This script turns a cstate ftrace output into a SVG graphic that shows
28# historic C-state information
29#
30#
31# cat /sys/kernel/debug/tracing/trace | perl power.pl > out.svg
32#
33
34my @styles;
35my $base = 0;
36
37my @pstate_last;
38my @pstate_level;
39
40$styles[0] = "fill:rgb(0,0,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
41$styles[1] = "fill:rgb(0,255,0);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
42$styles[2] = "fill:rgb(255,0,20);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
43$styles[3] = "fill:rgb(255,255,20);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
44$styles[4] = "fill:rgb(255,0,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
45$styles[5] = "fill:rgb(0,255,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
46$styles[6] = "fill:rgb(0,128,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
47$styles[7] = "fill:rgb(0,255,128);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
48$styles[8] = "fill:rgb(0,25,20);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
49
50
51print "<?xml version=\"1.0\" standalone=\"no\"?> \n";
52print "<svg width=\"10000\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n";
53
54my $scale = 30000.0;
55while (<>) {
56 my $line = $_;
57 if ($line =~ /([0-9\.]+)\] CSTATE: Going to C([0-9]) on cpu ([0-9]+) for ([0-9\.]+)/) {
58 if ($base == 0) {
59 $base = $1;
60 }
61 my $time = $1 - $base;
62 $time = $time * $scale;
63 my $C = $2;
64 my $cpu = $3;
65 my $y = 400 * $cpu;
66 my $duration = $4 * $scale;
67 my $msec = int($4 * 100000)/100.0;
68 my $height = $C * 20;
69 $style = $styles[$C];
70
71 $y = $y + 140 - $height;
72
73 $x2 = $time + 4;
74 $y2 = $y + 4;
75
76
77 print "<rect x=\"$time\" width=\"$duration\" y=\"$y\" height=\"$height\" style=\"$style\"/>\n";
78 print "<text transform=\"translate($x2,$y2) rotate(90)\">C$C $msec</text>\n";
79 }
80 if ($line =~ /([0-9\.]+)\] PSTATE: Going to P([0-9]) on cpu ([0-9]+)/) {
81 my $time = $1 - $base;
82 my $state = $2;
83 my $cpu = $3;
84
85 if (defined($pstate_last[$cpu])) {
86 my $from = $pstate_last[$cpu];
87 my $oldstate = $pstate_state[$cpu];
88 my $duration = ($time-$from) * $scale;
89
90 $from = $from * $scale;
91 my $to = $from + $duration;
92 my $height = 140 - ($oldstate * (140/8));
93
94 my $y = 400 * $cpu + 200 + $height;
95 my $y2 = $y+4;
96 my $style = $styles[8];
97
98 print "<rect x=\"$from\" y=\"$y\" width=\"$duration\" height=\"5\" style=\"$style\"/>\n";
99 print "<text transform=\"translate($from,$y2)\">P$oldstate (cpu $cpu)</text>\n";
100 };
101
102 $pstate_last[$cpu] = $time;
103 $pstate_state[$cpu] = $state;
104 }
105}
106
107
108print "</svg>\n";