aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMichal Marek <mmarek@suse.cz>2010-10-27 18:15:57 -0400
committerMichal Marek <mmarek@suse.cz>2010-10-27 18:15:57 -0400
commitb74b953b998bcc2db91b694446f3a2619ec32de6 (patch)
tree6ce24caabd730f6ae9287ed0676ec32e6ff31e9d /scripts
parentabb438526201c6a79949ad45375c051b6681c253 (diff)
parentf6f94e2ab1b33f0082ac22d71f66385a60d8157f (diff)
Merge commit 'v2.6.36' into kbuild/misc
Update to be able to fix a recent change to scripts/basic/docproc.c (commit eda603f).
Diffstat (limited to 'scripts')
-rw-r--r--scripts/.gitignore1
-rw-r--r--scripts/Makefile.build37
-rw-r--r--scripts/Makefile.headersinst3
-rw-r--r--scripts/Makefile.lib4
-rw-r--r--scripts/Makefile.modbuiltin5
-rw-r--r--scripts/Makefile.modpost9
-rw-r--r--scripts/basic/docproc.c129
-rw-r--r--scripts/binoffset.c163
-rwxr-xr-xscripts/checkpatch.pl147
-rwxr-xr-xscripts/checksyscalls.sh1
-rwxr-xr-xscripts/extract-ikconfig127
-rw-r--r--scripts/gen_initramfs_list.sh1
-rwxr-xr-xscripts/get_maintainer.pl255
-rw-r--r--scripts/gfp-translate2
-rw-r--r--scripts/kconfig/Makefile93
-rw-r--r--scripts/kconfig/conf.c196
-rw-r--r--scripts/kconfig/confdata.c324
-rw-r--r--scripts/kconfig/expr.c4
-rw-r--r--scripts/kconfig/expr.h2
-rw-r--r--scripts/kconfig/gconf.c7
-rw-r--r--scripts/kconfig/lkc.h12
-rw-r--r--scripts/kconfig/lkc_proto.h1
-rw-r--r--scripts/kconfig/lxdialog/checklist.c10
-rw-r--r--scripts/kconfig/mconf.c2
-rw-r--r--scripts/kconfig/menu.c24
-rw-r--r--scripts/kconfig/nconf.c2
-rw-r--r--scripts/kconfig/nconf.gui.c2
-rw-r--r--scripts/kconfig/qconf.cc106
-rw-r--r--scripts/kconfig/qconf.h17
-rw-r--r--scripts/kconfig/streamline_config.pl68
-rw-r--r--scripts/kconfig/symbol.c296
-rw-r--r--scripts/kconfig/util.c2
-rwxr-xr-xscripts/kernel-doc77
-rw-r--r--scripts/markup_oops.pl2
-rw-r--r--scripts/mkmakefile4
-rw-r--r--scripts/mod/file2alias.c63
-rw-r--r--scripts/mod/modpost.c182
-rw-r--r--scripts/mod/modpost.h43
-rw-r--r--scripts/package/Makefile39
-rw-r--r--scripts/package/builddeb5
-rwxr-xr-xscripts/package/mkspec2
-rwxr-xr-xscripts/recordmcount.pl46
-rw-r--r--scripts/selinux/genheaders/genheaders.c2
-rwxr-xr-xscripts/setlocalversion183
44 files changed, 1893 insertions, 807 deletions
diff --git a/scripts/.gitignore b/scripts/.gitignore
index 52cab46ae35a..c5d5db54c009 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -6,5 +6,4 @@ kallsyms
6pnmtologo 6pnmtologo
7bin2c 7bin2c
8unifdef 8unifdef
9binoffset
10ihex2fw 9ihex2fw
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index e4deb73e9a84..a1a5cf95a68d 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -115,7 +115,10 @@ endif
115# --------------------------------------------------------------------------- 115# ---------------------------------------------------------------------------
116 116
117# Default is built-in, unless we know otherwise 117# Default is built-in, unless we know otherwise
118modkern_cflags = $(if $(part-of-module), $(CFLAGS_MODULE), $(CFLAGS_KERNEL)) 118modkern_cflags = \
119 $(if $(part-of-module), \
120 $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
121 $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
119quiet_modtag := $(empty) $(empty) 122quiet_modtag := $(empty) $(empty)
120 123
121$(real-objs-m) : part-of-module := y 124$(real-objs-m) : part-of-module := y
@@ -156,14 +159,14 @@ $(obj)/%.i: $(src)/%.c FORCE
156 159
157cmd_gensymtypes = \ 160cmd_gensymtypes = \
158 $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ 161 $(CPP) -D__GENKSYMS__ $(c_flags) $< | \
159 $(GENKSYMS) -T $@ -a $(ARCH) \ 162 $(GENKSYMS) $(if $(1), -T $(2)) -a $(ARCH) \
160 $(if $(KBUILD_PRESERVE),-p) \ 163 $(if $(KBUILD_PRESERVE),-p) \
161 $(if $(1),-r $(firstword $(wildcard $(@:.symtypes=.symref) /dev/null))) 164 -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null))
162 165
163quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ 166quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@
164cmd_cc_symtypes_c = \ 167cmd_cc_symtypes_c = \
165 set -e; \ 168 set -e; \
166 $(call cmd_gensymtypes, true) >/dev/null; \ 169 $(call cmd_gensymtypes,true,$@) >/dev/null; \
167 test -s $@ || rm -f $@ 170 test -s $@ || rm -f $@
168 171
169$(obj)/%.symtypes : $(src)/%.c FORCE 172$(obj)/%.symtypes : $(src)/%.c FORCE
@@ -192,16 +195,16 @@ else
192# the actual value of the checksum generated by genksyms 195# the actual value of the checksum generated by genksyms
193 196
194cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< 197cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
195cmd_modversions = \ 198cmd_modversions = \
196 if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ 199 if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \
197 $(call cmd_gensymtypes, $(KBUILD_SYMTYPES)) \ 200 $(call cmd_gensymtypes,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
198 > $(@D)/.tmp_$(@F:.o=.ver); \ 201 > $(@D)/.tmp_$(@F:.o=.ver); \
199 \ 202 \
200 $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ 203 $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \
201 -T $(@D)/.tmp_$(@F:.o=.ver); \ 204 -T $(@D)/.tmp_$(@F:.o=.ver); \
202 rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ 205 rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \
203 else \ 206 else \
204 mv -f $(@D)/.tmp_$(@F) $@; \ 207 mv -f $(@D)/.tmp_$(@F) $@; \
205 fi; 208 fi;
206endif 209endif
207 210
@@ -248,10 +251,10 @@ $(obj)/%.lst: $(src)/%.c FORCE
248# Compile assembler sources (.S) 251# Compile assembler sources (.S)
249# --------------------------------------------------------------------------- 252# ---------------------------------------------------------------------------
250 253
251modkern_aflags := $(AFLAGS_KERNEL) 254modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL)
252 255
253$(real-objs-m) : modkern_aflags := $(AFLAGS_MODULE) 256$(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
254$(real-objs-m:.o=.s): modkern_aflags := $(AFLAGS_MODULE) 257$(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
255 258
256quiet_cmd_as_s_S = CPP $(quiet_modtag) $@ 259quiet_cmd_as_s_S = CPP $(quiet_modtag) $@
257cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< 260cmd_as_s_S = $(CPP) $(a_flags) -o $@ $<
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index 0fcd83838771..f89cb87f5c01 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -3,7 +3,6 @@
3# 3#
4# header-y - list files to be installed. They are preprocessed 4# header-y - list files to be installed. They are preprocessed
5# to remove __KERNEL__ section of the file 5# to remove __KERNEL__ section of the file
6# unifdef-y - Same as header-y. Obsolete
7# objhdr-y - Same as header-y but for generated files 6# objhdr-y - Same as header-y but for generated files
8# 7#
9# ========================================================================== 8# ==========================================================================
@@ -20,7 +19,7 @@ include scripts/Kbuild.include
20 19
21install := $(INSTALL_HDR_PATH)/$(_dst) 20install := $(INSTALL_HDR_PATH)/$(_dst)
22 21
23header-y := $(sort $(header-y) $(unifdef-y)) 22header-y := $(sort $(header-y))
24subdirs := $(patsubst %/,%,$(filter %/, $(header-y))) 23subdirs := $(patsubst %/,%,$(filter %/, $(header-y)))
25header-y := $(filter-out %/, $(header-y)) 24header-y := $(filter-out %/, $(header-y))
26 25
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index f3ccdb1b302b..54fd1b700131 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -245,3 +245,7 @@ quiet_cmd_lzo = LZO $@
245cmd_lzo = (cat $(filter-out FORCE,$^) | \ 245cmd_lzo = (cat $(filter-out FORCE,$^) | \
246 lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ 246 lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
247 (rm -f $@ ; false) 247 (rm -f $@ ; false)
248
249# misc stuff
250# ---------------------------------------------------------------------------
251quote:="
diff --git a/scripts/Makefile.modbuiltin b/scripts/Makefile.modbuiltin
index 102a276f6eea..1adb974e6950 100644
--- a/scripts/Makefile.modbuiltin
+++ b/scripts/Makefile.modbuiltin
@@ -14,6 +14,11 @@ __modbuiltin:
14 14
15include scripts/Kbuild.include 15include scripts/Kbuild.include
16 16
17ifneq ($(KBUILD_SRC),)
18# Create output directory if not already present
19_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
20endif
21
17# The filename Kbuild has precedence over Makefile 22# The filename Kbuild has precedence over Makefile
18kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) 23kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
19kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile) 24kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 8f14c81abbc7..7d22056582c1 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -30,7 +30,7 @@
30# - See include/linux/module.h for more details 30# - See include/linux/module.h for more details
31 31
32# Step 4 is solely used to allow module versioning in external modules, 32# Step 4 is solely used to allow module versioning in external modules,
33# where the CRC of each module is retrieved from the Module.symers file. 33# where the CRC of each module is retrieved from the Module.symvers file.
34 34
35# KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined 35# KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined
36# symbols in the final module linking stage 36# symbols in the final module linking stage
@@ -107,7 +107,7 @@ $(modules:.ko=.mod.c): __modpost ;
107modname = $(notdir $(@:.mod.o=)) 107modname = $(notdir $(@:.mod.o=))
108 108
109quiet_cmd_cc_o_c = CC $@ 109quiet_cmd_cc_o_c = CC $@
110 cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \ 110 cmd_cc_o_c = $(CC) $(c_flags) $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE) \
111 -c -o $@ $< 111 -c -o $@ $<
112 112
113$(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE 113$(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE
@@ -117,8 +117,9 @@ targets += $(modules:.ko=.mod.o)
117 117
118# Step 6), final link of the modules 118# Step 6), final link of the modules
119quiet_cmd_ld_ko_o = LD [M] $@ 119quiet_cmd_ld_ko_o = LD [M] $@
120 cmd_ld_ko_o = $(LD) -r $(LDFLAGS) $(LDFLAGS_MODULE) -o $@ \ 120 cmd_ld_ko_o = $(LD) -r $(LDFLAGS) \
121 $(filter-out FORCE,$^) 121 $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
122 -o $@ $(filter-out FORCE,$^)
122 123
123$(modules): %.ko :%.o %.mod.o FORCE 124$(modules): %.ko :%.o %.mod.o FORCE
124 $(call if_changed,ld_ko_o) 125 $(call if_changed,ld_ko_o)
diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c
index 79ab973fb43a..fc3b18d844af 100644
--- a/scripts/basic/docproc.c
+++ b/scripts/basic/docproc.c
@@ -34,12 +34,14 @@
34 * 34 *
35 */ 35 */
36 36
37#define _GNU_SOURCE
37#include <stdio.h> 38#include <stdio.h>
38#include <stdlib.h> 39#include <stdlib.h>
39#include <string.h> 40#include <string.h>
40#include <ctype.h> 41#include <ctype.h>
41#include <unistd.h> 42#include <unistd.h>
42#include <limits.h> 43#include <limits.h>
44#include <errno.h>
43#include <sys/types.h> 45#include <sys/types.h>
44#include <sys/wait.h> 46#include <sys/wait.h>
45 47
@@ -54,6 +56,7 @@ typedef void FILEONLY(char * file);
54FILEONLY *internalfunctions; 56FILEONLY *internalfunctions;
55FILEONLY *externalfunctions; 57FILEONLY *externalfunctions;
56FILEONLY *symbolsonly; 58FILEONLY *symbolsonly;
59FILEONLY *findall;
57 60
58typedef void FILELINE(char * file, char * line); 61typedef void FILELINE(char * file, char * line);
59FILELINE * singlefunctions; 62FILELINE * singlefunctions;
@@ -65,12 +68,30 @@ FILELINE * docsection;
65#define KERNELDOCPATH "scripts/" 68#define KERNELDOCPATH "scripts/"
66#define KERNELDOC "kernel-doc" 69#define KERNELDOC "kernel-doc"
67#define DOCBOOK "-docbook" 70#define DOCBOOK "-docbook"
71#define LIST "-list"
68#define FUNCTION "-function" 72#define FUNCTION "-function"
69#define NOFUNCTION "-nofunction" 73#define NOFUNCTION "-nofunction"
70#define NODOCSECTIONS "-no-doc-sections" 74#define NODOCSECTIONS "-no-doc-sections"
71 75
72static char *srctree, *kernsrctree; 76static char *srctree, *kernsrctree;
73 77
78static char **all_list = NULL;
79static int all_list_len = 0;
80
81static void consume_symbol(const char *sym)
82{
83 int i;
84
85 for (i = 0; i < all_list_len; i++) {
86 if (!all_list[i])
87 continue;
88 if (strcmp(sym, all_list[i]))
89 continue;
90 all_list[i] = NULL;
91 break;
92 }
93}
94
74static void usage (void) 95static void usage (void)
75{ 96{
76 fprintf(stderr, "Usage: docproc {doc|depend} file\n"); 97 fprintf(stderr, "Usage: docproc {doc|depend} file\n");
@@ -248,6 +269,7 @@ static void docfunctions(char * filename, char * type)
248 struct symfile * sym = &symfilelist[i]; 269 struct symfile * sym = &symfilelist[i];
249 for (j=0; j < sym->symbolcnt; j++) { 270 for (j=0; j < sym->symbolcnt; j++) {
250 vec[idx++] = type; 271 vec[idx++] = type;
272 consume_symbol(sym->symbollist[j].name);
251 vec[idx++] = sym->symbollist[j].name; 273 vec[idx++] = sym->symbollist[j].name;
252 } 274 }
253 } 275 }
@@ -287,6 +309,11 @@ static void singfunc(char * filename, char * line)
287 vec[idx++] = &line[i]; 309 vec[idx++] = &line[i];
288 } 310 }
289 } 311 }
312 for (i = 0; i < idx; i++) {
313 if (strcmp(vec[i], FUNCTION))
314 continue;
315 consume_symbol(vec[i + 1]);
316 }
290 vec[idx++] = filename; 317 vec[idx++] = filename;
291 vec[idx] = NULL; 318 vec[idx] = NULL;
292 exec_kernel_doc(vec); 319 exec_kernel_doc(vec);
@@ -306,6 +333,10 @@ static void docsect(char *filename, char *line)
306 if (*s == '\n') 333 if (*s == '\n')
307 *s = '\0'; 334 *s = '\0';
308 335
336 asprintf(&s, "DOC: %s", line);
337 consume_symbol(s);
338 free(s);
339
309 vec[0] = KERNELDOC; 340 vec[0] = KERNELDOC;
310 vec[1] = DOCBOOK; 341 vec[1] = DOCBOOK;
311 vec[2] = FUNCTION; 342 vec[2] = FUNCTION;
@@ -315,6 +346,84 @@ static void docsect(char *filename, char *line)
315 exec_kernel_doc(vec); 346 exec_kernel_doc(vec);
316} 347}
317 348
349static void find_all_symbols(char *filename)
350{
351 char *vec[4]; /* kerneldoc -list file NULL */
352 pid_t pid;
353 int ret, i, count, start;
354 char real_filename[PATH_MAX + 1];
355 int pipefd[2];
356 char *data, *str;
357 size_t data_len = 0;
358
359 vec[0] = KERNELDOC;
360 vec[1] = LIST;
361 vec[2] = filename;
362 vec[3] = NULL;
363
364 if (pipe(pipefd)) {
365 perror("pipe");
366 exit(1);
367 }
368
369 switch (pid=fork()) {
370 case -1:
371 perror("fork");
372 exit(1);
373 case 0:
374 close(pipefd[0]);
375 dup2(pipefd[1], 1);
376 memset(real_filename, 0, sizeof(real_filename));
377 strncat(real_filename, kernsrctree, PATH_MAX);
378 strncat(real_filename, "/" KERNELDOCPATH KERNELDOC,
379 PATH_MAX - strlen(real_filename));
380 execvp(real_filename, vec);
381 fprintf(stderr, "exec ");
382 perror(real_filename);
383 exit(1);
384 default:
385 close(pipefd[1]);
386 data = malloc(4096);
387 do {
388 while ((ret = read(pipefd[0],
389 data + data_len,
390 4096)) > 0) {
391 data_len += ret;
392 data = realloc(data, data_len + 4096);
393 }
394 } while (ret == -EAGAIN);
395 if (ret != 0) {
396 perror("read");
397 exit(1);
398 }
399 waitpid(pid, &ret ,0);
400 }
401 if (WIFEXITED(ret))
402 exitstatus |= WEXITSTATUS(ret);
403 else
404 exitstatus = 0xff;
405
406 count = 0;
407 /* poor man's strtok, but with counting */
408 for (i = 0; i < data_len; i++) {
409 if (data[i] == '\n') {
410 count++;
411 data[i] = '\0';
412 }
413 }
414 start = all_list_len;
415 all_list_len += count;
416 all_list = realloc(all_list, sizeof(char *) * all_list_len);
417 str = data;
418 for (i = 0; i < data_len && start != all_list_len; i++) {
419 if (data[i] == '\0') {
420 all_list[start] = str;
421 str = data + i + 1;
422 start++;
423 }
424 }
425}
426
318/* 427/*
319 * Parse file, calling action specific functions for: 428 * Parse file, calling action specific functions for:
320 * 1) Lines containing !E 429 * 1) Lines containing !E
@@ -322,7 +431,8 @@ static void docsect(char *filename, char *line)
322 * 3) Lines containing !D 431 * 3) Lines containing !D
323 * 4) Lines containing !F 432 * 4) Lines containing !F
324 * 5) Lines containing !P 433 * 5) Lines containing !P
325 * 6) Default lines - lines not matching the above 434 * 6) Lines containing !C
435 * 7) Default lines - lines not matching the above
326 */ 436 */
327static void parse_file(FILE *infile) 437static void parse_file(FILE *infile)
328{ 438{
@@ -365,6 +475,12 @@ static void parse_file(FILE *infile)
365 s++; 475 s++;
366 docsection(line + 2, s); 476 docsection(line + 2, s);
367 break; 477 break;
478 case 'C':
479 while (*s && !isspace(*s)) s++;
480 *s = '\0';
481 if (findall)
482 findall(line+2);
483 break;
368 default: 484 default:
369 defaultline(line); 485 defaultline(line);
370 } 486 }
@@ -380,6 +496,7 @@ static void parse_file(FILE *infile)
380int main(int argc, char *argv[]) 496int main(int argc, char *argv[])
381{ 497{
382 FILE * infile; 498 FILE * infile;
499 int i;
383 500
384 srctree = getenv("SRCTREE"); 501 srctree = getenv("SRCTREE");
385 if (!srctree) 502 if (!srctree)
@@ -415,6 +532,7 @@ int main(int argc, char *argv[])
415 symbolsonly = find_export_symbols; 532 symbolsonly = find_export_symbols;
416 singlefunctions = noaction2; 533 singlefunctions = noaction2;
417 docsection = noaction2; 534 docsection = noaction2;
535 findall = find_all_symbols;
418 parse_file(infile); 536 parse_file(infile);
419 537
420 /* Rewind to start from beginning of file again */ 538 /* Rewind to start from beginning of file again */
@@ -425,8 +543,16 @@ int main(int argc, char *argv[])
425 symbolsonly = printline; 543 symbolsonly = printline;
426 singlefunctions = singfunc; 544 singlefunctions = singfunc;
427 docsection = docsect; 545 docsection = docsect;
546 findall = NULL;
428 547
429 parse_file(infile); 548 parse_file(infile);
549
550 for (i = 0; i < all_list_len; i++) {
551 if (!all_list[i])
552 continue;
553 fprintf(stderr, "Warning: didn't use docs for %s\n",
554 all_list[i]);
555 }
430 } 556 }
431 else if (strcmp("depend", argv[1]) == 0) 557 else if (strcmp("depend", argv[1]) == 0)
432 { 558 {
@@ -439,6 +565,7 @@ int main(int argc, char *argv[])
439 symbolsonly = adddep; 565 symbolsonly = adddep;
440 singlefunctions = adddep2; 566 singlefunctions = adddep2;
441 docsection = adddep2; 567 docsection = adddep2;
568 findall = adddep;
442 parse_file(infile); 569 parse_file(infile);
443 printf("\n"); 570 printf("\n");
444 } 571 }
diff --git a/scripts/binoffset.c b/scripts/binoffset.c
deleted file mode 100644
index 1a2e39b8e3e5..000000000000
--- a/scripts/binoffset.c
+++ /dev/null
@@ -1,163 +0,0 @@
1/***************************************************************************
2 * binoffset.c
3 * (C) 2002 Randy Dunlap <rdunlap@xenotime.net>
4
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19# binoffset.c:
20# - searches a (binary) file for a specified (binary) pattern
21# - returns the offset of the located pattern or ~0 if not found
22# - exits with exit status 0 normally or non-0 if pattern is not found
23# or any other error occurs.
24
25****************************************************************/
26
27#include <stdio.h>
28#include <stdlib.h>
29#include <string.h>
30#include <errno.h>
31#include <unistd.h>
32#include <fcntl.h>
33#include <sys/types.h>
34#include <sys/stat.h>
35#include <sys/mman.h>
36
37#define VERSION "0.1"
38#define BUF_SIZE (16 * 1024)
39#define PAT_SIZE 100
40
41char *progname;
42char *inputname;
43int inputfd;
44unsigned int bix; /* buf index */
45unsigned char patterns [PAT_SIZE] = {0}; /* byte-sized pattern array */
46int pat_len; /* actual number of pattern bytes */
47unsigned char *madr; /* mmap address */
48size_t filesize;
49int num_matches = 0;
50off_t firstloc = 0;
51
52void usage (void)
53{
54 fprintf (stderr, "%s ver. %s\n", progname, VERSION);
55 fprintf (stderr, "usage: %s filename pattern_bytes\n",
56 progname);
57 fprintf (stderr, " [prints location of pattern_bytes in file]\n");
58 exit (1);
59}
60
61void get_pattern (int pat_count, char *pats [])
62{
63 int ix, err, tmp;
64
65#ifdef DEBUG
66 fprintf (stderr,"get_pattern: count = %d\n", pat_count);
67 for (ix = 0; ix < pat_count; ix++)
68 fprintf (stderr, " pat # %d: [%s]\n", ix, pats[ix]);
69#endif
70
71 for (ix = 0; ix < pat_count; ix++) {
72 tmp = 0;
73 err = sscanf (pats[ix], "%5i", &tmp);
74 if (err != 1 || tmp > 0xff) {
75 fprintf (stderr, "pattern or value error in pattern # %d [%s]\n",
76 ix, pats[ix]);
77 usage ();
78 }
79 patterns [ix] = tmp;
80 }
81 pat_len = pat_count;
82}
83
84void search_pattern (void)
85{
86 for (bix = 0; bix < filesize; bix++) {
87 if (madr[bix] == patterns[0]) {
88 if (memcmp (&madr[bix], patterns, pat_len) == 0) {
89 if (num_matches == 0)
90 firstloc = bix;
91 num_matches++;
92 }
93 }
94 }
95}
96
97#ifdef NOTDEF
98size_t get_filesize (int fd)
99{
100 off_t end_off = lseek (fd, 0, SEEK_END);
101 lseek (fd, 0, SEEK_SET);
102 return (size_t) end_off;
103}
104#endif
105
106size_t get_filesize (int fd)
107{
108 int err;
109 struct stat stat;
110
111 err = fstat (fd, &stat);
112 fprintf (stderr, "filesize: %ld\n", err < 0 ? (long)err : stat.st_size);
113 if (err < 0)
114 return err;
115 return (size_t) stat.st_size;
116}
117
118int main (int argc, char *argv [])
119{
120 progname = argv[0];
121
122 if (argc < 3)
123 usage ();
124
125 get_pattern (argc - 2, argv + 2);
126
127 inputname = argv[1];
128
129 inputfd = open (inputname, O_RDONLY);
130 if (inputfd == -1) {
131 fprintf (stderr, "%s: cannot open '%s'\n",
132 progname, inputname);
133 exit (3);
134 }
135
136 filesize = get_filesize (inputfd);
137
138 madr = mmap (0, filesize, PROT_READ, MAP_PRIVATE, inputfd, 0);
139 if (madr == MAP_FAILED) {
140 fprintf (stderr, "mmap error = %d\n", errno);
141 close (inputfd);
142 exit (4);
143 }
144
145 search_pattern ();
146
147 if (munmap (madr, filesize))
148 fprintf (stderr, "munmap error = %d\n", errno);
149
150 if (close (inputfd))
151 fprintf (stderr, "%s: error %d closing '%s'\n",
152 progname, errno, inputname);
153
154 fprintf (stderr, "number of pattern matches = %d\n", num_matches);
155 if (num_matches == 0)
156 firstloc = ~0;
157 printf ("%ld\n", firstloc);
158 fprintf (stderr, "%ld\n", firstloc);
159
160 exit (num_matches ? 0 : 2);
161}
162
163/* end binoffset.c */
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 3257d3d96767..2039acdf5122 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -145,11 +145,14 @@ our $Sparse = qr{
145 __kprobes| 145 __kprobes|
146 __ref 146 __ref
147 }x; 147 }x;
148
149# Notes to $Attribute:
150# We need \b after 'init' otherwise 'initconst' will cause a false positive in a check
148our $Attribute = qr{ 151our $Attribute = qr{
149 const| 152 const|
150 __read_mostly| 153 __read_mostly|
151 __kprobes| 154 __kprobes|
152 __(?:mem|cpu|dev|)(?:initdata|init)| 155 __(?:mem|cpu|dev|)(?:initdata|initconst|init\b)|
153 ____cacheline_aligned| 156 ____cacheline_aligned|
154 ____cacheline_aligned_in_smp| 157 ____cacheline_aligned_in_smp|
155 ____cacheline_internodealigned_in_smp| 158 ____cacheline_internodealigned_in_smp|
@@ -189,6 +192,14 @@ our $typeTypedefs = qr{(?x:
189 atomic_t 192 atomic_t
190)}; 193)};
191 194
195our $logFunctions = qr{(?x:
196 printk|
197 pr_(debug|dbg|vdbg|devel|info|warning|err|notice|alert|crit|emerg|cont)|
198 (dev|netdev|netif)_(printk|dbg|vdbg|info|warn|err|notice|alert|crit|emerg|WARN)|
199 WARN|
200 panic
201)};
202
192our @typeList = ( 203our @typeList = (
193 qr{void}, 204 qr{void},
194 qr{(?:unsigned\s+)?char}, 205 qr{(?:unsigned\s+)?char},
@@ -213,6 +224,12 @@ our @modifierList = (
213 qr{fastcall}, 224 qr{fastcall},
214); 225);
215 226
227our $allowed_asm_includes = qr{(?x:
228 irq|
229 memory
230)};
231# memory.h: ARM has a custom one
232
216sub build_types { 233sub build_types {
217 my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)"; 234 my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)";
218 my $all = "(?x: \n" . join("|\n ", @typeList) . "\n)"; 235 my $all = "(?x: \n" . join("|\n ", @typeList) . "\n)";
@@ -541,6 +558,9 @@ sub ctx_statement_block {
541 $type = ($level != 0)? '{' : ''; 558 $type = ($level != 0)? '{' : '';
542 559
543 if ($level == 0) { 560 if ($level == 0) {
561 if (substr($blk, $off + 1, 1) eq ';') {
562 $off++;
563 }
544 last; 564 last;
545 } 565 }
546 } 566 }
@@ -1371,18 +1391,39 @@ sub process {
1371 ERROR("trailing whitespace\n" . $herevet); 1391 ERROR("trailing whitespace\n" . $herevet);
1372 } 1392 }
1373 1393
1394# check for Kconfig help text having a real description
1395 if ($realfile =~ /Kconfig/ &&
1396 $line =~ /\+?\s*(---)?help(---)?$/) {
1397 my $length = 0;
1398 for (my $l = $linenr; defined($lines[$l]); $l++) {
1399 my $f = $lines[$l];
1400 $f =~ s/#.*//;
1401 $f =~ s/^\s+//;
1402 next if ($f =~ /^$/);
1403 last if ($f =~ /^\s*config\s/);
1404 $length++;
1405 }
1406 WARN("please write a paragraph that describes the config symbol fully\n" . $herecurr) if ($length < 4);
1407 }
1408
1374# check we are in a valid source file if not then ignore this hunk 1409# check we are in a valid source file if not then ignore this hunk
1375 next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/); 1410 next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);
1376 1411
1377#80 column limit 1412#80 column limit
1378 if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && 1413 if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
1379 $rawline !~ /^.\s*\*\s*\@$Ident\s/ && 1414 $rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
1380 $line !~ /^\+\s*printk\s*\(\s*(?:KERN_\S+\s*)?"[X\t]*"\s*(?:,|\)\s*;)\s*$/ && 1415 !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:,|\)\s*;)\s*$/ ||
1416 $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
1381 $length > 80) 1417 $length > 80)
1382 { 1418 {
1383 WARN("line over 80 characters\n" . $herecurr); 1419 WARN("line over 80 characters\n" . $herecurr);
1384 } 1420 }
1385 1421
1422# check for spaces before a quoted newline
1423 if ($rawline =~ /^.*\".*\s\\n/) {
1424 WARN("unnecessary whitespace before a quoted newline\n" . $herecurr);
1425 }
1426
1386# check for adding lines without a newline. 1427# check for adding lines without a newline.
1387 if ($line =~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =~ /^\\ No newline at end of file/) { 1428 if ($line =~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =~ /^\\ No newline at end of file/) {
1388 WARN("adding a line without newline at end of file\n" . $herecurr); 1429 WARN("adding a line without newline at end of file\n" . $herecurr);
@@ -1411,6 +1452,19 @@ sub process {
1411 ERROR("code indent should use tabs where possible\n" . $herevet); 1452 ERROR("code indent should use tabs where possible\n" . $herevet);
1412 } 1453 }
1413 1454
1455# check for space before tabs.
1456 if ($rawline =~ /^\+/ && $rawline =~ / \t/) {
1457 my $herevet = "$here\n" . cat_vet($rawline) . "\n";
1458 WARN("please, no space before tabs\n" . $herevet);
1459 }
1460
1461# check for spaces at the beginning of a line.
1462 if ($rawline =~ /^\+ / && $rawline !~ /\+ +\*/) {
1463 my $herevet = "$here\n" . cat_vet($rawline) . "\n";
1464 WARN("please, no space for starting a line, \
1465 excluding comments\n" . $herevet);
1466 }
1467
1414# check we are in a valid C source file if not then ignore this hunk 1468# check we are in a valid C source file if not then ignore this hunk
1415 next if ($realfile !~ /\.(h|c)$/); 1469 next if ($realfile !~ /\.(h|c)$/);
1416 1470
@@ -1741,9 +1795,9 @@ sub process {
1741 WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr); 1795 WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr);
1742 } 1796 }
1743 1797
1744# check for external initialisers. 1798# check for global initialisers.
1745 if ($line =~ /^.$Type\s*$Ident\s*(?:\s+$Modifier)*\s*=\s*(0|NULL|false)\s*;/) { 1799 if ($line =~ /^.$Type\s*$Ident\s*(?:\s+$Modifier)*\s*=\s*(0|NULL|false)\s*;/) {
1746 ERROR("do not initialise externals to 0 or NULL\n" . 1800 ERROR("do not initialise globals to 0 or NULL\n" .
1747 $herecurr); 1801 $herecurr);
1748 } 1802 }
1749# check for static initialisers. 1803# check for static initialisers.
@@ -2182,8 +2236,10 @@ sub process {
2182 # Find out how long the conditional actually is. 2236 # Find out how long the conditional actually is.
2183 my @newlines = ($c =~ /\n/gs); 2237 my @newlines = ($c =~ /\n/gs);
2184 my $cond_lines = 1 + $#newlines; 2238 my $cond_lines = 1 + $#newlines;
2239 my $stat_real = '';
2185 2240
2186 my $stat_real = raw_line($linenr, $cond_lines); 2241 $stat_real = raw_line($linenr, $cond_lines)
2242 . "\n" if ($cond_lines);
2187 if (defined($stat_real) && $cond_lines > 1) { 2243 if (defined($stat_real) && $cond_lines > 1) {
2188 $stat_real = "[...]\n$stat_real"; 2244 $stat_real = "[...]\n$stat_real";
2189 } 2245 }
@@ -2269,7 +2325,7 @@ sub process {
2269 my $checkfile = "include/linux/$file"; 2325 my $checkfile = "include/linux/$file";
2270 if (-f "$root/$checkfile" && 2326 if (-f "$root/$checkfile" &&
2271 $realfile ne $checkfile && 2327 $realfile ne $checkfile &&
2272 $1 ne 'irq') 2328 $1 !~ /$allowed_asm_includes/)
2273 { 2329 {
2274 if ($realfile =~ m{^arch/}) { 2330 if ($realfile =~ m{^arch/}) {
2275 CHK("Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr); 2331 CHK("Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
@@ -2348,6 +2404,8 @@ sub process {
2348 DECLARE_PER_CPU| 2404 DECLARE_PER_CPU|
2349 DEFINE_PER_CPU| 2405 DEFINE_PER_CPU|
2350 __typeof__\(| 2406 __typeof__\(|
2407 union|
2408 struct|
2351 \.$Ident\s*=\s*| 2409 \.$Ident\s*=\s*|
2352 ^\"|\"$ 2410 ^\"|\"$
2353 }x; 2411 }x;
@@ -2529,6 +2587,21 @@ sub process {
2529 } 2587 }
2530 } 2588 }
2531 2589
2590# prefer usleep_range over udelay
2591 if ($line =~ /\budelay\s*\(\s*(\w+)\s*\)/) {
2592 # ignore udelay's < 10, however
2593 if (! (($1 =~ /(\d+)/) && ($1 < 10)) ) {
2594 CHK("usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt\n" . $line);
2595 }
2596 }
2597
2598# warn about unexpectedly long msleep's
2599 if ($line =~ /\bmsleep\s*\((\d+)\);/) {
2600 if ($1 < 20) {
2601 WARN("msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt\n" . $line);
2602 }
2603 }
2604
2532# warn about #ifdefs in C files 2605# warn about #ifdefs in C files
2533# if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) { 2606# if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) {
2534# print "#ifdef in C files should be avoided\n"; 2607# print "#ifdef in C files should be avoided\n";
@@ -2560,6 +2633,11 @@ sub process {
2560 CHK("architecture specific defines should be avoided\n" . $herecurr); 2633 CHK("architecture specific defines should be avoided\n" . $herecurr);
2561 } 2634 }
2562 2635
2636# Check that the storage class is at the beginning of a declaration
2637 if ($line =~ /\b$Storage\b/ && $line !~ /^.\s*$Storage\b/) {
2638 WARN("storage class should be at the beginning of the declaration\n" . $herecurr)
2639 }
2640
2563# check the location of the inline attribute, that it is between 2641# check the location of the inline attribute, that it is between
2564# storage class and type. 2642# storage class and type.
2565 if ($line =~ /\b$Type\s+$Inline\b/ || 2643 if ($line =~ /\b$Type\s+$Inline\b/ ||
@@ -2572,6 +2650,11 @@ sub process {
2572 WARN("plain inline is preferred over $1\n" . $herecurr); 2650 WARN("plain inline is preferred over $1\n" . $herecurr);
2573 } 2651 }
2574 2652
2653# check for sizeof(&)
2654 if ($line =~ /\bsizeof\s*\(\s*\&/) {
2655 WARN("sizeof(& should be avoided\n" . $herecurr);
2656 }
2657
2575# check for new externs in .c files. 2658# check for new externs in .c files.
2576 if ($realfile =~ /\.c$/ && defined $stat && 2659 if ($realfile =~ /\.c$/ && defined $stat &&
2577 $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) 2660 $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s)
@@ -2625,6 +2708,7 @@ sub process {
2625# check for semaphores used as mutexes 2708# check for semaphores used as mutexes
2626 if ($line =~ /^.\s*init_MUTEX_LOCKED\s*\(/) { 2709 if ($line =~ /^.\s*init_MUTEX_LOCKED\s*\(/) {
2627 WARN("consider using a completion\n" . $herecurr); 2710 WARN("consider using a completion\n" . $herecurr);
2711
2628 } 2712 }
2629# recommend strict_strto* over simple_strto* 2713# recommend strict_strto* over simple_strto*
2630 if ($line =~ /\bsimple_(strto.*?)\s*\(/) { 2714 if ($line =~ /\bsimple_(strto.*?)\s*\(/) {
@@ -2634,9 +2718,46 @@ sub process {
2634 if ($line =~ /^.\s*__initcall\s*\(/) { 2718 if ($line =~ /^.\s*__initcall\s*\(/) {
2635 WARN("please use device_initcall() instead of __initcall()\n" . $herecurr); 2719 WARN("please use device_initcall() instead of __initcall()\n" . $herecurr);
2636 } 2720 }
2637# check for struct file_operations, ensure they are const. 2721# check for various ops structs, ensure they are const.
2722 my $struct_ops = qr{acpi_dock_ops|
2723 address_space_operations|
2724 backlight_ops|
2725 block_device_operations|
2726 dentry_operations|
2727 dev_pm_ops|
2728 dma_map_ops|
2729 extent_io_ops|
2730 file_lock_operations|
2731 file_operations|
2732 hv_ops|
2733 ide_dma_ops|
2734 intel_dvo_dev_ops|
2735 item_operations|
2736 iwl_ops|
2737 kgdb_arch|
2738 kgdb_io|
2739 kset_uevent_ops|
2740 lock_manager_operations|
2741 microcode_ops|
2742 mtrr_ops|
2743 neigh_ops|
2744 nlmsvc_binding|
2745 pci_raw_ops|
2746 pipe_buf_operations|
2747 platform_hibernation_ops|
2748 platform_suspend_ops|
2749 proto_ops|
2750 rpc_pipe_ops|
2751 seq_operations|
2752 snd_ac97_build_ops|
2753 soc_pcmcia_socket_ops|
2754 stacktrace_ops|
2755 sysfs_ops|
2756 tty_operations|
2757 usb_mon_operations|
2758 wd_ops}x;
2638 if ($line !~ /\bconst\b/ && 2759 if ($line !~ /\bconst\b/ &&
2639 $line =~ /\bstruct\s+(file_operations|seq_operations)\b/) { 2760 $line =~ /\bstruct\s+($struct_ops)\b/) {
2640 WARN("struct $1 should normally be const\n" . 2761 WARN("struct $1 should normally be const\n" .
2641 $herecurr); 2762 $herecurr);
2642 } 2763 }
@@ -2672,6 +2793,16 @@ sub process {
2672 WARN("use of in_atomic() is incorrect outside core kernel code\n" . $herecurr); 2793 WARN("use of in_atomic() is incorrect outside core kernel code\n" . $herecurr);
2673 } 2794 }
2674 } 2795 }
2796
2797# check for lockdep_set_novalidate_class
2798 if ($line =~ /^.\s*lockdep_set_novalidate_class\s*\(/ ||
2799 $line =~ /__lockdep_no_validate__\s*\)/ ) {
2800 if ($realfile !~ m@^kernel/lockdep@ &&
2801 $realfile !~ m@^include/linux/lockdep@ &&
2802 $realfile !~ m@^drivers/base/core@) {
2803 ERROR("lockdep_no_validate class is reserved for device->mutex.\n" . $herecurr);
2804 }
2805 }
2675 } 2806 }
2676 2807
2677 # If we have no input at all, then there is nothing to report on 2808 # If we have no input at all, then there is nothing to report on
diff --git a/scripts/checksyscalls.sh b/scripts/checksyscalls.sh
index 66ad375612f2..6bb42e72e0e5 100755
--- a/scripts/checksyscalls.sh
+++ b/scripts/checksyscalls.sh
@@ -183,7 +183,6 @@ cat << EOF
183#define __IGNORE_ustat /* statfs */ 183#define __IGNORE_ustat /* statfs */
184#define __IGNORE_utime /* utimes */ 184#define __IGNORE_utime /* utimes */
185#define __IGNORE_vfork /* clone */ 185#define __IGNORE_vfork /* clone */
186#define __IGNORE_wait4 /* waitid */
187 186
188/* sync_file_range had a stupid ABI. Allow sync_file_range2 instead */ 187/* sync_file_range had a stupid ABI. Allow sync_file_range2 instead */
189#ifdef __NR_sync_file_range2 188#ifdef __NR_sync_file_range2
diff --git a/scripts/extract-ikconfig b/scripts/extract-ikconfig
index de233ff43c1c..37f30d36c944 100755
--- a/scripts/extract-ikconfig
+++ b/scripts/extract-ikconfig
@@ -1,92 +1,53 @@
1#!/bin/sh 1#!/bin/sh
2# extracts .config info from a [b]zImage file 2# ----------------------------------------------------------------------
3# uses: binoffset (new), dd, zcat, strings, grep 3# extract-ikconfig - Extract the .config file from a kernel image
4# $arg1 is [b]zImage filename 4#
5 5# This will only work when the kernel was compiled with CONFIG_IKCONFIG.
6binoffset="./scripts/binoffset" 6#
7test -e $binoffset || cc -o $binoffset ./scripts/binoffset.c || exit 1 7# The obscure use of the "tr" filter is to work around older versions of
8 8# "grep" that report the byte offset of the line instead of the pattern.
9IKCFG_ST="0x49 0x4b 0x43 0x46 0x47 0x5f 0x53 0x54" 9#
10IKCFG_ED="0x49 0x4b 0x43 0x46 0x47 0x5f 0x45 0x44" 10# (c) 2009, Dick Streefland <dick@streefland.net>
11dump_config() { 11# Licensed under the terms of the GNU General Public License.
12 file="$1" 12# ----------------------------------------------------------------------
13 13
14 start=`$binoffset $file $IKCFG_ST 2>/dev/null` 14gz1='\037\213\010'
15 [ "$?" != "0" ] && start="-1" 15gz2='01'
16 if [ "$start" -eq "-1" ]; then 16cf1='IKCFG_ST\037\213\010'
17 return 17cf2='0123456789'
18 fi 18
19 end=`$binoffset $file $IKCFG_ED 2>/dev/null` 19dump_config()
20 [ "$?" != "0" ] && end="-1"
21 if [ "$end" -eq "-1" ]; then
22 return
23 fi
24
25 start=`expr $start + 8`
26 size=`expr $end - $start`
27
28 dd if="$file" ibs=1 skip="$start" count="$size" 2>/dev/null | zcat
29
30 clean_up
31 exit 0
32}
33
34
35usage()
36{
37 echo " usage: extract-ikconfig [b]zImage_filename"
38}
39
40clean_up()
41{ 20{
42 if [ "$TMPFILE" != "" ]; then 21 if pos=`tr "$cf1\n$cf2" "\n$cf2=" < "$1" | grep -abo "^$cf2"`
43 rm -f $TMPFILE 22 then
23 pos=${pos%%:*}
24 tail -c+$(($pos+8)) "$1" | zcat -q
25 exit 0
44 fi 26 fi
45} 27}
46 28
47if [ $# -lt 1 ] 29# Check invocation:
30me=${0##*/}
31img=$1
32if [ $# -ne 1 -o ! -s "$img" ]
48then 33then
49 usage 34 echo "Usage: $me <kernel-image>" >&2
50 exit 1 35 exit 2
51fi 36fi
52 37
53TMPFILE=`mktemp -t ikconfig-XXXXXX` || exit 1 38# Initial attempt for uncompressed images or objects:
54image="$1" 39dump_config "$img"
55 40
56# vmlinux: Attempt to dump the configuration from the file directly 41# That didn't work, so decompress and try again:
57dump_config "$image" 42tmp=/tmp/ikconfig$$
58 43trap "rm -f $tmp" 0
59GZHDR1="0x1f 0x8b 0x08 0x00" 44for pos in `tr "$gz1\n$gz2" "\n$gz2=" < "$img" | grep -abo "^$gz2"`
60GZHDR2="0x1f 0x8b 0x08 0x08" 45do
61 46 pos=${pos%%:*}
62ELFHDR="0x7f 0x45 0x4c 0x46" 47 tail -c+$pos "$img" | zcat 2> /dev/null > $tmp
63 48 dump_config $tmp
64# vmlinux.gz: Check for a compressed images 49done
65off=`$binoffset "$image" $GZHDR1 2>/dev/null` 50
66[ "$?" != "0" ] && off="-1" 51# Bail out:
67if [ "$off" -eq "-1" ]; then 52echo "$me: Cannot find kernel config." >&2
68 off=`$binoffset "$image" $GZHDR2 2>/dev/null`
69 [ "$?" != "0" ] && off="-1"
70fi
71if [ "$off" -eq "0" ]; then
72 zcat <"$image" >"$TMPFILE"
73 dump_config "$TMPFILE"
74elif [ "$off" -ne "-1" ]; then
75 (dd ibs="$off" skip=1 count=0 && dd bs=512k) <"$image" 2>/dev/null | \
76 zcat >"$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
86fi
87
88echo "ERROR: Unable to extract kernel configuration information."
89echo " This kernel image may not have the config info."
90
91clean_up
92exit 1 53exit 1
diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
index f3b5c05ced40..5958fffb2114 100644
--- a/scripts/gen_initramfs_list.sh
+++ b/scripts/gen_initramfs_list.sh
@@ -243,6 +243,7 @@ case "$arg" in
243 echo "$output_file" | grep -q "\.gz$" && compr="gzip -9 -f" 243 echo "$output_file" | grep -q "\.gz$" && compr="gzip -9 -f"
244 echo "$output_file" | grep -q "\.bz2$" && compr="bzip2 -9 -f" 244 echo "$output_file" | grep -q "\.bz2$" && compr="bzip2 -9 -f"
245 echo "$output_file" | grep -q "\.lzma$" && compr="lzma -9 -f" 245 echo "$output_file" | grep -q "\.lzma$" && compr="lzma -9 -f"
246 echo "$output_file" | grep -q "\.lzo$" && compr="lzop -9 -f"
246 echo "$output_file" | grep -q "\.cpio$" && compr="cat" 247 echo "$output_file" | grep -q "\.cpio$" && compr="cat"
247 shift 248 shift
248 ;; 249 ;;
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index 090f24839700..b2281982f52f 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.23'; 16my $V = '0.24';
17 17
18use Getopt::Long qw(:config no_auto_abbrev); 18use Getopt::Long qw(:config no_auto_abbrev);
19 19
@@ -25,6 +25,7 @@ my $email_list = 1;
25my $email_subscriber_list = 0; 25my $email_subscriber_list = 0;
26my $email_git_penguin_chiefs = 0; 26my $email_git_penguin_chiefs = 0;
27my $email_git = 1; 27my $email_git = 1;
28my $email_git_all_signature_types = 0;
28my $email_git_blame = 0; 29my $email_git_blame = 0;
29my $email_git_min_signatures = 1; 30my $email_git_min_signatures = 1;
30my $email_git_max_maintainers = 5; 31my $email_git_max_maintainers = 5;
@@ -41,6 +42,8 @@ my $web = 0;
41my $subsystem = 0; 42my $subsystem = 0;
42my $status = 0; 43my $status = 0;
43my $keywords = 1; 44my $keywords = 1;
45my $sections = 0;
46my $file_emails = 0;
44my $from_filename = 0; 47my $from_filename = 0;
45my $pattern_depth = 0; 48my $pattern_depth = 0;
46my $version = 0; 49my $version = 0;
@@ -49,9 +52,9 @@ my $help = 0;
49my $exit = 0; 52my $exit = 0;
50 53
51my @penguin_chief = (); 54my @penguin_chief = ();
52push(@penguin_chief,"Linus Torvalds:torvalds\@linux-foundation.org"); 55push(@penguin_chief, "Linus Torvalds:torvalds\@linux-foundation.org");
53#Andrew wants in on most everything - 2009/01/14 56#Andrew wants in on most everything - 2009/01/14
54#push(@penguin_chief,"Andrew Morton:akpm\@linux-foundation.org"); 57#push(@penguin_chief, "Andrew Morton:akpm\@linux-foundation.org");
55 58
56my @penguin_chief_names = (); 59my @penguin_chief_names = ();
57foreach my $chief (@penguin_chief) { 60foreach my $chief (@penguin_chief) {
@@ -61,7 +64,16 @@ foreach my $chief (@penguin_chief) {
61 push(@penguin_chief_names, $chief_name); 64 push(@penguin_chief_names, $chief_name);
62 } 65 }
63} 66}
64my $penguin_chiefs = "\(" . join("|",@penguin_chief_names) . "\)"; 67my $penguin_chiefs = "\(" . join("|", @penguin_chief_names) . "\)";
68
69# Signature types of people who are either
70# a) responsible for the code in question, or
71# b) familiar enough with it to give relevant feedback
72my @signature_tags = ();
73push(@signature_tags, "Signed-off-by:");
74push(@signature_tags, "Reviewed-by:");
75push(@signature_tags, "Acked-by:");
76my $signaturePattern = "\(" . join("|", @signature_tags) . "\)";
65 77
66# rfc822 email address - preloaded methods go here. 78# rfc822 email address - preloaded methods go here.
67my $rfc822_lwsp = "(?:(?:\\r\\n)?[ \\t])"; 79my $rfc822_lwsp = "(?:(?:\\r\\n)?[ \\t])";
@@ -74,8 +86,8 @@ my %VCS_cmds;
74my %VCS_cmds_git = ( 86my %VCS_cmds_git = (
75 "execute_cmd" => \&git_execute_cmd, 87 "execute_cmd" => \&git_execute_cmd,
76 "available" => '(which("git") ne "") && (-d ".git")', 88 "available" => '(which("git") ne "") && (-d ".git")',
77 "find_signers_cmd" => "git log --since=\$email_git_since -- \$file", 89 "find_signers_cmd" => "git log --no-color --since=\$email_git_since -- \$file",
78 "find_commit_signers_cmd" => "git log -1 \$commit", 90 "find_commit_signers_cmd" => "git log --no-color -1 \$commit",
79 "blame_range_cmd" => "git blame -l -L \$diff_start,+\$diff_length \$file", 91 "blame_range_cmd" => "git blame -l -L \$diff_start,+\$diff_length \$file",
80 "blame_file_cmd" => "git blame -l \$file", 92 "blame_file_cmd" => "git blame -l \$file",
81 "commit_pattern" => "^commit [0-9a-f]{40,40}", 93 "commit_pattern" => "^commit [0-9a-f]{40,40}",
@@ -95,9 +107,34 @@ my %VCS_cmds_hg = (
95 "blame_commit_pattern" => "^([0-9a-f]+):" 107 "blame_commit_pattern" => "^([0-9a-f]+):"
96); 108);
97 109
110if (-f "${lk_path}.get_maintainer.conf") {
111 my @conf_args;
112 open(my $conffile, '<', "${lk_path}.get_maintainer.conf")
113 or warn "$P: Can't open .get_maintainer.conf: $!\n";
114 while (<$conffile>) {
115 my $line = $_;
116
117 $line =~ s/\s*\n?$//g;
118 $line =~ s/^\s*//g;
119 $line =~ s/\s+/ /g;
120
121 next if ($line =~ m/^\s*#/);
122 next if ($line =~ m/^\s*$/);
123
124 my @words = split(" ", $line);
125 foreach my $word (@words) {
126 last if ($word =~ m/^#/);
127 push (@conf_args, $word);
128 }
129 }
130 close($conffile);
131 unshift(@ARGV, @conf_args) if @conf_args;
132}
133
98if (!GetOptions( 134if (!GetOptions(
99 'email!' => \$email, 135 'email!' => \$email,
100 'git!' => \$email_git, 136 'git!' => \$email_git,
137 'git-all-signature-types!' => \$email_git_all_signature_types,
101 'git-blame!' => \$email_git_blame, 138 'git-blame!' => \$email_git_blame,
102 'git-chief-penguins!' => \$email_git_penguin_chiefs, 139 'git-chief-penguins!' => \$email_git_penguin_chiefs,
103 'git-min-signatures=i' => \$email_git_min_signatures, 140 'git-min-signatures=i' => \$email_git_min_signatures,
@@ -120,9 +157,11 @@ if (!GetOptions(
120 'web!' => \$web, 157 'web!' => \$web,
121 'pattern-depth=i' => \$pattern_depth, 158 'pattern-depth=i' => \$pattern_depth,
122 'k|keywords!' => \$keywords, 159 'k|keywords!' => \$keywords,
160 'sections!' => \$sections,
161 'fe|file-emails!' => \$file_emails,
123 'f|file' => \$from_filename, 162 'f|file' => \$from_filename,
124 'v|version' => \$version, 163 'v|version' => \$version,
125 'h|help' => \$help, 164 'h|help|usage' => \$help,
126 )) { 165 )) {
127 die "$P: invalid argument - use --help if necessary\n"; 166 die "$P: invalid argument - use --help if necessary\n";
128} 167}
@@ -137,9 +176,9 @@ if ($version != 0) {
137 exit 0; 176 exit 0;
138} 177}
139 178
140if ($#ARGV < 0) { 179if (-t STDIN && !@ARGV) {
141 usage(); 180 # We're talking to a terminal, but have no command line arguments.
142 die "$P: argument missing: patchfile or -f file please\n"; 181 die "$P: missing patchfile or -f file - use --help if necessary\n";
143} 182}
144 183
145if ($output_separator ne ", ") { 184if ($output_separator ne ", ") {
@@ -150,16 +189,24 @@ if ($output_rolestats) {
150 $output_roles = 1; 189 $output_roles = 1;
151} 190}
152 191
153my $selections = $email + $scm + $status + $subsystem + $web; 192if ($sections) {
154if ($selections == 0) { 193 $email = 0;
155 usage(); 194 $email_list = 0;
156 die "$P: Missing required option: email, scm, status, subsystem or web\n"; 195 $scm = 0;
196 $status = 0;
197 $subsystem = 0;
198 $web = 0;
199 $keywords = 0;
200} else {
201 my $selections = $email + $scm + $status + $subsystem + $web;
202 if ($selections == 0) {
203 die "$P: Missing required option: email, scm, status, subsystem or web\n";
204 }
157} 205}
158 206
159if ($email && 207if ($email &&
160 ($email_maintainer + $email_list + $email_subscriber_list + 208 ($email_maintainer + $email_list + $email_subscriber_list +
161 $email_git + $email_git_penguin_chiefs + $email_git_blame) == 0) { 209 $email_git + $email_git_penguin_chiefs + $email_git_blame) == 0) {
162 usage();
163 die "$P: Please select at least 1 email option\n"; 210 die "$P: Please select at least 1 email option\n";
164} 211}
165 212
@@ -168,13 +215,18 @@ if (!top_of_kernel_tree($lk_path)) {
168 . "a linux kernel source tree.\n"; 215 . "a linux kernel source tree.\n";
169} 216}
170 217
218if ($email_git_all_signature_types) {
219 $signaturePattern = "(.+?)[Bb][Yy]:";
220}
221
171## Read MAINTAINERS for type/value pairs 222## Read MAINTAINERS for type/value pairs
172 223
173my @typevalue = (); 224my @typevalue = ();
174my %keyword_hash; 225my %keyword_hash;
175 226
176open(MAINT, "<${lk_path}MAINTAINERS") || die "$P: Can't open MAINTAINERS\n"; 227open (my $maint, '<', "${lk_path}MAINTAINERS")
177while (<MAINT>) { 228 or die "$P: Can't open MAINTAINERS: $!\n";
229while (<$maint>) {
178 my $line = $_; 230 my $line = $_;
179 231
180 if ($line =~ m/^(\C):\s*(.*)/) { 232 if ($line =~ m/^(\C):\s*(.*)/) {
@@ -199,13 +251,14 @@ while (<MAINT>) {
199 push(@typevalue, $line); 251 push(@typevalue, $line);
200 } 252 }
201} 253}
202close(MAINT); 254close($maint);
203 255
204my %mailmap; 256my %mailmap;
205 257
206if ($email_remove_duplicates) { 258if ($email_remove_duplicates) {
207 open(MAILMAP, "<${lk_path}.mailmap") || warn "$P: Can't open .mailmap\n"; 259 open(my $mailmap, '<', "${lk_path}.mailmap")
208 while (<MAILMAP>) { 260 or warn "$P: Can't open .mailmap: $!\n";
261 while (<$mailmap>) {
209 my $line = $_; 262 my $line = $_;
210 263
211 next if ($line =~ m/^\s*#/); 264 next if ($line =~ m/^\s*#/);
@@ -224,7 +277,7 @@ if ($email_remove_duplicates) {
224 $mailmap{$name} = \@arr; 277 $mailmap{$name} = \@arr;
225 } 278 }
226 } 279 }
227 close(MAILMAP); 280 close($mailmap);
228} 281}
229 282
230## use the filenames on the command line or find the filenames in the patchfiles 283## use the filenames on the command line or find the filenames in the patchfiles
@@ -232,31 +285,47 @@ if ($email_remove_duplicates) {
232my @files = (); 285my @files = ();
233my @range = (); 286my @range = ();
234my @keyword_tvi = (); 287my @keyword_tvi = ();
288my @file_emails = ();
289
290if (!@ARGV) {
291 push(@ARGV, "&STDIN");
292}
235 293
236foreach my $file (@ARGV) { 294foreach my $file (@ARGV) {
237 ##if $file is a directory and it lacks a trailing slash, add one 295 if ($file ne "&STDIN") {
238 if ((-d $file)) { 296 ##if $file is a directory and it lacks a trailing slash, add one
239 $file =~ s@([^/])$@$1/@; 297 if ((-d $file)) {
240 } elsif (!(-f $file)) { 298 $file =~ s@([^/])$@$1/@;
241 die "$P: file '${file}' not found\n"; 299 } elsif (!(-f $file)) {
300 die "$P: file '${file}' not found\n";
301 }
242 } 302 }
243 if ($from_filename) { 303 if ($from_filename) {
244 push(@files, $file); 304 push(@files, $file);
245 if (-f $file && $keywords) { 305 if (-f $file && ($keywords || $file_emails)) {
246 open(FILE, "<$file") or die "$P: Can't open ${file}\n"; 306 open(my $f, '<', $file)
247 my $text = do { local($/) ; <FILE> }; 307 or die "$P: Can't open $file: $!\n";
248 foreach my $line (keys %keyword_hash) { 308 my $text = do { local($/) ; <$f> };
249 if ($text =~ m/$keyword_hash{$line}/x) { 309 close($f);
250 push(@keyword_tvi, $line); 310 if ($keywords) {
311 foreach my $line (keys %keyword_hash) {
312 if ($text =~ m/$keyword_hash{$line}/x) {
313 push(@keyword_tvi, $line);
314 }
251 } 315 }
252 } 316 }
253 close(FILE); 317 if ($file_emails) {
318 my @poss_addr = $text =~ m$[A-Za-zÀ-ÿ\"\' \,\.\+-]*\s*[\,]*\s*[\(\<\{]{0,1}[A-Za-z0-9_\.\+-]+\@[A-Za-z0-9\.-]+\.[A-Za-z0-9]+[\)\>\}]{0,1}$g;
319 push(@file_emails, clean_file_emails(@poss_addr));
320 }
254 } 321 }
255 } else { 322 } else {
256 my $file_cnt = @files; 323 my $file_cnt = @files;
257 my $lastfile; 324 my $lastfile;
258 open(PATCH, "<$file") or die "$P: Can't open ${file}\n"; 325
259 while (<PATCH>) { 326 open(my $patch, "< $file")
327 or die "$P: Can't open $file: $!\n";
328 while (<$patch>) {
260 my $patch_line = $_; 329 my $patch_line = $_;
261 if (m/^\+\+\+\s+(\S+)/) { 330 if (m/^\+\+\+\s+(\S+)/) {
262 my $filename = $1; 331 my $filename = $1;
@@ -276,7 +345,8 @@ foreach my $file (@ARGV) {
276 } 345 }
277 } 346 }
278 } 347 }
279 close(PATCH); 348 close($patch);
349
280 if ($file_cnt == @files) { 350 if ($file_cnt == @files) {
281 warn "$P: file '${file}' doesn't appear to be a patch. " 351 warn "$P: file '${file}' doesn't appear to be a patch. "
282 . "Add -f to options?\n"; 352 . "Add -f to options?\n";
@@ -285,6 +355,8 @@ foreach my $file (@ARGV) {
285 } 355 }
286} 356}
287 357
358@file_emails = uniq(@file_emails);
359
288my @email_to = (); 360my @email_to = ();
289my @list_to = (); 361my @list_to = ();
290my @scm = (); 362my @scm = ();
@@ -314,6 +386,7 @@ foreach my $file (@files) {
314 if ($type eq 'X') { 386 if ($type eq 'X') {
315 if (file_match_pattern($file, $value)) { 387 if (file_match_pattern($file, $value)) {
316 $exclude = 1; 388 $exclude = 1;
389 last;
317 } 390 }
318 } 391 }
319 } 392 }
@@ -340,12 +413,28 @@ foreach my $file (@files) {
340 } 413 }
341 } 414 }
342 415
343 $tvi += ($end - $start); 416 $tvi = $end + 1;
344
345 } 417 }
346 418
347 foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) { 419 foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) {
348 add_categories($line); 420 add_categories($line);
421 if ($sections) {
422 my $i;
423 my $start = find_starting_index($line);
424 my $end = find_ending_index($line);
425 for ($i = $start; $i < $end; $i++) {
426 my $line = $typevalue[$i];
427 if ($line =~ /^[FX]:/) { ##Restore file patterns
428 $line =~ s/([^\\])\.([^\*])/$1\?$2/g;
429 $line =~ s/([^\\])\.$/$1\?/g; ##Convert . back to ?
430 $line =~ s/\\\./\./g; ##Convert \. to .
431 $line =~ s/\.\*/\*/g; ##Convert .* to *
432 }
433 $line =~ s/^([A-Z]):/$1:\t/g;
434 print("$line\n");
435 }
436 print("\n");
437 }
349 } 438 }
350 439
351 if ($email && $email_git) { 440 if ($email && $email_git) {
@@ -377,6 +466,14 @@ if ($email) {
377 } 466 }
378 } 467 }
379 } 468 }
469
470 foreach my $email (@file_emails) {
471 my ($name, $address) = parse_email($email);
472
473 my $tmp_email = format_email($name, $address, $email_usename);
474 push_email_address($tmp_email, '');
475 add_role($tmp_email, 'in file');
476 }
380} 477}
381 478
382if ($email || $email_list) { 479if ($email || $email_list) {
@@ -439,13 +536,15 @@ version: $V
439MAINTAINER field selection options: 536MAINTAINER field selection options:
440 --email => print email address(es) if any 537 --email => print email address(es) if any
441 --git => include recent git \*-by: signers 538 --git => include recent git \*-by: signers
539 --git-all-signature-types => include signers regardless of signature type
540 or use only ${signaturePattern} signers (default: $email_git_all_signature_types)
442 --git-chief-penguins => include ${penguin_chiefs} 541 --git-chief-penguins => include ${penguin_chiefs}
443 --git-min-signatures => number of signatures required (default: 1) 542 --git-min-signatures => number of signatures required (default: $email_git_min_signatures)
444 --git-max-maintainers => maximum maintainers to add (default: 5) 543 --git-max-maintainers => maximum maintainers to add (default: $email_git_max_maintainers)
445 --git-min-percent => minimum percentage of commits required (default: 5) 544 --git-min-percent => minimum percentage of commits required (default: $email_git_min_percent)
446 --git-blame => use git blame to find modified commits for patch or file 545 --git-blame => use git blame to find modified commits for patch or file
447 --git-since => git history to use (default: 1-year-ago) 546 --git-since => git history to use (default: $email_git_since)
448 --hg-since => hg history to use (default: -365) 547 --hg-since => hg history to use (default: $email_hg_since)
449 --m => include maintainer(s) if any 548 --m => include maintainer(s) if any
450 --n => include name 'Full Name <addr\@domain.tld>' 549 --n => include name 'Full Name <addr\@domain.tld>'
451 --l => include list(s) if any 550 --l => include list(s) if any
@@ -453,6 +552,7 @@ MAINTAINER field selection options:
453 --remove-duplicates => minimize duplicate email names/addresses 552 --remove-duplicates => minimize duplicate email names/addresses
454 --roles => show roles (status:subsystem, git-signer, list, etc...) 553 --roles => show roles (status:subsystem, git-signer, list, etc...)
455 --rolestats => show roles and statistics (commits/total_commits, %) 554 --rolestats => show roles and statistics (commits/total_commits, %)
555 --file-emails => add email addresses found in -f file (default: 0 (off))
456 --scm => print SCM tree(s) if any 556 --scm => print SCM tree(s) if any
457 --status => print status if any 557 --status => print status if any
458 --subsystem => print subsystem name if any 558 --subsystem => print subsystem name if any
@@ -466,6 +566,7 @@ Output type options:
466Other options: 566Other options:
467 --pattern-depth => Number of pattern directory traversals (default: 0 (all)) 567 --pattern-depth => Number of pattern directory traversals (default: 0 (all))
468 --keywords => scan patch for keywords (default: 1 (on)) 568 --keywords => scan patch for keywords (default: 1 (on))
569 --sections => print the entire subsystem sections with pattern matches
469 --version => show version 570 --version => show version
470 --help => show this help information 571 --help => show this help information
471 572
@@ -496,6 +597,11 @@ Notes:
496 --git-min-signatures, --git-max-maintainers, --git-min-percent, and 597 --git-min-signatures, --git-max-maintainers, --git-min-percent, and
497 --git-blame 598 --git-blame
498 Use --hg-since not --git-since to control date selection 599 Use --hg-since not --git-since to control date selection
600 File ".get_maintainer.conf", if it exists in the linux kernel source root
601 directory, can change whatever get_maintainer defaults are desired.
602 Entries in this file can be any command line argument.
603 This file is prepended to any additional command line arguments.
604 Multiple lines and # comments are allowed.
499EOT 605EOT
500} 606}
501 607
@@ -545,7 +651,7 @@ sub parse_email {
545 $name =~ s/^\"|\"$//g; 651 $name =~ s/^\"|\"$//g;
546 $address =~ s/^\s+|\s+$//g; 652 $address =~ s/^\s+|\s+$//g;
547 653
548 if ($name =~ /[^a-z0-9 \.\-]/i) { ##has "must quote" chars 654 if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
549 $name =~ s/(?<!\\)"/\\"/g; ##escape quotes 655 $name =~ s/(?<!\\)"/\\"/g; ##escape quotes
550 $name = "\"$name\""; 656 $name = "\"$name\"";
551 } 657 }
@@ -562,7 +668,7 @@ sub format_email {
562 $name =~ s/^\"|\"$//g; 668 $name =~ s/^\"|\"$//g;
563 $address =~ s/^\s+|\s+$//g; 669 $address =~ s/^\s+|\s+$//g;
564 670
565 if ($name =~ /[^a-z0-9 \.\-]/i) { ##has "must quote" chars 671 if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
566 $name =~ s/(?<!\\)"/\\"/g; ##escape quotes 672 $name =~ s/(?<!\\)"/\\"/g; ##escape quotes
567 $name = "\"$name\""; 673 $name = "\"$name\"";
568 } 674 }
@@ -811,7 +917,9 @@ sub add_role {
811 foreach my $entry (@email_to) { 917 foreach my $entry (@email_to) {
812 if ($email_remove_duplicates) { 918 if ($email_remove_duplicates) {
813 my ($entry_name, $entry_address) = parse_email($entry->[0]); 919 my ($entry_name, $entry_address) = parse_email($entry->[0]);
814 if ($name eq $entry_name || $address eq $entry_address) { 920 if (($name eq $entry_name || $address eq $entry_address)
921 && ($role eq "" || !($entry->[1] =~ m/$role/))
922 ) {
815 if ($entry->[1] eq "") { 923 if ($entry->[1] eq "") {
816 $entry->[1] = "$role"; 924 $entry->[1] = "$role";
817 } else { 925 } else {
@@ -819,7 +927,9 @@ sub add_role {
819 } 927 }
820 } 928 }
821 } else { 929 } else {
822 if ($email eq $entry->[0]) { 930 if ($email eq $entry->[0]
931 && ($role eq "" || !($entry->[1] =~ m/$role/))
932 ) {
823 if ($entry->[1] eq "") { 933 if ($entry->[1] eq "") {
824 $entry->[1] = "$role"; 934 $entry->[1] = "$role";
825 } else { 935 } else {
@@ -900,7 +1010,7 @@ sub vcs_find_signers {
900 1010
901 $commits = grep(/$pattern/, @lines); # of commits 1011 $commits = grep(/$pattern/, @lines); # of commits
902 1012
903 @lines = grep(/^[-_ a-z]+by:.*\@.*$/i, @lines); 1013 @lines = grep(/^[ \t]*${signaturePattern}.*\@.*$/, @lines);
904 if (!$email_git_penguin_chiefs) { 1014 if (!$email_git_penguin_chiefs) {
905 @lines = grep(!/${penguin_chiefs}/i, @lines); 1015 @lines = grep(!/${penguin_chiefs}/i, @lines);
906 } 1016 }
@@ -1099,6 +1209,51 @@ sub sort_and_uniq {
1099 return @parms; 1209 return @parms;
1100} 1210}
1101 1211
1212sub clean_file_emails {
1213 my (@file_emails) = @_;
1214 my @fmt_emails = ();
1215
1216 foreach my $email (@file_emails) {
1217 $email =~ s/[\(\<\{]{0,1}([A-Za-z0-9_\.\+-]+\@[A-Za-z0-9\.-]+)[\)\>\}]{0,1}/\<$1\>/g;
1218 my ($name, $address) = parse_email($email);
1219 if ($name eq '"[,\.]"') {
1220 $name = "";
1221 }
1222
1223 my @nw = split(/[^A-Za-zÀ-ÿ\'\,\.\+-]/, $name);
1224 if (@nw > 2) {
1225 my $first = $nw[@nw - 3];
1226 my $middle = $nw[@nw - 2];
1227 my $last = $nw[@nw - 1];
1228
1229 if (((length($first) == 1 && $first =~ m/[A-Za-z]/) ||
1230 (length($first) == 2 && substr($first, -1) eq ".")) ||
1231 (length($middle) == 1 ||
1232 (length($middle) == 2 && substr($middle, -1) eq "."))) {
1233 $name = "$first $middle $last";
1234 } else {
1235 $name = "$middle $last";
1236 }
1237 }
1238
1239 if (substr($name, -1) =~ /[,\.]/) {
1240 $name = substr($name, 0, length($name) - 1);
1241 } elsif (substr($name, -2) =~ /[,\.]"/) {
1242 $name = substr($name, 0, length($name) - 2) . '"';
1243 }
1244
1245 if (substr($name, 0, 1) =~ /[,\.]/) {
1246 $name = substr($name, 1, length($name) - 1);
1247 } elsif (substr($name, 0, 2) =~ /"[,\.]/) {
1248 $name = '"' . substr($name, 2, length($name) - 2);
1249 }
1250
1251 my $fmt_email = format_email($name, $address, $email_usename);
1252 push(@fmt_emails, $fmt_email);
1253 }
1254 return @fmt_emails;
1255}
1256
1102sub merge_email { 1257sub merge_email {
1103 my @lines; 1258 my @lines;
1104 my %saw; 1259 my %saw;
@@ -1183,7 +1338,7 @@ sub rfc822_strip_comments {
1183 1338
1184# valid: returns true if the parameter is an RFC822 valid address 1339# valid: returns true if the parameter is an RFC822 valid address
1185# 1340#
1186sub rfc822_valid ($) { 1341sub rfc822_valid {
1187 my $s = rfc822_strip_comments(shift); 1342 my $s = rfc822_strip_comments(shift);
1188 1343
1189 if (!$rfc822re) { 1344 if (!$rfc822re) {
@@ -1203,7 +1358,7 @@ sub rfc822_valid ($) {
1203# from success with no addresses found, because an empty string is 1358# from success with no addresses found, because an empty string is
1204# a valid list. 1359# a valid list.
1205 1360
1206sub rfc822_validlist ($) { 1361sub rfc822_validlist {
1207 my $s = rfc822_strip_comments(shift); 1362 my $s = rfc822_strip_comments(shift);
1208 1363
1209 if (!$rfc822re) { 1364 if (!$rfc822re) {
diff --git a/scripts/gfp-translate b/scripts/gfp-translate
index 073cb6d152a0..d81b968d864e 100644
--- a/scripts/gfp-translate
+++ b/scripts/gfp-translate
@@ -19,7 +19,7 @@ usage() {
19 exit 0 19 exit 0
20} 20}
21 21
22# Parse command-line arguements 22# Parse command-line arguments
23while [ $# -gt 0 ]; do 23while [ $# -gt 0 ]; do
24 case $1 in 24 case $1 in
25 --source) 25 --source)
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 75bdf5ae202c..de934def410f 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -21,44 +21,54 @@ menuconfig: $(obj)/mconf
21 $< $(Kconfig) 21 $< $(Kconfig)
22 22
23config: $(obj)/conf 23config: $(obj)/conf
24 $< $(Kconfig) 24 $< --oldaskconfig $(Kconfig)
25 25
26nconfig: $(obj)/nconf 26nconfig: $(obj)/nconf
27 $< $(Kconfig) 27 $< $(Kconfig)
28 28
29oldconfig: $(obj)/conf 29oldconfig: $(obj)/conf
30 $< -o $(Kconfig) 30 $< --$@ $(Kconfig)
31 31
32silentoldconfig: $(obj)/conf 32silentoldconfig: $(obj)/conf
33 $(Q)mkdir -p include/generated 33 $(Q)mkdir -p include/generated
34 $< -s $(Kconfig) 34 $< --$@ $(Kconfig)
35
36# if no path is given, then use src directory to find file
37ifdef LSMOD
38LSMOD_F := $(LSMOD)
39ifeq ($(findstring /,$(LSMOD)),)
40 LSMOD_F := $(objtree)/$(LSMOD)
41endif
42endif
35 43
36localmodconfig: $(obj)/streamline_config.pl $(obj)/conf 44localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
37 $(Q)perl $< $(srctree) $(Kconfig) > .tmp.config 45 $(Q)mkdir -p include/generated
38 $(Q)if [ -f .config ]; then \ 46 $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config
39 cmp -s .tmp.config .config || \ 47 $(Q)if [ -f .config ]; then \
40 (mv -f .config .config.old.1; \ 48 cmp -s .tmp.config .config || \
41 mv -f .tmp.config .config; \ 49 (mv -f .config .config.old.1; \
42 $(obj)/conf -s $(Kconfig); \ 50 mv -f .tmp.config .config; \
43 mv -f .config.old.1 .config.old) \ 51 $(obj)/conf --silentoldconfig $(Kconfig); \
44 else \ 52 mv -f .config.old.1 .config.old) \
45 mv -f .tmp.config .config; \ 53 else \
46 $(obj)/conf -s $(Kconfig); \ 54 mv -f .tmp.config .config; \
55 $(obj)/conf --silentoldconfig $(Kconfig); \
47 fi 56 fi
48 $(Q)rm -f .tmp.config 57 $(Q)rm -f .tmp.config
49 58
50localyesconfig: $(obj)/streamline_config.pl $(obj)/conf 59localyesconfig: $(obj)/streamline_config.pl $(obj)/conf
51 $(Q)perl $< $(srctree) $(Kconfig) > .tmp.config 60 $(Q)mkdir -p include/generated
61 $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config
52 $(Q)sed -i s/=m/=y/ .tmp.config 62 $(Q)sed -i s/=m/=y/ .tmp.config
53 $(Q)if [ -f .config ]; then \ 63 $(Q)if [ -f .config ]; then \
54 cmp -s .tmp.config .config || \ 64 cmp -s .tmp.config .config || \
55 (mv -f .config .config.old.1; \ 65 (mv -f .config .config.old.1; \
56 mv -f .tmp.config .config; \ 66 mv -f .tmp.config .config; \
57 $(obj)/conf -s $(Kconfig); \ 67 $(obj)/conf --silentoldconfig $(Kconfig); \
58 mv -f .config.old.1 .config.old) \ 68 mv -f .config.old.1 .config.old) \
59 else \ 69 else \
60 mv -f .tmp.config .config; \ 70 mv -f .tmp.config .config; \
61 $(obj)/conf -s $(Kconfig); \ 71 $(obj)/conf --silentoldconfig $(Kconfig); \
62 fi 72 fi
63 $(Q)rm -f .tmp.config 73 $(Q)rm -f .tmp.config
64 74
@@ -85,30 +95,29 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
85 $(Q)rm -f arch/um/Kconfig.arch 95 $(Q)rm -f arch/um/Kconfig.arch
86 $(Q)rm -f $(obj)/config.pot 96 $(Q)rm -f $(obj)/config.pot
87 97
88PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig 98PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig
89 99
90randconfig: $(obj)/conf 100allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(obj)/conf
91 $< -r $(Kconfig) 101 $< --$@ $(Kconfig)
92 102
93allyesconfig: $(obj)/conf 103PHONY += listnewconfig oldnoconfig savedefconfig defconfig
94 $< -y $(Kconfig)
95 104
96allnoconfig: $(obj)/conf 105listnewconfig oldnoconfig: $(obj)/conf
97 $< -n $(Kconfig) 106 $< --$@ $(Kconfig)
98 107
99allmodconfig: $(obj)/conf 108savedefconfig: $(obj)/conf
100 $< -m $(Kconfig) 109 $< --$@=defconfig $(Kconfig)
101 110
102defconfig: $(obj)/conf 111defconfig: $(obj)/conf
103ifeq ($(KBUILD_DEFCONFIG),) 112ifeq ($(KBUILD_DEFCONFIG),)
104 $< -d $(Kconfig) 113 $< --defconfig $(Kconfig)
105else 114else
106 @echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" 115 @echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
107 $(Q)$< -D arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) 116 $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
108endif 117endif
109 118
110%_defconfig: $(obj)/conf 119%_defconfig: $(obj)/conf
111 $(Q)$< -D arch/$(SRCARCH)/configs/$@ $(Kconfig) 120 $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
112 121
113# Help text used by make help 122# Help text used by make help
114help: 123help:
@@ -121,11 +130,15 @@ help:
121 @echo ' localmodconfig - Update current config disabling modules not loaded' 130 @echo ' localmodconfig - Update current config disabling modules not loaded'
122 @echo ' localyesconfig - Update current config converting local mods to core' 131 @echo ' localyesconfig - Update current config converting local mods to core'
123 @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps' 132 @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
124 @echo ' randconfig - New config with random answer to all options' 133 @echo ' defconfig - New config with default from ARCH supplied defconfig'
125 @echo ' defconfig - New config with default answer to all options' 134 @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
126 @echo ' allmodconfig - New config selecting modules when possible'
127 @echo ' allyesconfig - New config where all options are accepted with yes'
128 @echo ' allnoconfig - New config where all options are answered with no' 135 @echo ' allnoconfig - New config where all options are answered with no'
136 @echo ' allyesconfig - New config where all options are accepted with yes'
137 @echo ' allmodconfig - New config selecting modules when possible'
138 @echo ' alldefconfig - New config with all symbols set to default'
139 @echo ' randconfig - New config with random answer to all options'
140 @echo ' listnewconfig - List new options'
141 @echo ' oldnoconfig - Same as silentoldconfig but set new symbols to n (unset)'
129 142
130# lxdialog stuff 143# lxdialog stuff
131check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh 144check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
@@ -209,7 +222,7 @@ HOSTCFLAGS_zconf.tab.o := -I$(src)
209HOSTLOADLIBES_qconf = $(KC_QT_LIBS) -ldl 222HOSTLOADLIBES_qconf = $(KC_QT_LIBS) -ldl
210HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) -D LKC_DIRECT_LINK 223HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) -D LKC_DIRECT_LINK
211 224
212HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0` 225HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0` -ldl
213HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \ 226HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
214 -D LKC_DIRECT_LINK 227 -D LKC_DIRECT_LINK
215 228
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 9960d1c303f8..7ef429cd5cb3 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -10,6 +10,7 @@
10#include <string.h> 10#include <string.h>
11#include <time.h> 11#include <time.h>
12#include <unistd.h> 12#include <unistd.h>
13#include <getopt.h>
13#include <sys/stat.h> 14#include <sys/stat.h>
14#include <sys/time.h> 15#include <sys/time.h>
15 16
@@ -19,16 +20,21 @@
19static void conf(struct menu *menu); 20static void conf(struct menu *menu);
20static void check_conf(struct menu *menu); 21static void check_conf(struct menu *menu);
21 22
22enum { 23enum input_mode {
23 ask_all, 24 oldaskconfig,
24 ask_new, 25 silentoldconfig,
25 ask_silent, 26 oldconfig,
26 set_default, 27 allnoconfig,
27 set_yes, 28 allyesconfig,
28 set_mod, 29 allmodconfig,
29 set_no, 30 alldefconfig,
30 set_random 31 randconfig,
31} input_mode = ask_all; 32 defconfig,
33 savedefconfig,
34 listnewconfig,
35 oldnoconfig,
36} input_mode = oldaskconfig;
37
32char *defconfig_file; 38char *defconfig_file;
33 39
34static int indent = 1; 40static int indent = 1;
@@ -93,16 +99,16 @@ static int conf_askvalue(struct symbol *sym, const char *def)
93 } 99 }
94 100
95 switch (input_mode) { 101 switch (input_mode) {
96 case ask_new: 102 case oldconfig:
97 case ask_silent: 103 case silentoldconfig:
98 if (sym_has_value(sym)) { 104 if (sym_has_value(sym)) {
99 printf("%s\n", def); 105 printf("%s\n", def);
100 return 0; 106 return 0;
101 } 107 }
102 check_stdin(); 108 check_stdin();
103 case ask_all: 109 case oldaskconfig:
104 fflush(stdout); 110 fflush(stdout);
105 fgets(line, 128, stdin); 111 xfgets(line, 128, stdin);
106 return 1; 112 return 1;
107 default: 113 default:
108 break; 114 break;
@@ -156,14 +162,12 @@ static int conf_string(struct menu *menu)
156static int conf_sym(struct menu *menu) 162static int conf_sym(struct menu *menu)
157{ 163{
158 struct symbol *sym = menu->sym; 164 struct symbol *sym = menu->sym;
159 int type;
160 tristate oldval, newval; 165 tristate oldval, newval;
161 166
162 while (1) { 167 while (1) {
163 printf("%*s%s ", indent - 1, "", _(menu->prompt->text)); 168 printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
164 if (sym->name) 169 if (sym->name)
165 printf("(%s) ", sym->name); 170 printf("(%s) ", sym->name);
166 type = sym_get_type(sym);
167 putchar('['); 171 putchar('[');
168 oldval = sym_get_tristate_value(sym); 172 oldval = sym_get_tristate_value(sym);
169 switch (oldval) { 173 switch (oldval) {
@@ -228,11 +232,9 @@ static int conf_choice(struct menu *menu)
228{ 232{
229 struct symbol *sym, *def_sym; 233 struct symbol *sym, *def_sym;
230 struct menu *child; 234 struct menu *child;
231 int type;
232 bool is_new; 235 bool is_new;
233 236
234 sym = menu->sym; 237 sym = menu->sym;
235 type = sym_get_type(sym);
236 is_new = !sym_has_value(sym); 238 is_new = !sym_has_value(sym);
237 if (sym_is_changable(sym)) { 239 if (sym_is_changable(sym)) {
238 conf_sym(menu); 240 conf_sym(menu);
@@ -294,17 +296,17 @@ static int conf_choice(struct menu *menu)
294 printf("?"); 296 printf("?");
295 printf("]: "); 297 printf("]: ");
296 switch (input_mode) { 298 switch (input_mode) {
297 case ask_new: 299 case oldconfig:
298 case ask_silent: 300 case silentoldconfig:
299 if (!is_new) { 301 if (!is_new) {
300 cnt = def; 302 cnt = def;
301 printf("%d\n", cnt); 303 printf("%d\n", cnt);
302 break; 304 break;
303 } 305 }
304 check_stdin(); 306 check_stdin();
305 case ask_all: 307 case oldaskconfig:
306 fflush(stdout); 308 fflush(stdout);
307 fgets(line, 128, stdin); 309 xfgets(line, 128, stdin);
308 strip(line); 310 strip(line);
309 if (line[0] == '?') { 311 if (line[0] == '?') {
310 print_help(menu); 312 print_help(menu);
@@ -360,7 +362,10 @@ static void conf(struct menu *menu)
360 362
361 switch (prop->type) { 363 switch (prop->type) {
362 case P_MENU: 364 case P_MENU:
363 if (input_mode == ask_silent && rootEntry != menu) { 365 if ((input_mode == silentoldconfig ||
366 input_mode == listnewconfig ||
367 input_mode == oldnoconfig) &&
368 rootEntry != menu) {
364 check_conf(menu); 369 check_conf(menu);
365 return; 370 return;
366 } 371 }
@@ -418,10 +423,16 @@ static void check_conf(struct menu *menu)
418 if (sym && !sym_has_value(sym)) { 423 if (sym && !sym_has_value(sym)) {
419 if (sym_is_changable(sym) || 424 if (sym_is_changable(sym) ||
420 (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { 425 (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) {
421 if (!conf_cnt++) 426 if (input_mode == listnewconfig) {
422 printf(_("*\n* Restart config...\n*\n")); 427 if (sym->name && !sym_is_choice_value(sym)) {
423 rootEntry = menu_get_parent_menu(menu); 428 printf("CONFIG_%s\n", sym->name);
424 conf(rootEntry); 429 }
430 } else if (input_mode != oldnoconfig) {
431 if (!conf_cnt++)
432 printf(_("*\n* Restart config...\n*\n"));
433 rootEntry = menu_get_parent_menu(menu);
434 conf(rootEntry);
435 }
425 } 436 }
426 } 437 }
427 438
@@ -429,6 +440,22 @@ static void check_conf(struct menu *menu)
429 check_conf(child); 440 check_conf(child);
430} 441}
431 442
443static struct option long_opts[] = {
444 {"oldaskconfig", no_argument, NULL, oldaskconfig},
445 {"oldconfig", no_argument, NULL, oldconfig},
446 {"silentoldconfig", no_argument, NULL, silentoldconfig},
447 {"defconfig", optional_argument, NULL, defconfig},
448 {"savedefconfig", required_argument, NULL, savedefconfig},
449 {"allnoconfig", no_argument, NULL, allnoconfig},
450 {"allyesconfig", no_argument, NULL, allyesconfig},
451 {"allmodconfig", no_argument, NULL, allmodconfig},
452 {"alldefconfig", no_argument, NULL, alldefconfig},
453 {"randconfig", no_argument, NULL, randconfig},
454 {"listnewconfig", no_argument, NULL, listnewconfig},
455 {"oldnoconfig", no_argument, NULL, oldnoconfig},
456 {NULL, 0, NULL, 0}
457};
458
432int main(int ac, char **av) 459int main(int ac, char **av)
433{ 460{
434 int opt; 461 int opt;
@@ -439,32 +466,17 @@ int main(int ac, char **av)
439 bindtextdomain(PACKAGE, LOCALEDIR); 466 bindtextdomain(PACKAGE, LOCALEDIR);
440 textdomain(PACKAGE); 467 textdomain(PACKAGE);
441 468
442 while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) { 469 while ((opt = getopt_long_only(ac, av, "", long_opts, NULL)) != -1) {
470 input_mode = (enum input_mode)opt;
443 switch (opt) { 471 switch (opt) {
444 case 'o': 472 case silentoldconfig:
445 input_mode = ask_silent;
446 break;
447 case 's':
448 input_mode = ask_silent;
449 sync_kconfig = 1; 473 sync_kconfig = 1;
450 break; 474 break;
451 case 'd': 475 case defconfig:
452 input_mode = set_default; 476 case savedefconfig:
453 break;
454 case 'D':
455 input_mode = set_default;
456 defconfig_file = optarg; 477 defconfig_file = optarg;
457 break; 478 break;
458 case 'n': 479 case randconfig:
459 input_mode = set_no;
460 break;
461 case 'm':
462 input_mode = set_mod;
463 break;
464 case 'y':
465 input_mode = set_yes;
466 break;
467 case 'r':
468 { 480 {
469 struct timeval now; 481 struct timeval now;
470 unsigned int seed; 482 unsigned int seed;
@@ -477,17 +489,12 @@ int main(int ac, char **av)
477 489
478 seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1)); 490 seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1));
479 srand(seed); 491 srand(seed);
480
481 input_mode = set_random;
482 break; 492 break;
483 } 493 }
484 case 'h': 494 case '?':
485 printf(_("See README for usage info\n"));
486 exit(0);
487 break;
488 default:
489 fprintf(stderr, _("See README for usage info\n")); 495 fprintf(stderr, _("See README for usage info\n"));
490 exit(1); 496 exit(1);
497 break;
491 } 498 }
492 } 499 }
493 if (ac == optind) { 500 if (ac == optind) {
@@ -512,7 +519,7 @@ int main(int ac, char **av)
512 } 519 }
513 520
514 switch (input_mode) { 521 switch (input_mode) {
515 case set_default: 522 case defconfig:
516 if (!defconfig_file) 523 if (!defconfig_file)
517 defconfig_file = conf_get_default_confname(); 524 defconfig_file = conf_get_default_confname();
518 if (conf_read(defconfig_file)) { 525 if (conf_read(defconfig_file)) {
@@ -522,25 +529,32 @@ int main(int ac, char **av)
522 exit(1); 529 exit(1);
523 } 530 }
524 break; 531 break;
525 case ask_silent: 532 case savedefconfig:
526 case ask_all: 533 conf_read(NULL);
527 case ask_new: 534 break;
535 case silentoldconfig:
536 case oldaskconfig:
537 case oldconfig:
538 case listnewconfig:
539 case oldnoconfig:
528 conf_read(NULL); 540 conf_read(NULL);
529 break; 541 break;
530 case set_no: 542 case allnoconfig:
531 case set_mod: 543 case allyesconfig:
532 case set_yes: 544 case allmodconfig:
533 case set_random: 545 case alldefconfig:
546 case randconfig:
534 name = getenv("KCONFIG_ALLCONFIG"); 547 name = getenv("KCONFIG_ALLCONFIG");
535 if (name && !stat(name, &tmpstat)) { 548 if (name && !stat(name, &tmpstat)) {
536 conf_read_simple(name, S_DEF_USER); 549 conf_read_simple(name, S_DEF_USER);
537 break; 550 break;
538 } 551 }
539 switch (input_mode) { 552 switch (input_mode) {
540 case set_no: name = "allno.config"; break; 553 case allnoconfig: name = "allno.config"; break;
541 case set_mod: name = "allmod.config"; break; 554 case allyesconfig: name = "allyes.config"; break;
542 case set_yes: name = "allyes.config"; break; 555 case allmodconfig: name = "allmod.config"; break;
543 case set_random: name = "allrandom.config"; break; 556 case alldefconfig: name = "alldef.config"; break;
557 case randconfig: name = "allrandom.config"; break;
544 default: break; 558 default: break;
545 } 559 }
546 if (!stat(name, &tmpstat)) 560 if (!stat(name, &tmpstat))
@@ -565,33 +579,42 @@ int main(int ac, char **av)
565 } 579 }
566 580
567 switch (input_mode) { 581 switch (input_mode) {
568 case set_no: 582 case allnoconfig:
569 conf_set_all_new_symbols(def_no); 583 conf_set_all_new_symbols(def_no);
570 break; 584 break;
571 case set_yes: 585 case allyesconfig:
572 conf_set_all_new_symbols(def_yes); 586 conf_set_all_new_symbols(def_yes);
573 break; 587 break;
574 case set_mod: 588 case allmodconfig:
575 conf_set_all_new_symbols(def_mod); 589 conf_set_all_new_symbols(def_mod);
576 break; 590 break;
577 case set_random: 591 case alldefconfig:
592 conf_set_all_new_symbols(def_default);
593 break;
594 case randconfig:
578 conf_set_all_new_symbols(def_random); 595 conf_set_all_new_symbols(def_random);
579 break; 596 break;
580 case set_default: 597 case defconfig:
581 conf_set_all_new_symbols(def_default); 598 conf_set_all_new_symbols(def_default);
582 break; 599 break;
583 case ask_new: 600 case savedefconfig:
584 case ask_all: 601 break;
602 case oldaskconfig:
585 rootEntry = &rootmenu; 603 rootEntry = &rootmenu;
586 conf(&rootmenu); 604 conf(&rootmenu);
587 input_mode = ask_silent; 605 input_mode = silentoldconfig;
588 /* fall through */ 606 /* fall through */
589 case ask_silent: 607 case oldconfig:
608 case listnewconfig:
609 case oldnoconfig:
610 case silentoldconfig:
590 /* Update until a loop caused no more changes */ 611 /* Update until a loop caused no more changes */
591 do { 612 do {
592 conf_cnt = 0; 613 conf_cnt = 0;
593 check_conf(&rootmenu); 614 check_conf(&rootmenu);
594 } while (conf_cnt); 615 } while (conf_cnt &&
616 (input_mode != listnewconfig &&
617 input_mode != oldnoconfig));
595 break; 618 break;
596 } 619 }
597 620
@@ -607,7 +630,13 @@ int main(int ac, char **av)
607 fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n")); 630 fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n"));
608 return 1; 631 return 1;
609 } 632 }
610 } else { 633 } else if (input_mode == savedefconfig) {
634 if (conf_write_defconfig(defconfig_file)) {
635 fprintf(stderr, _("n*** Error while saving defconfig to: %s\n\n"),
636 defconfig_file);
637 return 1;
638 }
639 } else if (input_mode != listnewconfig) {
611 if (conf_write(NULL)) { 640 if (conf_write(NULL)) {
612 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); 641 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
613 exit(1); 642 exit(1);
@@ -615,3 +644,14 @@ int main(int ac, char **av)
615 } 644 }
616 return 0; 645 return 0;
617} 646}
647/*
648 * Helper function to facilitate fgets() by Jean Sacren.
649 */
650void xfgets(str, size, in)
651 char *str;
652 int size;
653 FILE *in;
654{
655 if (fgets(str, size, in) == NULL)
656 fprintf(stderr, "\nError in reading or end of file.\n");
657}
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index c4dec80cfd8e..515253fe46cf 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -170,8 +170,11 @@ int conf_read_simple(const char *name, int def)
170 if (in) 170 if (in)
171 goto load; 171 goto load;
172 sym_add_change_count(1); 172 sym_add_change_count(1);
173 if (!sym_defconfig_list) 173 if (!sym_defconfig_list) {
174 if (modules_sym)
175 sym_calc_value(modules_sym);
174 return 1; 176 return 1;
177 }
175 178
176 for_all_defaults(sym_defconfig_list, prop) { 179 for_all_defaults(sym_defconfig_list, prop) {
177 if (expr_calc_value(prop->visible.expr) == no || 180 if (expr_calc_value(prop->visible.expr) == no ||
@@ -396,15 +399,150 @@ int conf_read(const char *name)
396 return 0; 399 return 0;
397} 400}
398 401
402/* Write a S_STRING */
403static void conf_write_string(bool headerfile, const char *name,
404 const char *str, FILE *out)
405{
406 int l;
407 if (headerfile)
408 fprintf(out, "#define CONFIG_%s \"", name);
409 else
410 fprintf(out, "CONFIG_%s=\"", name);
411
412 while (1) {
413 l = strcspn(str, "\"\\");
414 if (l) {
415 xfwrite(str, l, 1, out);
416 str += l;
417 }
418 if (!*str)
419 break;
420 fprintf(out, "\\%c", *str++);
421 }
422 fputs("\"\n", out);
423}
424
425static void conf_write_symbol(struct symbol *sym, enum symbol_type type,
426 FILE *out, bool write_no)
427{
428 const char *str;
429
430 switch (type) {
431 case S_BOOLEAN:
432 case S_TRISTATE:
433 switch (sym_get_tristate_value(sym)) {
434 case no:
435 if (write_no)
436 fprintf(out, "# CONFIG_%s is not set\n", sym->name);
437 break;
438 case mod:
439 fprintf(out, "CONFIG_%s=m\n", sym->name);
440 break;
441 case yes:
442 fprintf(out, "CONFIG_%s=y\n", sym->name);
443 break;
444 }
445 break;
446 case S_STRING:
447 conf_write_string(false, sym->name, sym_get_string_value(sym), out);
448 break;
449 case S_HEX:
450 case S_INT:
451 str = sym_get_string_value(sym);
452 fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
453 break;
454 case S_OTHER:
455 case S_UNKNOWN:
456 break;
457 }
458}
459
460/*
461 * Write out a minimal config.
462 * All values that has default values are skipped as this is redundant.
463 */
464int conf_write_defconfig(const char *filename)
465{
466 struct symbol *sym;
467 struct menu *menu;
468 FILE *out;
469
470 out = fopen(filename, "w");
471 if (!out)
472 return 1;
473
474 sym_clear_all_valid();
475
476 /* Traverse all menus to find all relevant symbols */
477 menu = rootmenu.list;
478
479 while (menu != NULL)
480 {
481 sym = menu->sym;
482 if (sym == NULL) {
483 if (!menu_is_visible(menu))
484 goto next_menu;
485 } else if (!sym_is_choice(sym)) {
486 sym_calc_value(sym);
487 if (!(sym->flags & SYMBOL_WRITE))
488 goto next_menu;
489 sym->flags &= ~SYMBOL_WRITE;
490 /* If we cannot change the symbol - skip */
491 if (!sym_is_changable(sym))
492 goto next_menu;
493 /* If symbol equals to default value - skip */
494 if (strcmp(sym_get_string_value(sym), sym_get_string_default(sym)) == 0)
495 goto next_menu;
496
497 /*
498 * If symbol is a choice value and equals to the
499 * default for a choice - skip.
500 * But only if value is bool and equal to "y" and
501 * choice is not "optional".
502 * (If choice is "optional" then all values can be "n")
503 */
504 if (sym_is_choice_value(sym)) {
505 struct symbol *cs;
506 struct symbol *ds;
507
508 cs = prop_get_symbol(sym_get_choice_prop(sym));
509 ds = sym_choice_default(cs);
510 if (!sym_is_optional(cs) && sym == ds) {
511 if ((sym->type == S_BOOLEAN) &&
512 sym_get_tristate_value(sym) == yes)
513 goto next_menu;
514 }
515 }
516 conf_write_symbol(sym, sym->type, out, true);
517 }
518next_menu:
519 if (menu->list != NULL) {
520 menu = menu->list;
521 }
522 else if (menu->next != NULL) {
523 menu = menu->next;
524 } else {
525 while ((menu = menu->parent)) {
526 if (menu->next != NULL) {
527 menu = menu->next;
528 break;
529 }
530 }
531 }
532 }
533 fclose(out);
534 return 0;
535}
536
399int conf_write(const char *name) 537int conf_write(const char *name)
400{ 538{
401 FILE *out; 539 FILE *out;
402 struct symbol *sym; 540 struct symbol *sym;
403 struct menu *menu; 541 struct menu *menu;
404 const char *basename; 542 const char *basename;
405 char dirname[128], tmpname[128], newname[128];
406 int type, l;
407 const char *str; 543 const char *str;
544 char dirname[128], tmpname[128], newname[128];
545 enum symbol_type type;
408 time_t now; 546 time_t now;
409 int use_timestamp = 1; 547 int use_timestamp = 1;
410 char *env; 548 char *env;
@@ -484,50 +622,11 @@ int conf_write(const char *name)
484 if (modules_sym->curr.tri == no) 622 if (modules_sym->curr.tri == no)
485 type = S_BOOLEAN; 623 type = S_BOOLEAN;
486 } 624 }
487 switch (type) { 625 /* Write config symbol to file */
488 case S_BOOLEAN: 626 conf_write_symbol(sym, type, out, true);
489 case S_TRISTATE:
490 switch (sym_get_tristate_value(sym)) {
491 case no:
492 fprintf(out, "# CONFIG_%s is not set\n", sym->name);
493 break;
494 case mod:
495 fprintf(out, "CONFIG_%s=m\n", sym->name);
496 break;
497 case yes:
498 fprintf(out, "CONFIG_%s=y\n", sym->name);
499 break;
500 }
501 break;
502 case S_STRING:
503 str = sym_get_string_value(sym);
504 fprintf(out, "CONFIG_%s=\"", sym->name);
505 while (1) {
506 l = strcspn(str, "\"\\");
507 if (l) {
508 fwrite(str, l, 1, out);
509 str += l;
510 }
511 if (!*str)
512 break;
513 fprintf(out, "\\%c", *str++);
514 }
515 fputs("\"\n", out);
516 break;
517 case S_HEX:
518 str = sym_get_string_value(sym);
519 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
520 fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
521 break;
522 }
523 case S_INT:
524 str = sym_get_string_value(sym);
525 fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
526 break;
527 }
528 } 627 }
529 628
530 next: 629next:
531 if (menu->list) { 630 if (menu->list) {
532 menu = menu->list; 631 menu = menu->list;
533 continue; 632 continue;
@@ -679,7 +778,7 @@ int conf_write_autoconf(void)
679 const char *name; 778 const char *name;
680 FILE *out, *tristate, *out_h; 779 FILE *out, *tristate, *out_h;
681 time_t now; 780 time_t now;
682 int i, l; 781 int i;
683 782
684 sym_clear_all_valid(); 783 sym_clear_all_valid();
685 784
@@ -729,6 +828,11 @@ int conf_write_autoconf(void)
729 sym_calc_value(sym); 828 sym_calc_value(sym);
730 if (!(sym->flags & SYMBOL_WRITE) || !sym->name) 829 if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
731 continue; 830 continue;
831
832 /* write symbol to config file */
833 conf_write_symbol(sym, sym->type, out, false);
834
835 /* update autoconf and tristate files */
732 switch (sym->type) { 836 switch (sym->type) {
733 case S_BOOLEAN: 837 case S_BOOLEAN:
734 case S_TRISTATE: 838 case S_TRISTATE:
@@ -736,12 +840,10 @@ int conf_write_autoconf(void)
736 case no: 840 case no:
737 break; 841 break;
738 case mod: 842 case mod:
739 fprintf(out, "CONFIG_%s=m\n", sym->name);
740 fprintf(tristate, "CONFIG_%s=M\n", sym->name); 843 fprintf(tristate, "CONFIG_%s=M\n", sym->name);
741 fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name); 844 fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name);
742 break; 845 break;
743 case yes: 846 case yes:
744 fprintf(out, "CONFIG_%s=y\n", sym->name);
745 if (sym->type == S_TRISTATE) 847 if (sym->type == S_TRISTATE)
746 fprintf(tristate, "CONFIG_%s=Y\n", 848 fprintf(tristate, "CONFIG_%s=Y\n",
747 sym->name); 849 sym->name);
@@ -750,35 +852,16 @@ int conf_write_autoconf(void)
750 } 852 }
751 break; 853 break;
752 case S_STRING: 854 case S_STRING:
753 str = sym_get_string_value(sym); 855 conf_write_string(true, sym->name, sym_get_string_value(sym), out_h);
754 fprintf(out, "CONFIG_%s=\"", sym->name);
755 fprintf(out_h, "#define CONFIG_%s \"", sym->name);
756 while (1) {
757 l = strcspn(str, "\"\\");
758 if (l) {
759 fwrite(str, l, 1, out);
760 fwrite(str, l, 1, out_h);
761 str += l;
762 }
763 if (!*str)
764 break;
765 fprintf(out, "\\%c", *str);
766 fprintf(out_h, "\\%c", *str);
767 str++;
768 }
769 fputs("\"\n", out);
770 fputs("\"\n", out_h);
771 break; 856 break;
772 case S_HEX: 857 case S_HEX:
773 str = sym_get_string_value(sym); 858 str = sym_get_string_value(sym);
774 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { 859 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
775 fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
776 fprintf(out_h, "#define CONFIG_%s 0x%s\n", sym->name, str); 860 fprintf(out_h, "#define CONFIG_%s 0x%s\n", sym->name, str);
777 break; 861 break;
778 } 862 }
779 case S_INT: 863 case S_INT:
780 str = sym_get_string_value(sym); 864 str = sym_get_string_value(sym);
781 fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
782 fprintf(out_h, "#define CONFIG_%s %s\n", sym->name, str); 865 fprintf(out_h, "#define CONFIG_%s %s\n", sym->name, str);
783 break; 866 break;
784 default: 867 default:
@@ -837,13 +920,73 @@ void conf_set_changed_callback(void (*fn)(void))
837 conf_changed_callback = fn; 920 conf_changed_callback = fn;
838} 921}
839 922
923static void randomize_choice_values(struct symbol *csym)
924{
925 struct property *prop;
926 struct symbol *sym;
927 struct expr *e;
928 int cnt, def;
840 929
841void conf_set_all_new_symbols(enum conf_def_mode mode) 930 /*
931 * If choice is mod then we may have more items slected
932 * and if no then no-one.
933 * In both cases stop.
934 */
935 if (csym->curr.tri != yes)
936 return;
937
938 prop = sym_get_choice_prop(csym);
939
940 /* count entries in choice block */
941 cnt = 0;
942 expr_list_for_each_sym(prop->expr, e, sym)
943 cnt++;
944
945 /*
946 * find a random value and set it to yes,
947 * set the rest to no so we have only one set
948 */
949 def = (rand() % cnt);
950
951 cnt = 0;
952 expr_list_for_each_sym(prop->expr, e, sym) {
953 if (def == cnt++) {
954 sym->def[S_DEF_USER].tri = yes;
955 csym->def[S_DEF_USER].val = sym;
956 }
957 else {
958 sym->def[S_DEF_USER].tri = no;
959 }
960 }
961 csym->flags |= SYMBOL_DEF_USER;
962 /* clear VALID to get value calculated */
963 csym->flags &= ~(SYMBOL_VALID);
964}
965
966static void set_all_choice_values(struct symbol *csym)
842{ 967{
843 struct symbol *sym, *csym;
844 struct property *prop; 968 struct property *prop;
969 struct symbol *sym;
845 struct expr *e; 970 struct expr *e;
846 int i, cnt, def; 971
972 prop = sym_get_choice_prop(csym);
973
974 /*
975 * Set all non-assinged choice values to no
976 */
977 expr_list_for_each_sym(prop->expr, e, sym) {
978 if (!sym_has_value(sym))
979 sym->def[S_DEF_USER].tri = no;
980 }
981 csym->flags |= SYMBOL_DEF_USER;
982 /* clear VALID to get value calculated */
983 csym->flags &= ~(SYMBOL_VALID);
984}
985
986void conf_set_all_new_symbols(enum conf_def_mode mode)
987{
988 struct symbol *sym, *csym;
989 int i, cnt;
847 990
848 for_all_symbols(i, sym) { 991 for_all_symbols(i, sym) {
849 if (sym_has_value(sym)) 992 if (sym_has_value(sym))
@@ -862,7 +1005,8 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
862 sym->def[S_DEF_USER].tri = no; 1005 sym->def[S_DEF_USER].tri = no;
863 break; 1006 break;
864 case def_random: 1007 case def_random:
865 sym->def[S_DEF_USER].tri = (tristate)(rand() % 3); 1008 cnt = sym_get_type(sym) == S_TRISTATE ? 3 : 2;
1009 sym->def[S_DEF_USER].tri = (tristate)(rand() % cnt);
866 break; 1010 break;
867 default: 1011 default:
868 continue; 1012 continue;
@@ -878,8 +1022,6 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
878 1022
879 sym_clear_all_valid(); 1023 sym_clear_all_valid();
880 1024
881 if (mode != def_random)
882 return;
883 /* 1025 /*
884 * We have different type of choice blocks. 1026 * We have different type of choice blocks.
885 * If curr.tri equal to mod then we can select several 1027 * If curr.tri equal to mod then we can select several
@@ -894,35 +1036,9 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
894 continue; 1036 continue;
895 1037
896 sym_calc_value(csym); 1038 sym_calc_value(csym);
897 1039 if (mode == def_random)
898 if (csym->curr.tri != yes) 1040 randomize_choice_values(csym);
899 continue; 1041 else
900 1042 set_all_choice_values(csym);
901 prop = sym_get_choice_prop(csym);
902
903 /* count entries in choice block */
904 cnt = 0;
905 expr_list_for_each_sym(prop->expr, e, sym)
906 cnt++;
907
908 /*
909 * find a random value and set it to yes,
910 * set the rest to no so we have only one set
911 */
912 def = (rand() % cnt);
913
914 cnt = 0;
915 expr_list_for_each_sym(prop->expr, e, sym) {
916 if (def == cnt++) {
917 sym->def[S_DEF_USER].tri = yes;
918 csym->def[S_DEF_USER].val = sym;
919 }
920 else {
921 sym->def[S_DEF_USER].tri = no;
922 }
923 }
924 csym->flags |= SYMBOL_DEF_USER;
925 /* clear VALID to get value calculated */
926 csym->flags &= ~(SYMBOL_VALID);
927 } 1043 }
928} 1044}
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c
index d83f2322893a..330e7c0048a8 100644
--- a/scripts/kconfig/expr.c
+++ b/scripts/kconfig/expr.c
@@ -1087,7 +1087,7 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *
1087 1087
1088static void expr_print_file_helper(void *data, struct symbol *sym, const char *str) 1088static void expr_print_file_helper(void *data, struct symbol *sym, const char *str)
1089{ 1089{
1090 fwrite(str, strlen(str), 1, data); 1090 xfwrite(str, strlen(str), 1, data);
1091} 1091}
1092 1092
1093void expr_fprint(struct expr *e, FILE *out) 1093void expr_fprint(struct expr *e, FILE *out)
@@ -1121,7 +1121,7 @@ static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *s
1121 } 1121 }
1122 1122
1123 str_append(gs, str); 1123 str_append(gs, str);
1124 if (sym) 1124 if (sym && sym->type != S_UNKNOWN)
1125 str_printf(gs, " [=%s]", sym_str); 1125 str_printf(gs, " [=%s]", sym_str);
1126} 1126}
1127 1127
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index 891cd9ce9ba2..170459c224a1 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -83,6 +83,7 @@ struct symbol {
83 tristate visible; 83 tristate visible;
84 int flags; 84 int flags;
85 struct property *prop; 85 struct property *prop;
86 struct expr_value dir_dep;
86 struct expr_value rev_dep; 87 struct expr_value rev_dep;
87}; 88};
88 89
@@ -131,6 +132,7 @@ enum prop_type {
131 P_SELECT, /* select BAR */ 132 P_SELECT, /* select BAR */
132 P_RANGE, /* range 7..100 (for a symbol) */ 133 P_RANGE, /* range 7..100 (for a symbol) */
133 P_ENV, /* value from environment variable */ 134 P_ENV, /* value from environment variable */
135 P_SYMBOL, /* where a symbol is defined */
134}; 136};
135 137
136struct property { 138struct property {
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
index bef10411837f..d66988265f89 100644
--- a/scripts/kconfig/gconf.c
+++ b/scripts/kconfig/gconf.c
@@ -1114,7 +1114,7 @@ static gchar **fill_row(struct menu *menu)
1114 1114
1115 row[COL_OPTION] = 1115 row[COL_OPTION] =
1116 g_strdup_printf("%s %s", _(menu_get_prompt(menu)), 1116 g_strdup_printf("%s %s", _(menu_get_prompt(menu)),
1117 sym && sym_has_value(sym) ? "(NEW)" : ""); 1117 sym && !sym_has_value(sym) ? "(NEW)" : "");
1118 1118
1119 if (opt_mode == OPT_ALL && !menu_is_visible(menu)) 1119 if (opt_mode == OPT_ALL && !menu_is_visible(menu))
1120 row[COL_COLOR] = g_strdup("DarkGray"); 1120 row[COL_COLOR] = g_strdup("DarkGray");
@@ -1343,7 +1343,8 @@ static void update_tree(struct menu *src, GtkTreeIter * dst)
1343#endif 1343#endif
1344 1344
1345 if ((opt_mode == OPT_NORMAL && !menu_is_visible(child1)) || 1345 if ((opt_mode == OPT_NORMAL && !menu_is_visible(child1)) ||
1346 (opt_mode == OPT_PROMPT && !menu_has_prompt(child1))) { 1346 (opt_mode == OPT_PROMPT && !menu_has_prompt(child1)) ||
1347 (opt_mode == OPT_ALL && !menu_get_prompt(child1))) {
1347 1348
1348 /* remove node */ 1349 /* remove node */
1349 if (gtktree_iter_find_node(dst, menu1) != NULL) { 1350 if (gtktree_iter_find_node(dst, menu1) != NULL) {
@@ -1425,7 +1426,7 @@ static void display_tree(struct menu *menu)
1425 1426
1426 if ((opt_mode == OPT_NORMAL && menu_is_visible(child)) || 1427 if ((opt_mode == OPT_NORMAL && menu_is_visible(child)) ||
1427 (opt_mode == OPT_PROMPT && menu_has_prompt(child)) || 1428 (opt_mode == OPT_PROMPT && menu_has_prompt(child)) ||
1428 (opt_mode == OPT_ALL)) 1429 (opt_mode == OPT_ALL && menu_get_prompt(child)))
1429 place_node(child, fill_row(child)); 1430 place_node(child, fill_row(child));
1430#ifdef DEBUG 1431#ifdef DEBUG
1431 printf("%*c%s: ", indent, ' ', menu_get_prompt(child)); 1432 printf("%*c%s: ", indent, ' ', menu_get_prompt(child));
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index ce6549cdaccf..bdf71bd31412 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -72,6 +72,9 @@ void zconf_nextfile(const char *name);
72int zconf_lineno(void); 72int zconf_lineno(void);
73char *zconf_curname(void); 73char *zconf_curname(void);
74 74
75/* conf.c */
76void xfgets(char *str, int size, FILE *in);
77
75/* confdata.c */ 78/* confdata.c */
76const char *conf_get_configname(void); 79const char *conf_get_configname(void);
77const char *conf_get_autoconfig_name(void); 80const char *conf_get_autoconfig_name(void);
@@ -80,6 +83,13 @@ void sym_set_change_count(int count);
80void sym_add_change_count(int count); 83void sym_add_change_count(int count);
81void conf_set_all_new_symbols(enum conf_def_mode mode); 84void conf_set_all_new_symbols(enum conf_def_mode mode);
82 85
86/* confdata.c and expr.c */
87static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
88{
89 if (fwrite(str, len, count, out) < count)
90 fprintf(stderr, "\nError in writing or end of file.\n");
91}
92
83/* kconfig_load.c */ 93/* kconfig_load.c */
84void kconfig_load(void); 94void kconfig_load(void);
85 95
@@ -126,6 +136,8 @@ void sym_init(void);
126void sym_clear_all_valid(void); 136void sym_clear_all_valid(void);
127void sym_set_all_changed(void); 137void sym_set_all_changed(void);
128void sym_set_changed(struct symbol *sym); 138void sym_set_changed(struct symbol *sym);
139struct symbol *sym_choice_default(struct symbol *sym);
140const char *sym_get_string_default(struct symbol *sym);
129struct symbol *sym_check_deps(struct symbol *sym); 141struct symbol *sym_check_deps(struct symbol *sym);
130struct property *prop_alloc(enum prop_type type, struct symbol *sym); 142struct property *prop_alloc(enum prop_type type, struct symbol *sym);
131struct symbol *prop_get_symbol(struct property *prop); 143struct symbol *prop_get_symbol(struct property *prop);
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index 7cadcad8233b..9a948c9ce44e 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -3,6 +3,7 @@
3P(conf_parse,void,(const char *name)); 3P(conf_parse,void,(const char *name));
4P(conf_read,int,(const char *name)); 4P(conf_read,int,(const char *name));
5P(conf_read_simple,int,(const char *name, int)); 5P(conf_read_simple,int,(const char *name, int));
6P(conf_write_defconfig,int,(const char *name));
6P(conf_write,int,(const char *name)); 7P(conf_write,int,(const char *name));
7P(conf_write_autoconf,int,(void)); 8P(conf_write_autoconf,int,(void));
8P(conf_get_changed,bool,(void)); 9P(conf_get_changed,bool,(void));
diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c
index bcc6f19c3a35..a2eb80fbc896 100644
--- a/scripts/kconfig/lxdialog/checklist.c
+++ b/scripts/kconfig/lxdialog/checklist.c
@@ -31,6 +31,10 @@ static int list_width, check_x, item_x;
31static void print_item(WINDOW * win, int choice, int selected) 31static void print_item(WINDOW * win, int choice, int selected)
32{ 32{
33 int i; 33 int i;
34 char *list_item = malloc(list_width + 1);
35
36 strncpy(list_item, item_str(), list_width - item_x);
37 list_item[list_width - item_x] = '\0';
34 38
35 /* Clear 'residue' of last item */ 39 /* Clear 'residue' of last item */
36 wattrset(win, dlg.menubox.atr); 40 wattrset(win, dlg.menubox.atr);
@@ -45,13 +49,14 @@ static void print_item(WINDOW * win, int choice, int selected)
45 wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' '); 49 wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' ');
46 50
47 wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr); 51 wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr);
48 mvwaddch(win, choice, item_x, item_str()[0]); 52 mvwaddch(win, choice, item_x, list_item[0]);
49 wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); 53 wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr);
50 waddstr(win, (char *)item_str() + 1); 54 waddstr(win, list_item + 1);
51 if (selected) { 55 if (selected) {
52 wmove(win, choice, check_x + 1); 56 wmove(win, choice, check_x + 1);
53 wrefresh(win); 57 wrefresh(win);
54 } 58 }
59 free(list_item);
55} 60}
56 61
57/* 62/*
@@ -175,6 +180,7 @@ do_resize:
175 check_x = 0; 180 check_x = 0;
176 item_foreach() 181 item_foreach()
177 check_x = MAX(check_x, strlen(item_str()) + 4); 182 check_x = MAX(check_x, strlen(item_str()) + 4);
183 check_x = MIN(check_x, list_width);
178 184
179 check_x = (list_width - check_x) / 2; 185 check_x = (list_width - check_x) / 2;
180 item_x = check_x + 4; 186 item_x = check_x + 4;
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 2c83d3234d30..d2f6e056c058 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -74,7 +74,7 @@ static const char mconf_readme[] = N_(
74"\n" 74"\n"
75" Shortcut: Press <H> or <?>.\n" 75" Shortcut: Press <H> or <?>.\n"
76"\n" 76"\n"
77"o To show hidden options, press <Z>.\n" 77"o To toggle the display of hidden options, press <Z>.\n"
78"\n" 78"\n"
79"\n" 79"\n"
80"Radiolists (Choice lists)\n" 80"Radiolists (Choice lists)\n"
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 203632cc30bd..edda8b49619d 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -58,6 +58,8 @@ void menu_add_entry(struct symbol *sym)
58 *last_entry_ptr = menu; 58 *last_entry_ptr = menu;
59 last_entry_ptr = &menu->next; 59 last_entry_ptr = &menu->next;
60 current_entry = menu; 60 current_entry = menu;
61 if (sym)
62 menu_add_symbol(P_SYMBOL, sym, NULL);
61} 63}
62 64
63void menu_end_entry(void) 65void menu_end_entry(void)
@@ -318,6 +320,8 @@ void menu_finalize(struct menu *parent)
318 parent->next = last_menu->next; 320 parent->next = last_menu->next;
319 last_menu->next = NULL; 321 last_menu->next = NULL;
320 } 322 }
323
324 sym->dir_dep.expr = parent->dep;
321 } 325 }
322 for (menu = parent->list; menu; menu = menu->next) { 326 for (menu = parent->list; menu; menu = menu->next) {
323 if (sym && sym_is_choice(sym) && 327 if (sym && sym_is_choice(sym) &&
@@ -419,9 +423,13 @@ bool menu_is_visible(struct menu *menu)
419 if (!sym || sym_get_tristate_value(menu->sym) == no) 423 if (!sym || sym_get_tristate_value(menu->sym) == no)
420 return false; 424 return false;
421 425
422 for (child = menu->list; child; child = child->next) 426 for (child = menu->list; child; child = child->next) {
423 if (menu_is_visible(child)) 427 if (menu_is_visible(child)) {
428 if (sym)
429 sym->flags |= SYMBOL_DEF_USER;
424 return true; 430 return true;
431 }
432 }
425 433
426 return false; 434 return false;
427} 435}
@@ -501,9 +509,19 @@ void get_symbol_str(struct gstr *r, struct symbol *sym)
501 bool hit; 509 bool hit;
502 struct property *prop; 510 struct property *prop;
503 511
504 if (sym && sym->name) 512 if (sym && sym->name) {
505 str_printf(r, "Symbol: %s [=%s]\n", sym->name, 513 str_printf(r, "Symbol: %s [=%s]\n", sym->name,
506 sym_get_string_value(sym)); 514 sym_get_string_value(sym));
515 str_printf(r, "Type : %s\n", sym_type_name(sym->type));
516 if (sym->type == S_INT || sym->type == S_HEX) {
517 prop = sym_get_range_prop(sym);
518 if (prop) {
519 str_printf(r, "Range : ");
520 expr_gstr_print(prop->expr, r);
521 str_append(r, "\n");
522 }
523 }
524 }
507 for_all_prompts(sym, prop) 525 for_all_prompts(sym, prop)
508 get_prompt_str(r, prop); 526 get_prompt_str(r, prop);
509 hit = false; 527 hit = false;
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c
index 762caf80ce37..2ba71bcd38e6 100644
--- a/scripts/kconfig/nconf.c
+++ b/scripts/kconfig/nconf.c
@@ -676,6 +676,8 @@ static void *item_data(void)
676 struct mitem *mcur; 676 struct mitem *mcur;
677 677
678 cur = current_item(curses_menu); 678 cur = current_item(curses_menu);
679 if (!cur)
680 return NULL;
679 mcur = (struct mitem *) item_userptr(cur); 681 mcur = (struct mitem *) item_userptr(cur);
680 return mcur->usrptr; 682 return mcur->usrptr;
681 683
diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c
index 115edb437fb1..a9d9344e1365 100644
--- a/scripts/kconfig/nconf.gui.c
+++ b/scripts/kconfig/nconf.gui.c
@@ -226,7 +226,7 @@ void fill_window(WINDOW *win, const char *text)
226 int len = get_line_length(line); 226 int len = get_line_length(line);
227 strncpy(tmp, line, min(len, x)); 227 strncpy(tmp, line, min(len, x));
228 tmp[len] = '\0'; 228 tmp[len] = '\0';
229 mvwprintw(win, i, 0, tmp); 229 mvwprintw(win, i, 0, "%s", tmp);
230 } 230 }
231} 231}
232 232
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 00c51507cfcc..820df2d1217b 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -58,11 +58,10 @@ QValueList<int> ConfigSettings::readSizes(const QString& key, bool *ok)
58{ 58{
59 QValueList<int> result; 59 QValueList<int> result;
60 QStringList entryList = readListEntry(key, ok); 60 QStringList entryList = readListEntry(key, ok);
61 if (ok) { 61 QStringList::Iterator it;
62 QStringList::Iterator it; 62
63 for (it = entryList.begin(); it != entryList.end(); ++it) 63 for (it = entryList.begin(); it != entryList.end(); ++it)
64 result.push_back((*it).toInt()); 64 result.push_back((*it).toInt());
65 }
66 65
67 return result; 66 return result;
68} 67}
@@ -149,7 +148,7 @@ void ConfigItem::updateMenu(void)
149 case S_TRISTATE: 148 case S_TRISTATE:
150 char ch; 149 char ch;
151 150
152 if (!sym_is_changable(sym) && !list->showAll) { 151 if (!sym_is_changable(sym) && list->optMode == normalOpt) {
153 setPixmap(promptColIdx, 0); 152 setPixmap(promptColIdx, 0);
154 setText(noColIdx, QString::null); 153 setText(noColIdx, QString::null);
155 setText(modColIdx, QString::null); 154 setText(modColIdx, QString::null);
@@ -320,7 +319,7 @@ ConfigList::ConfigList(ConfigView* p, const char *name)
320 symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), 319 symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no),
321 choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), 320 choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no),
322 menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void), 321 menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void),
323 showAll(false), showName(false), showRange(false), showData(false), 322 showName(false), showRange(false), showData(false), optMode(normalOpt),
324 rootEntry(0), headerPopup(0) 323 rootEntry(0), headerPopup(0)
325{ 324{
326 int i; 325 int i;
@@ -337,10 +336,10 @@ ConfigList::ConfigList(ConfigView* p, const char *name)
337 336
338 if (name) { 337 if (name) {
339 configSettings->beginGroup(name); 338 configSettings->beginGroup(name);
340 showAll = configSettings->readBoolEntry("/showAll", false);
341 showName = configSettings->readBoolEntry("/showName", false); 339 showName = configSettings->readBoolEntry("/showName", false);
342 showRange = configSettings->readBoolEntry("/showRange", false); 340 showRange = configSettings->readBoolEntry("/showRange", false);
343 showData = configSettings->readBoolEntry("/showData", false); 341 showData = configSettings->readBoolEntry("/showData", false);
342 optMode = (enum optionMode)configSettings->readNumEntry("/optionMode", false);
344 configSettings->endGroup(); 343 configSettings->endGroup();
345 connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); 344 connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
346 } 345 }
@@ -352,6 +351,17 @@ ConfigList::ConfigList(ConfigView* p, const char *name)
352 reinit(); 351 reinit();
353} 352}
354 353
354bool ConfigList::menuSkip(struct menu *menu)
355{
356 if (optMode == normalOpt && menu_is_visible(menu))
357 return false;
358 if (optMode == promptOpt && menu_has_prompt(menu))
359 return false;
360 if (optMode == allOpt)
361 return false;
362 return true;
363}
364
355void ConfigList::reinit(void) 365void ConfigList::reinit(void)
356{ 366{
357 removeColumn(dataColIdx); 367 removeColumn(dataColIdx);
@@ -380,7 +390,7 @@ void ConfigList::saveSettings(void)
380 configSettings->writeEntry("/showName", showName); 390 configSettings->writeEntry("/showName", showName);
381 configSettings->writeEntry("/showRange", showRange); 391 configSettings->writeEntry("/showRange", showRange);
382 configSettings->writeEntry("/showData", showData); 392 configSettings->writeEntry("/showData", showData);
383 configSettings->writeEntry("/showAll", showAll); 393 configSettings->writeEntry("/optionMode", (int)optMode);
384 configSettings->endGroup(); 394 configSettings->endGroup();
385 } 395 }
386} 396}
@@ -606,7 +616,7 @@ void ConfigList::updateMenuList(P* parent, struct menu* menu)
606 } 616 }
607 617
608 visible = menu_is_visible(child); 618 visible = menu_is_visible(child);
609 if (showAll || visible) { 619 if (!menuSkip(child)) {
610 if (!child->sym && !child->list && !child->prompt) 620 if (!child->sym && !child->list && !child->prompt)
611 continue; 621 continue;
612 if (!item || item->menu != child) 622 if (!item || item->menu != child)
@@ -835,7 +845,10 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
835 e->ignore(); 845 e->ignore();
836} 846}
837 847
838ConfigView* ConfigView::viewList; 848ConfigView*ConfigView::viewList;
849QAction *ConfigView::showNormalAction;
850QAction *ConfigView::showAllAction;
851QAction *ConfigView::showPromptAction;
839 852
840ConfigView::ConfigView(QWidget* parent, const char *name) 853ConfigView::ConfigView(QWidget* parent, const char *name)
841 : Parent(parent, name) 854 : Parent(parent, name)
@@ -860,13 +873,16 @@ ConfigView::~ConfigView(void)
860 } 873 }
861} 874}
862 875
863void ConfigView::setShowAll(bool b) 876void ConfigView::setOptionMode(QAction *act)
864{ 877{
865 if (list->showAll != b) { 878 if (act == showNormalAction)
866 list->showAll = b; 879 list->optMode = normalOpt;
867 list->updateListAll(); 880 else if (act == showAllAction)
868 emit showAllChanged(b); 881 list->optMode = allOpt;
869 } 882 else
883 list->optMode = promptOpt;
884
885 list->updateListAll();
870} 886}
871 887
872void ConfigView::setShowName(bool b) 888void ConfigView::setShowName(bool b)
@@ -964,34 +980,6 @@ void ConfigInfoView::setInfo(struct menu *m)
964 menuInfo(); 980 menuInfo();
965} 981}
966 982
967void ConfigInfoView::setSource(const QString& name)
968{
969 const char *p = name.latin1();
970
971 menu = NULL;
972 sym = NULL;
973
974 switch (p[0]) {
975 case 'm':
976 struct menu *m;
977
978 if (sscanf(p, "m%p", &m) == 1 && menu != m) {
979 menu = m;
980 menuInfo();
981 emit menuSelected(menu);
982 }
983 break;
984 case 's':
985 struct symbol *s;
986
987 if (sscanf(p, "s%p", &s) == 1 && sym != s) {
988 sym = s;
989 symbolInfo();
990 }
991 break;
992 }
993}
994
995void ConfigInfoView::symbolInfo(void) 983void ConfigInfoView::symbolInfo(void)
996{ 984{
997 QString str; 985 QString str;
@@ -1349,11 +1337,24 @@ ConfigMainWindow::ConfigMainWindow(void)
1349 connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool))); 1337 connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool)));
1350 connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool))); 1338 connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool)));
1351 showDataAction->setOn(configList->showData); 1339 showDataAction->setOn(configList->showData);
1352 QAction *showAllAction = new QAction(NULL, _("Show All Options"), 0, this); 1340
1353 showAllAction->setToggleAction(TRUE); 1341 QActionGroup *optGroup = new QActionGroup(this);
1354 connect(showAllAction, SIGNAL(toggled(bool)), configView, SLOT(setShowAll(bool))); 1342 optGroup->setExclusive(TRUE);
1355 connect(showAllAction, SIGNAL(toggled(bool)), menuView, SLOT(setShowAll(bool))); 1343 connect(optGroup, SIGNAL(selected(QAction *)), configView,
1356 showAllAction->setOn(configList->showAll); 1344 SLOT(setOptionMode(QAction *)));
1345 connect(optGroup, SIGNAL(selected(QAction *)), menuView,
1346 SLOT(setOptionMode(QAction *)));
1347
1348 configView->showNormalAction = new QAction(NULL, _("Show Normal Options"), 0, optGroup);
1349 configView->showAllAction = new QAction(NULL, _("Show All Options"), 0, optGroup);
1350 configView->showPromptAction = new QAction(NULL, _("Show Prompt Options"), 0, optGroup);
1351 configView->showNormalAction->setToggleAction(TRUE);
1352 configView->showNormalAction->setOn(configList->optMode == normalOpt);
1353 configView->showAllAction->setToggleAction(TRUE);
1354 configView->showAllAction->setOn(configList->optMode == allOpt);
1355 configView->showPromptAction->setToggleAction(TRUE);
1356 configView->showPromptAction->setOn(configList->optMode == promptOpt);
1357
1357 QAction *showDebugAction = new QAction(NULL, _("Show Debug Info"), 0, this); 1358 QAction *showDebugAction = new QAction(NULL, _("Show Debug Info"), 0, this);
1358 showDebugAction->setToggleAction(TRUE); 1359 showDebugAction->setToggleAction(TRUE);
1359 connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool))); 1360 connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool)));
@@ -1396,7 +1397,8 @@ ConfigMainWindow::ConfigMainWindow(void)
1396 showRangeAction->addTo(optionMenu); 1397 showRangeAction->addTo(optionMenu);
1397 showDataAction->addTo(optionMenu); 1398 showDataAction->addTo(optionMenu);
1398 optionMenu->insertSeparator(); 1399 optionMenu->insertSeparator();
1399 showAllAction->addTo(optionMenu); 1400 optGroup->addTo(optionMenu);
1401 optionMenu->insertSeparator();
1400 showDebugAction->addTo(optionMenu); 1402 showDebugAction->addTo(optionMenu);
1401 1403
1402 // create help menu 1404 // create help menu
@@ -1491,7 +1493,7 @@ void ConfigMainWindow::setMenuLink(struct menu *menu)
1491 ConfigList* list = NULL; 1493 ConfigList* list = NULL;
1492 ConfigItem* item; 1494 ConfigItem* item;
1493 1495
1494 if (!menu_is_visible(menu) && !configView->showAll()) 1496 if (configList->menuSkip(menu))
1495 return; 1497 return;
1496 1498
1497 switch (configList->mode) { 1499 switch (configList->mode) {
diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h
index b3b5657b6b35..636a74b23bf9 100644
--- a/scripts/kconfig/qconf.h
+++ b/scripts/kconfig/qconf.h
@@ -44,6 +44,9 @@ enum colIdx {
44enum listMode { 44enum listMode {
45 singleMode, menuMode, symbolMode, fullMode, listMode 45 singleMode, menuMode, symbolMode, fullMode, listMode
46}; 46};
47enum optionMode {
48 normalOpt = 0, allOpt, promptOpt
49};
47 50
48class ConfigList : public QListView { 51class ConfigList : public QListView {
49 Q_OBJECT 52 Q_OBJECT
@@ -115,6 +118,8 @@ public:
115 void setAllOpen(bool open); 118 void setAllOpen(bool open);
116 void setParentMenu(void); 119 void setParentMenu(void);
117 120
121 bool menuSkip(struct menu *);
122
118 template <class P> 123 template <class P>
119 void updateMenuList(P*, struct menu*); 124 void updateMenuList(P*, struct menu*);
120 125
@@ -124,8 +129,9 @@ public:
124 QPixmap choiceYesPix, choiceNoPix; 129 QPixmap choiceYesPix, choiceNoPix;
125 QPixmap menuPix, menuInvPix, menuBackPix, voidPix; 130 QPixmap menuPix, menuInvPix, menuBackPix, voidPix;
126 131
127 bool showAll, showName, showRange, showData; 132 bool showName, showRange, showData;
128 enum listMode mode; 133 enum listMode mode;
134 enum optionMode optMode;
129 struct menu *rootEntry; 135 struct menu *rootEntry;
130 QColorGroup disabledColorGroup; 136 QColorGroup disabledColorGroup;
131 QColorGroup inactivedColorGroup; 137 QColorGroup inactivedColorGroup;
@@ -222,17 +228,15 @@ public:
222 static void updateList(ConfigItem* item); 228 static void updateList(ConfigItem* item);
223 static void updateListAll(void); 229 static void updateListAll(void);
224 230
225 bool showAll(void) const { return list->showAll; }
226 bool showName(void) const { return list->showName; } 231 bool showName(void) const { return list->showName; }
227 bool showRange(void) const { return list->showRange; } 232 bool showRange(void) const { return list->showRange; }
228 bool showData(void) const { return list->showData; } 233 bool showData(void) const { return list->showData; }
229public slots: 234public slots:
230 void setShowAll(bool);
231 void setShowName(bool); 235 void setShowName(bool);
232 void setShowRange(bool); 236 void setShowRange(bool);
233 void setShowData(bool); 237 void setShowData(bool);
238 void setOptionMode(QAction *);
234signals: 239signals:
235 void showAllChanged(bool);
236 void showNameChanged(bool); 240 void showNameChanged(bool);
237 void showRangeChanged(bool); 241 void showRangeChanged(bool);
238 void showDataChanged(bool); 242 void showDataChanged(bool);
@@ -242,6 +246,10 @@ public:
242 246
243 static ConfigView* viewList; 247 static ConfigView* viewList;
244 ConfigView* nextView; 248 ConfigView* nextView;
249
250 static QAction *showNormalAction;
251 static QAction *showAllAction;
252 static QAction *showPromptAction;
245}; 253};
246 254
247class ConfigInfoView : public QTextBrowser { 255class ConfigInfoView : public QTextBrowser {
@@ -254,7 +262,6 @@ public:
254public slots: 262public slots:
255 void setInfo(struct menu *menu); 263 void setInfo(struct menu *menu);
256 void saveSettings(void); 264 void saveSettings(void);
257 void setSource(const QString& name);
258 void setShowDebug(bool); 265 void setShowDebug(bool);
259 266
260signals: 267signals:
diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
index 0d800820c3cd..c70a27d924f0 100644
--- a/scripts/kconfig/streamline_config.pl
+++ b/scripts/kconfig/streamline_config.pl
@@ -113,14 +113,19 @@ find_config;
113# Get the build source and top level Kconfig file (passed in) 113# Get the build source and top level Kconfig file (passed in)
114my $ksource = $ARGV[0]; 114my $ksource = $ARGV[0];
115my $kconfig = $ARGV[1]; 115my $kconfig = $ARGV[1];
116my $lsmod_file = $ARGV[2];
117
118my @makefiles = `find $ksource -name Makefile 2>/dev/null`;
119chomp @makefiles;
116 120
117my @makefiles = `find $ksource -name Makefile`;
118my %depends; 121my %depends;
119my %selects; 122my %selects;
120my %prompts; 123my %prompts;
121my %objects; 124my %objects;
122my $var; 125my $var;
123my $cont = 0; 126my $cont = 0;
127my $iflevel = 0;
128my @ifdeps;
124 129
125# prevent recursion 130# prevent recursion
126my %read_kconfigs; 131my %read_kconfigs;
@@ -146,6 +151,15 @@ sub read_kconfig {
146 $state = "NEW"; 151 $state = "NEW";
147 $config = $1; 152 $config = $1;
148 153
154 for (my $i = 0; $i < $iflevel; $i++) {
155 if ($i) {
156 $depends{$config} .= " " . $ifdeps[$i];
157 } else {
158 $depends{$config} = $ifdeps[$i];
159 }
160 $state = "DEP";
161 }
162
149 # collect the depends for the config 163 # collect the depends for the config
150 } elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) { 164 } elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) {
151 $state = "DEP"; 165 $state = "DEP";
@@ -166,6 +180,21 @@ sub read_kconfig {
166 # note if the config has a prompt 180 # note if the config has a prompt
167 $prompt{$config} = 1; 181 $prompt{$config} = 1;
168 182
183 # Check for if statements
184 } elsif (/^if\s+(.*\S)\s*$/) {
185 my $deps = $1;
186 # remove beginning and ending non text
187 $deps =~ s/^[^a-zA-Z0-9_]*//;
188 $deps =~ s/[^a-zA-Z0-9_]*$//;
189
190 my @deps = split /[^a-zA-Z0-9_]+/, $deps;
191
192 $ifdeps[$iflevel++] = join ':', @deps;
193
194 } elsif (/^endif/) {
195
196 $iflevel-- if ($iflevel);
197
169 # stop on "help" 198 # stop on "help"
170 } elsif (/^\s*help\s*$/) { 199 } elsif (/^\s*help\s*$/) {
171 $state = "NONE"; 200 $state = "NONE";
@@ -188,7 +217,6 @@ if ($kconfig) {
188 217
189# Read all Makefiles to map the configs to the objects 218# Read all Makefiles to map the configs to the objects
190foreach my $makefile (@makefiles) { 219foreach my $makefile (@makefiles) {
191 chomp $makefile;
192 220
193 open(MIN,$makefile) || die "Can't open $makefile"; 221 open(MIN,$makefile) || die "Can't open $makefile";
194 while (<MIN>) { 222 while (<MIN>) {
@@ -215,7 +243,7 @@ foreach my $makefile (@makefiles) {
215 foreach my $obj (split /\s+/,$objs) { 243 foreach my $obj (split /\s+/,$objs) {
216 $obj =~ s/-/_/g; 244 $obj =~ s/-/_/g;
217 if ($obj =~ /(.*)\.o$/) { 245 if ($obj =~ /(.*)\.o$/) {
218 # Objects may bes enabled by more than one config. 246 # Objects may be enabled by more than one config.
219 # Store configs in an array. 247 # Store configs in an array.
220 my @arr; 248 my @arr;
221 249
@@ -237,8 +265,36 @@ foreach my $makefile (@makefiles) {
237 265
238my %modules; 266my %modules;
239 267
240# see what modules are loaded on this system 268if (defined($lsmod_file)) {
241open(LIN,"/sbin/lsmod|") || die "Cant lsmod"; 269 if ( ! -f $lsmod_file) {
270 die "$lsmod_file not found";
271 }
272 if ( -x $lsmod_file) {
273 # the file is executable, run it
274 open(LIN, "$lsmod_file|");
275 } else {
276 # Just read the contents
277 open(LIN, "$lsmod_file");
278 }
279} else {
280
281 # see what modules are loaded on this system
282 my $lsmod;
283
284 foreach $dir ( ("/sbin", "/bin", "/usr/sbin", "/usr/bin") ) {
285 if ( -x "$dir/lsmod" ) {
286 $lsmod = "$dir/lsmod";
287 last;
288 }
289}
290 if (!defined($lsmod)) {
291 # try just the path
292 $lsmod = "lsmod";
293 }
294
295 open(LIN,"$lsmod|") || die "Can not call lsmod with $lsmod";
296}
297
242while (<LIN>) { 298while (<LIN>) {
243 next if (/^Module/); # Skip the first line. 299 next if (/^Module/); # Skip the first line.
244 if (/^(\S+)/) { 300 if (/^(\S+)/) {
@@ -252,7 +308,7 @@ close (LIN);
252my %configs; 308my %configs;
253foreach my $module (keys(%modules)) { 309foreach my $module (keys(%modules)) {
254 if (defined($objects{$module})) { 310 if (defined($objects{$module})) {
255 @arr = @{$objects{$module}}; 311 my @arr = @{$objects{$module}};
256 foreach my $conf (@arr) { 312 foreach my $conf (@arr) {
257 $configs{$conf} = $module; 313 $configs{$conf} = $module;
258 } 314 }
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 2e7a048e0cfc..1f8b305449db 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -205,6 +205,16 @@ static void sym_calc_visibility(struct symbol *sym)
205 } 205 }
206 if (sym_is_choice_value(sym)) 206 if (sym_is_choice_value(sym))
207 return; 207 return;
208 /* defaulting to "yes" if no explicit "depends on" are given */
209 tri = yes;
210 if (sym->dir_dep.expr)
211 tri = expr_calc_value(sym->dir_dep.expr);
212 if (tri == mod)
213 tri = yes;
214 if (sym->dir_dep.tri != tri) {
215 sym->dir_dep.tri = tri;
216 sym_set_changed(sym);
217 }
208 tri = no; 218 tri = no;
209 if (sym->rev_dep.expr) 219 if (sym->rev_dep.expr)
210 tri = expr_calc_value(sym->rev_dep.expr); 220 tri = expr_calc_value(sym->rev_dep.expr);
@@ -216,44 +226,63 @@ static void sym_calc_visibility(struct symbol *sym)
216 } 226 }
217} 227}
218 228
219static struct symbol *sym_calc_choice(struct symbol *sym) 229/*
230 * Find the default symbol for a choice.
231 * First try the default values for the choice symbol
232 * Next locate the first visible choice value
233 * Return NULL if none was found
234 */
235struct symbol *sym_choice_default(struct symbol *sym)
220{ 236{
221 struct symbol *def_sym; 237 struct symbol *def_sym;
222 struct property *prop; 238 struct property *prop;
223 struct expr *e; 239 struct expr *e;
224 240
225 /* is the user choice visible? */
226 def_sym = sym->def[S_DEF_USER].val;
227 if (def_sym) {
228 sym_calc_visibility(def_sym);
229 if (def_sym->visible != no)
230 return def_sym;
231 }
232
233 /* any of the defaults visible? */ 241 /* any of the defaults visible? */
234 for_all_defaults(sym, prop) { 242 for_all_defaults(sym, prop) {
235 prop->visible.tri = expr_calc_value(prop->visible.expr); 243 prop->visible.tri = expr_calc_value(prop->visible.expr);
236 if (prop->visible.tri == no) 244 if (prop->visible.tri == no)
237 continue; 245 continue;
238 def_sym = prop_get_symbol(prop); 246 def_sym = prop_get_symbol(prop);
239 sym_calc_visibility(def_sym);
240 if (def_sym->visible != no) 247 if (def_sym->visible != no)
241 return def_sym; 248 return def_sym;
242 } 249 }
243 250
244 /* just get the first visible value */ 251 /* just get the first visible value */
245 prop = sym_get_choice_prop(sym); 252 prop = sym_get_choice_prop(sym);
246 expr_list_for_each_sym(prop->expr, e, def_sym) { 253 expr_list_for_each_sym(prop->expr, e, def_sym)
247 sym_calc_visibility(def_sym);
248 if (def_sym->visible != no) 254 if (def_sym->visible != no)
249 return def_sym; 255 return def_sym;
250 }
251 256
252 /* no choice? reset tristate value */ 257 /* failed to locate any defaults */
253 sym->curr.tri = no;
254 return NULL; 258 return NULL;
255} 259}
256 260
261static struct symbol *sym_calc_choice(struct symbol *sym)
262{
263 struct symbol *def_sym;
264 struct property *prop;
265 struct expr *e;
266
267 /* first calculate all choice values' visibilities */
268 prop = sym_get_choice_prop(sym);
269 expr_list_for_each_sym(prop->expr, e, def_sym)
270 sym_calc_visibility(def_sym);
271
272 /* is the user choice visible? */
273 def_sym = sym->def[S_DEF_USER].val;
274 if (def_sym && def_sym->visible != no)
275 return def_sym;
276
277 def_sym = sym_choice_default(sym);
278
279 if (def_sym == NULL)
280 /* no choice? reset tristate value */
281 sym->curr.tri = no;
282
283 return def_sym;
284}
285
257void sym_calc_value(struct symbol *sym) 286void sym_calc_value(struct symbol *sym)
258{ 287{
259 struct symbol_value newval, oldval; 288 struct symbol_value newval, oldval;
@@ -321,6 +350,16 @@ void sym_calc_value(struct symbol *sym)
321 } 350 }
322 } 351 }
323 calc_newval: 352 calc_newval:
353#if 0
354 if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) {
355 fprintf(stderr, "warning: (");
356 expr_fprint(sym->rev_dep.expr, stderr);
357 fprintf(stderr, ") selects %s which has unmet direct dependencies (",
358 sym->name);
359 expr_fprint(sym->dir_dep.expr, stderr);
360 fprintf(stderr, ")\n");
361 }
362#endif
324 newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); 363 newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);
325 } 364 }
326 if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN) 365 if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN)
@@ -365,12 +404,13 @@ void sym_calc_value(struct symbol *sym)
365 404
366 if (sym_is_choice(sym)) { 405 if (sym_is_choice(sym)) {
367 struct symbol *choice_sym; 406 struct symbol *choice_sym;
368 int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);
369 407
370 prop = sym_get_choice_prop(sym); 408 prop = sym_get_choice_prop(sym);
371 expr_list_for_each_sym(prop->expr, e, choice_sym) { 409 expr_list_for_each_sym(prop->expr, e, choice_sym) {
372 choice_sym->flags |= flags; 410 if ((sym->flags & SYMBOL_WRITE) &&
373 if (flags & SYMBOL_CHANGED) 411 choice_sym->visible != no)
412 choice_sym->flags |= SYMBOL_WRITE;
413 if (sym->flags & SYMBOL_CHANGED)
374 sym_set_changed(choice_sym); 414 sym_set_changed(choice_sym);
375 } 415 }
376 } 416 }
@@ -623,6 +663,80 @@ bool sym_set_string_value(struct symbol *sym, const char *newval)
623 return true; 663 return true;
624} 664}
625 665
666/*
667 * Find the default value associated to a symbol.
668 * For tristate symbol handle the modules=n case
669 * in which case "m" becomes "y".
670 * If the symbol does not have any default then fallback
671 * to the fixed default values.
672 */
673const char *sym_get_string_default(struct symbol *sym)
674{
675 struct property *prop;
676 struct symbol *ds;
677 const char *str;
678 tristate val;
679
680 sym_calc_visibility(sym);
681 sym_calc_value(modules_sym);
682 val = symbol_no.curr.tri;
683 str = symbol_empty.curr.val;
684
685 /* If symbol has a default value look it up */
686 prop = sym_get_default_prop(sym);
687 if (prop != NULL) {
688 switch (sym->type) {
689 case S_BOOLEAN:
690 case S_TRISTATE:
691 /* The visibility imay limit the value from yes => mod */
692 val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri);
693 break;
694 default:
695 /*
696 * The following fails to handle the situation
697 * where a default value is further limited by
698 * the valid range.
699 */
700 ds = prop_get_symbol(prop);
701 if (ds != NULL) {
702 sym_calc_value(ds);
703 str = (const char *)ds->curr.val;
704 }
705 }
706 }
707
708 /* Handle select statements */
709 val = EXPR_OR(val, sym->rev_dep.tri);
710
711 /* transpose mod to yes if modules are not enabled */
712 if (val == mod)
713 if (!sym_is_choice_value(sym) && modules_sym->curr.tri == no)
714 val = yes;
715
716 /* transpose mod to yes if type is bool */
717 if (sym->type == S_BOOLEAN && val == mod)
718 val = yes;
719
720 switch (sym->type) {
721 case S_BOOLEAN:
722 case S_TRISTATE:
723 switch (val) {
724 case no: return "n";
725 case mod: return "m";
726 case yes: return "y";
727 }
728 case S_INT:
729 case S_HEX:
730 return str;
731 case S_STRING:
732 return str;
733 case S_OTHER:
734 case S_UNKNOWN:
735 break;
736 }
737 return "";
738}
739
626const char *sym_get_string_value(struct symbol *sym) 740const char *sym_get_string_value(struct symbol *sym)
627{ 741{
628 tristate val; 742 tristate val;
@@ -765,6 +879,112 @@ struct symbol **sym_re_search(const char *pattern)
765 return sym_arr; 879 return sym_arr;
766} 880}
767 881
882/*
883 * When we check for recursive dependencies we use a stack to save
884 * current state so we can print out relevant info to user.
885 * The entries are located on the call stack so no need to free memory.
886 * Note inser() remove() must always match to properly clear the stack.
887 */
888static struct dep_stack {
889 struct dep_stack *prev, *next;
890 struct symbol *sym;
891 struct property *prop;
892 struct expr *expr;
893} *check_top;
894
895static void dep_stack_insert(struct dep_stack *stack, struct symbol *sym)
896{
897 memset(stack, 0, sizeof(*stack));
898 if (check_top)
899 check_top->next = stack;
900 stack->prev = check_top;
901 stack->sym = sym;
902 check_top = stack;
903}
904
905static void dep_stack_remove(void)
906{
907 check_top = check_top->prev;
908 if (check_top)
909 check_top->next = NULL;
910}
911
912/*
913 * Called when we have detected a recursive dependency.
914 * check_top point to the top of the stact so we use
915 * the ->prev pointer to locate the bottom of the stack.
916 */
917static void sym_check_print_recursive(struct symbol *last_sym)
918{
919 struct dep_stack *stack;
920 struct symbol *sym, *next_sym;
921 struct menu *menu = NULL;
922 struct property *prop;
923 struct dep_stack cv_stack;
924
925 if (sym_is_choice_value(last_sym)) {
926 dep_stack_insert(&cv_stack, last_sym);
927 last_sym = prop_get_symbol(sym_get_choice_prop(last_sym));
928 }
929
930 for (stack = check_top; stack != NULL; stack = stack->prev)
931 if (stack->sym == last_sym)
932 break;
933 if (!stack) {
934 fprintf(stderr, "unexpected recursive dependency error\n");
935 return;
936 }
937
938 for (; stack; stack = stack->next) {
939 sym = stack->sym;
940 next_sym = stack->next ? stack->next->sym : last_sym;
941 prop = stack->prop;
942 if (prop == NULL)
943 prop = stack->sym->prop;
944
945 /* for choice values find the menu entry (used below) */
946 if (sym_is_choice(sym) || sym_is_choice_value(sym)) {
947 for (prop = sym->prop; prop; prop = prop->next) {
948 menu = prop->menu;
949 if (prop->menu)
950 break;
951 }
952 }
953 if (stack->sym == last_sym)
954 fprintf(stderr, "%s:%d:error: recursive dependency detected!\n",
955 prop->file->name, prop->lineno);
956 if (stack->expr) {
957 fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n",
958 prop->file->name, prop->lineno,
959 sym->name ? sym->name : "<choice>",
960 prop_get_type_name(prop->type),
961 next_sym->name ? next_sym->name : "<choice>");
962 } else if (stack->prop) {
963 fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n",
964 prop->file->name, prop->lineno,
965 sym->name ? sym->name : "<choice>",
966 next_sym->name ? next_sym->name : "<choice>");
967 } else if (sym_is_choice(sym)) {
968 fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n",
969 menu->file->name, menu->lineno,
970 sym->name ? sym->name : "<choice>",
971 next_sym->name ? next_sym->name : "<choice>");
972 } else if (sym_is_choice_value(sym)) {
973 fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n",
974 menu->file->name, menu->lineno,
975 sym->name ? sym->name : "<choice>",
976 next_sym->name ? next_sym->name : "<choice>");
977 } else {
978 fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n",
979 prop->file->name, prop->lineno,
980 sym->name ? sym->name : "<choice>",
981 next_sym->name ? next_sym->name : "<choice>");
982 }
983 }
984
985 if (check_top == &cv_stack)
986 dep_stack_remove();
987}
768 988
769static struct symbol *sym_check_expr_deps(struct expr *e) 989static struct symbol *sym_check_expr_deps(struct expr *e)
770{ 990{
@@ -801,24 +1021,33 @@ static struct symbol *sym_check_sym_deps(struct symbol *sym)
801{ 1021{
802 struct symbol *sym2; 1022 struct symbol *sym2;
803 struct property *prop; 1023 struct property *prop;
1024 struct dep_stack stack;
1025
1026 dep_stack_insert(&stack, sym);
804 1027
805 sym2 = sym_check_expr_deps(sym->rev_dep.expr); 1028 sym2 = sym_check_expr_deps(sym->rev_dep.expr);
806 if (sym2) 1029 if (sym2)
807 return sym2; 1030 goto out;
808 1031
809 for (prop = sym->prop; prop; prop = prop->next) { 1032 for (prop = sym->prop; prop; prop = prop->next) {
810 if (prop->type == P_CHOICE || prop->type == P_SELECT) 1033 if (prop->type == P_CHOICE || prop->type == P_SELECT)
811 continue; 1034 continue;
1035 stack.prop = prop;
812 sym2 = sym_check_expr_deps(prop->visible.expr); 1036 sym2 = sym_check_expr_deps(prop->visible.expr);
813 if (sym2) 1037 if (sym2)
814 break; 1038 break;
815 if (prop->type != P_DEFAULT || sym_is_choice(sym)) 1039 if (prop->type != P_DEFAULT || sym_is_choice(sym))
816 continue; 1040 continue;
1041 stack.expr = prop->expr;
817 sym2 = sym_check_expr_deps(prop->expr); 1042 sym2 = sym_check_expr_deps(prop->expr);
818 if (sym2) 1043 if (sym2)
819 break; 1044 break;
1045 stack.expr = NULL;
820 } 1046 }
821 1047
1048out:
1049 dep_stack_remove();
1050
822 return sym2; 1051 return sym2;
823} 1052}
824 1053
@@ -827,6 +1056,9 @@ static struct symbol *sym_check_choice_deps(struct symbol *choice)
827 struct symbol *sym, *sym2; 1056 struct symbol *sym, *sym2;
828 struct property *prop; 1057 struct property *prop;
829 struct expr *e; 1058 struct expr *e;
1059 struct dep_stack stack;
1060
1061 dep_stack_insert(&stack, choice);
830 1062
831 prop = sym_get_choice_prop(choice); 1063 prop = sym_get_choice_prop(choice);
832 expr_list_for_each_sym(prop->expr, e, sym) 1064 expr_list_for_each_sym(prop->expr, e, sym)
@@ -840,10 +1072,8 @@ static struct symbol *sym_check_choice_deps(struct symbol *choice)
840 1072
841 expr_list_for_each_sym(prop->expr, e, sym) { 1073 expr_list_for_each_sym(prop->expr, e, sym) {
842 sym2 = sym_check_sym_deps(sym); 1074 sym2 = sym_check_sym_deps(sym);
843 if (sym2) { 1075 if (sym2)
844 fprintf(stderr, " -> %s", sym->name);
845 break; 1076 break;
846 }
847 } 1077 }
848out: 1078out:
849 expr_list_for_each_sym(prop->expr, e, sym) 1079 expr_list_for_each_sym(prop->expr, e, sym)
@@ -853,6 +1083,8 @@ out:
853 prop_get_symbol(sym_get_choice_prop(sym2)) == choice) 1083 prop_get_symbol(sym_get_choice_prop(sym2)) == choice)
854 sym2 = choice; 1084 sym2 = choice;
855 1085
1086 dep_stack_remove();
1087
856 return sym2; 1088 return sym2;
857} 1089}
858 1090
@@ -862,18 +1094,20 @@ struct symbol *sym_check_deps(struct symbol *sym)
862 struct property *prop; 1094 struct property *prop;
863 1095
864 if (sym->flags & SYMBOL_CHECK) { 1096 if (sym->flags & SYMBOL_CHECK) {
865 fprintf(stderr, "%s:%d:error: found recursive dependency: %s", 1097 sym_check_print_recursive(sym);
866 sym->prop->file->name, sym->prop->lineno,
867 sym->name ? sym->name : "<choice>");
868 return sym; 1098 return sym;
869 } 1099 }
870 if (sym->flags & SYMBOL_CHECKED) 1100 if (sym->flags & SYMBOL_CHECKED)
871 return NULL; 1101 return NULL;
872 1102
873 if (sym_is_choice_value(sym)) { 1103 if (sym_is_choice_value(sym)) {
1104 struct dep_stack stack;
1105
874 /* for choice groups start the check with main choice symbol */ 1106 /* for choice groups start the check with main choice symbol */
1107 dep_stack_insert(&stack, sym);
875 prop = sym_get_choice_prop(sym); 1108 prop = sym_get_choice_prop(sym);
876 sym2 = sym_check_deps(prop_get_symbol(prop)); 1109 sym2 = sym_check_deps(prop_get_symbol(prop));
1110 dep_stack_remove();
877 } else if (sym_is_choice(sym)) { 1111 } else if (sym_is_choice(sym)) {
878 sym2 = sym_check_choice_deps(sym); 1112 sym2 = sym_check_choice_deps(sym);
879 } else { 1113 } else {
@@ -882,14 +1116,8 @@ struct symbol *sym_check_deps(struct symbol *sym)
882 sym->flags &= ~SYMBOL_CHECK; 1116 sym->flags &= ~SYMBOL_CHECK;
883 } 1117 }
884 1118
885 if (sym2) { 1119 if (sym2 && sym2 == sym)
886 fprintf(stderr, " -> %s", sym->name ? sym->name : "<choice>"); 1120 sym2 = NULL;
887 if (sym2 == sym) {
888 fprintf(stderr, "\n");
889 zconfnerrs++;
890 sym2 = NULL;
891 }
892 }
893 1121
894 return sym2; 1122 return sym2;
895} 1123}
@@ -943,6 +1171,8 @@ const char *prop_get_type_name(enum prop_type type)
943 return "select"; 1171 return "select";
944 case P_RANGE: 1172 case P_RANGE:
945 return "range"; 1173 return "range";
1174 case P_SYMBOL:
1175 return "symbol";
946 case P_UNKNOWN: 1176 case P_UNKNOWN:
947 break; 1177 break;
948 } 1178 }
diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c
index 81c100d953ef..78b5c04e736b 100644
--- a/scripts/kconfig/util.c
+++ b/scripts/kconfig/util.c
@@ -72,7 +72,7 @@ int file_write_dep(const char *name)
72} 72}
73 73
74 74
75/* Allocate initial growable sting */ 75/* Allocate initial growable string */
76struct gstr str_new(void) 76struct gstr str_new(void)
77{ 77{
78 struct gstr gs; 78 struct gstr gs;
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 241310e59cd6..cdb6dc1f6458 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -13,8 +13,6 @@ use strict;
13## This software falls under the GNU General Public License. ## 13## This software falls under the GNU General Public License. ##
14## Please read the COPYING file for more information ## 14## Please read the COPYING file for more information ##
15 15
16# w.o. 03-11-2000: added the '-filelist' option.
17
18# 18/01/2001 - Cleanups 16# 18/01/2001 - Cleanups
19# Functions prototyped as foo(void) same as foo() 17# Functions prototyped as foo(void) same as foo()
20# Stop eval'ing where we don't need to. 18# Stop eval'ing where we don't need to.
@@ -46,12 +44,13 @@ use strict;
46# Note: This only supports 'c'. 44# Note: This only supports 'c'.
47 45
48# usage: 46# usage:
49# kernel-doc [ -docbook | -html | -text | -man ] [ -no-doc-sections ] 47# kernel-doc [ -docbook | -html | -text | -man | -list ] [ -no-doc-sections ]
50# [ -function funcname [ -function funcname ...] ] c file(s)s > outputfile 48# [ -function funcname [ -function funcname ...] ] c file(s)s > outputfile
51# or 49# or
52# [ -nofunction funcname [ -function funcname ...] ] c file(s)s > outputfile 50# [ -nofunction funcname [ -function funcname ...] ] c file(s)s > outputfile
53# 51#
54# Set output format using one of -docbook -html -text or -man. Default is man. 52# Set output format using one of -docbook -html -text or -man. Default is man.
53# The -list format is for internal use by docproc.
55# 54#
56# -no-doc-sections 55# -no-doc-sections
57# Do not output DOC: sections 56# Do not output DOC: sections
@@ -212,9 +211,16 @@ my %highlights_text = ( $type_constant, "\$1",
212 $type_param, "\$1" ); 211 $type_param, "\$1" );
213my $blankline_text = ""; 212my $blankline_text = "";
214 213
214# list mode
215my %highlights_list = ( $type_constant, "\$1",
216 $type_func, "\$1",
217 $type_struct, "\$1",
218 $type_param, "\$1" );
219my $blankline_list = "";
215 220
216sub usage { 221sub usage {
217 print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man ] [ -no-doc-sections ]\n"; 222 print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man | -list ]\n";
223 print " [ -no-doc-sections ]\n";
218 print " [ -function funcname [ -function funcname ...] ]\n"; 224 print " [ -function funcname [ -function funcname ...] ]\n";
219 print " [ -nofunction funcname [ -nofunction funcname ...] ]\n"; 225 print " [ -nofunction funcname [ -nofunction funcname ...] ]\n";
220 print " c source file(s) > outputfile\n"; 226 print " c source file(s) > outputfile\n";
@@ -245,7 +251,7 @@ my $man_date = ('January', 'February', 'March', 'April', 'May', 'June',
245# could cause "use of undefined value" or other bugs. 251# could cause "use of undefined value" or other bugs.
246my ($function, %function_table, %parametertypes, $declaration_purpose); 252my ($function, %function_table, %parametertypes, $declaration_purpose);
247my ($type, $declaration_name, $return_type); 253my ($type, $declaration_name, $return_type);
248my ($newsection, $newcontents, $prototype, $filelist, $brcount, %source_map); 254my ($newsection, $newcontents, $prototype, $brcount, %source_map);
249 255
250if (defined($ENV{'KBUILD_VERBOSE'})) { 256if (defined($ENV{'KBUILD_VERBOSE'})) {
251 $verbose = "$ENV{'KBUILD_VERBOSE'}"; 257 $verbose = "$ENV{'KBUILD_VERBOSE'}";
@@ -320,6 +326,10 @@ while ($ARGV[0] =~ m/^-(.*)/) {
320 $output_mode = "xml"; 326 $output_mode = "xml";
321 %highlights = %highlights_xml; 327 %highlights = %highlights_xml;
322 $blankline = $blankline_xml; 328 $blankline = $blankline_xml;
329 } elsif ($cmd eq "-list") {
330 $output_mode = "list";
331 %highlights = %highlights_list;
332 $blankline = $blankline_list;
323 } elsif ($cmd eq "-gnome") { 333 } elsif ($cmd eq "-gnome") {
324 $output_mode = "gnome"; 334 $output_mode = "gnome";
325 %highlights = %highlights_gnome; 335 %highlights = %highlights_gnome;
@@ -338,8 +348,6 @@ while ($ARGV[0] =~ m/^-(.*)/) {
338 $verbose = 1; 348 $verbose = 1;
339 } elsif (($cmd eq "-h") || ($cmd eq "--help")) { 349 } elsif (($cmd eq "-h") || ($cmd eq "--help")) {
340 usage(); 350 usage();
341 } elsif ($cmd eq '-filelist') {
342 $filelist = shift @ARGV;
343 } elsif ($cmd eq '-no-doc-sections') { 351 } elsif ($cmd eq '-no-doc-sections') {
344 $no_doc_sections = 1; 352 $no_doc_sections = 1;
345 } 353 }
@@ -1365,6 +1373,42 @@ sub output_blockhead_text(%) {
1365 } 1373 }
1366} 1374}
1367 1375
1376## list mode output functions
1377
1378sub output_function_list(%) {
1379 my %args = %{$_[0]};
1380
1381 print $args{'function'} . "\n";
1382}
1383
1384# output enum in list
1385sub output_enum_list(%) {
1386 my %args = %{$_[0]};
1387 print $args{'enum'} . "\n";
1388}
1389
1390# output typedef in list
1391sub output_typedef_list(%) {
1392 my %args = %{$_[0]};
1393 print $args{'typedef'} . "\n";
1394}
1395
1396# output struct as list
1397sub output_struct_list(%) {
1398 my %args = %{$_[0]};
1399
1400 print $args{'struct'} . "\n";
1401}
1402
1403sub output_blockhead_list(%) {
1404 my %args = %{$_[0]};
1405 my ($parameter, $section);
1406
1407 foreach $section (@{$args{'sectionlist'}}) {
1408 print "DOC: $section\n";
1409 }
1410}
1411
1368## 1412##
1369# generic output function for all types (function, struct/union, typedef, enum); 1413# generic output function for all types (function, struct/union, typedef, enum);
1370# calls the generated, variable output_ function name based on 1414# calls the generated, variable output_ function name based on
@@ -1428,6 +1472,8 @@ sub dump_struct($$) {
1428 $nested =~ s/\/\*.*?\*\///gos; 1472 $nested =~ s/\/\*.*?\*\///gos;
1429 # strip kmemcheck_bitfield_{begin,end}.*; 1473 # strip kmemcheck_bitfield_{begin,end}.*;
1430 $members =~ s/kmemcheck_bitfield_.*?;//gos; 1474 $members =~ s/kmemcheck_bitfield_.*?;//gos;
1475 # strip attributes
1476 $members =~ s/__aligned\s*\(\d+\)//gos;
1431 1477
1432 create_parameterlist($members, ';', $file); 1478 create_parameterlist($members, ';', $file);
1433 check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested); 1479 check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested);
@@ -1456,6 +1502,8 @@ sub dump_enum($$) {
1456 my $file = shift; 1502 my $file = shift;
1457 1503
1458 $x =~ s@/\*.*?\*/@@gos; # strip comments. 1504 $x =~ s@/\*.*?\*/@@gos; # strip comments.
1505 $x =~ s/^#\s*define\s+.*$//; # strip #define macros inside enums
1506
1459 if ($x =~ /enum\s+(\w+)\s*{(.*)}/) { 1507 if ($x =~ /enum\s+(\w+)\s*{(.*)}/) {
1460 $declaration_name = $1; 1508 $declaration_name = $1;
1461 my $members = $2; 1509 my $members = $2;
@@ -1679,7 +1727,7 @@ sub check_sections($$$$$$) {
1679 foreach $px (0 .. $#prms) { 1727 foreach $px (0 .. $#prms) {
1680 $prm_clean = $prms[$px]; 1728 $prm_clean = $prms[$px];
1681 $prm_clean =~ s/\[.*\]//; 1729 $prm_clean =~ s/\[.*\]//;
1682 $prm_clean =~ s/__attribute__\s*\(\([a-z,_\*\s\(\)]*\)\)//; 1730 $prm_clean =~ s/__attribute__\s*\(\([a-z,_\*\s\(\)]*\)\)//i;
1683 # ignore array size in a parameter string; 1731 # ignore array size in a parameter string;
1684 # however, the original param string may contain 1732 # however, the original param string may contain
1685 # spaces, e.g.: addr[6 + 2] 1733 # spaces, e.g.: addr[6 + 2]
@@ -1732,6 +1780,7 @@ sub dump_function($$) {
1732 $prototype =~ s/^noinline +//; 1780 $prototype =~ s/^noinline +//;
1733 $prototype =~ s/__devinit +//; 1781 $prototype =~ s/__devinit +//;
1734 $prototype =~ s/__init +//; 1782 $prototype =~ s/__init +//;
1783 $prototype =~ s/__init_or_module +//;
1735 $prototype =~ s/^#\s*define\s+//; #ak added 1784 $prototype =~ s/^#\s*define\s+//; #ak added
1736 $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//; 1785 $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//;
1737 1786
@@ -1811,14 +1860,6 @@ if (open(SOURCE_MAP, "<.tmp_filelist.txt")) {
1811 close(SOURCE_MAP); 1860 close(SOURCE_MAP);
1812} 1861}
1813 1862
1814if ($filelist) {
1815 open(FLIST,"<$filelist") or die "Can't open file list $filelist";
1816 while(<FLIST>) {
1817 chop;
1818 process_file($_);
1819 }
1820}
1821
1822foreach (@ARGV) { 1863foreach (@ARGV) {
1823 chomp; 1864 chomp;
1824 process_file($_); 1865 process_file($_);
@@ -2023,6 +2064,8 @@ sub process_file($) {
2023 return; 2064 return;
2024 } 2065 }
2025 2066
2067 $. = 1;
2068
2026 $section_counter = 0; 2069 $section_counter = 0;
2027 while (<IN>) { 2070 while (<IN>) {
2028 if ($state == 0) { 2071 if ($state == 0) {
@@ -2113,7 +2156,7 @@ sub process_file($) {
2113 $section = $newsection; 2156 $section = $newsection;
2114 } elsif (/$doc_end/) { 2157 } elsif (/$doc_end/) {
2115 2158
2116 if ($contents ne "") { 2159 if (($contents ne "") && ($contents ne "\n")) {
2117 dump_section($file, $section, xml_escape($contents)); 2160 dump_section($file, $section, xml_escape($contents));
2118 $section = $section_default; 2161 $section = $section_default;
2119 $contents = ""; 2162 $contents = "";
diff --git a/scripts/markup_oops.pl b/scripts/markup_oops.pl
index 90e1d9aa35b5..827896f56501 100644
--- a/scripts/markup_oops.pl
+++ b/scripts/markup_oops.pl
@@ -168,7 +168,7 @@ while (<STDIN>) {
168 $function = $1; 168 $function = $1;
169 $func_offset = $2; 169 $func_offset = $2;
170 } 170 }
171 if ($line =~ /RIP: 0010:\[\<[0-9a-f]+\>\] \[\<[0-9a-f]+\>\] ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]/) { 171 if ($line =~ /RIP: 0010:\[\<[0-9a-f]+\>\] \[\<[0-9a-f]+\>\] ([a-zA-Z0-9\_]+)\+0x([0-9a-f]+)\/0x[a-f0-9]/) {
172 $function = $1; 172 $function = $1;
173 $func_offset = $2; 173 $func_offset = $2;
174 } 174 }
diff --git a/scripts/mkmakefile b/scripts/mkmakefile
index 67d59c7a18dc..5325423ceab4 100644
--- a/scripts/mkmakefile
+++ b/scripts/mkmakefile
@@ -44,7 +44,9 @@ all:
44 44
45Makefile:; 45Makefile:;
46 46
47\$(all) %/: all 47\$(all): all
48 @: 48 @:
49 49
50%/: all
51 @:
50EOF 52EOF
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 220213e603db..88f3f07205f8 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -796,6 +796,51 @@ static int do_platform_entry(const char *filename,
796 return 1; 796 return 1;
797} 797}
798 798
799static int do_mdio_entry(const char *filename,
800 struct mdio_device_id *id, char *alias)
801{
802 int i;
803
804 alias += sprintf(alias, MDIO_MODULE_PREFIX);
805
806 for (i = 0; i < 32; i++) {
807 if (!((id->phy_id_mask >> (31-i)) & 1))
808 *(alias++) = '?';
809 else if ((id->phy_id >> (31-i)) & 1)
810 *(alias++) = '1';
811 else
812 *(alias++) = '0';
813 }
814
815 /* Terminate the string */
816 *alias = 0;
817
818 return 1;
819}
820
821/* Looks like: zorro:iN. */
822static int do_zorro_entry(const char *filename, struct zorro_device_id *id,
823 char *alias)
824{
825 id->id = TO_NATIVE(id->id);
826 strcpy(alias, "zorro:");
827 ADD(alias, "i", id->id != ZORRO_WILDCARD, id->id);
828 return 1;
829}
830
831/* looks like: "pnp:dD" */
832static int do_isapnp_entry(const char *filename,
833 struct isapnp_device_id *id, char *alias)
834{
835 sprintf(alias, "pnp:d%c%c%c%x%x%x%x*",
836 'A' + ((id->vendor >> 2) & 0x3f) - 1,
837 'A' + (((id->vendor & 3) << 3) | ((id->vendor >> 13) & 7)) - 1,
838 'A' + ((id->vendor >> 8) & 0x1f) - 1,
839 (id->function >> 4) & 0x0f, id->function & 0x0f,
840 (id->function >> 12) & 0x0f, (id->function >> 8) & 0x0f);
841 return 1;
842}
843
799/* Ignore any prefix, eg. some architectures prepend _ */ 844/* Ignore any prefix, eg. some architectures prepend _ */
800static inline int sym_is(const char *symbol, const char *name) 845static inline int sym_is(const char *symbol, const char *name)
801{ 846{
@@ -839,16 +884,16 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
839 char *zeros = NULL; 884 char *zeros = NULL;
840 885
841 /* We're looking for a section relative symbol */ 886 /* We're looking for a section relative symbol */
842 if (!sym->st_shndx || sym->st_shndx >= info->hdr->e_shnum) 887 if (!sym->st_shndx || get_secindex(info, sym) >= info->num_sections)
843 return; 888 return;
844 889
845 /* Handle all-NULL symbols allocated into .bss */ 890 /* Handle all-NULL symbols allocated into .bss */
846 if (info->sechdrs[sym->st_shndx].sh_type & SHT_NOBITS) { 891 if (info->sechdrs[get_secindex(info, sym)].sh_type & SHT_NOBITS) {
847 zeros = calloc(1, sym->st_size); 892 zeros = calloc(1, sym->st_size);
848 symval = zeros; 893 symval = zeros;
849 } else { 894 } else {
850 symval = (void *)info->hdr 895 symval = (void *)info->hdr
851 + info->sechdrs[sym->st_shndx].sh_offset 896 + info->sechdrs[get_secindex(info, sym)].sh_offset
852 + sym->st_value; 897 + sym->st_value;
853 } 898 }
854 899
@@ -943,6 +988,18 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
943 do_table(symval, sym->st_size, 988 do_table(symval, sym->st_size,
944 sizeof(struct platform_device_id), "platform", 989 sizeof(struct platform_device_id), "platform",
945 do_platform_entry, mod); 990 do_platform_entry, mod);
991 else if (sym_is(symname, "__mod_mdio_device_table"))
992 do_table(symval, sym->st_size,
993 sizeof(struct mdio_device_id), "mdio",
994 do_mdio_entry, mod);
995 else if (sym_is(symname, "__mod_zorro_device_table"))
996 do_table(symval, sym->st_size,
997 sizeof(struct zorro_device_id), "zorro",
998 do_zorro_entry, mod);
999 else if (sym_is(symname, "__mod_isapnp_device_table"))
1000 do_table(symval, sym->st_size,
1001 sizeof(struct isapnp_device_id), "isa",
1002 do_isapnp_entry, mod);
946 free(zeros); 1003 free(zeros);
947} 1004}
948 1005
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 3318692e4e76..1ec7158b6c1f 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -14,6 +14,7 @@
14#define _GNU_SOURCE 14#define _GNU_SOURCE
15#include <stdio.h> 15#include <stdio.h>
16#include <ctype.h> 16#include <ctype.h>
17#include <string.h>
17#include "modpost.h" 18#include "modpost.h"
18#include "../../include/generated/autoconf.h" 19#include "../../include/generated/autoconf.h"
19#include "../../include/linux/license.h" 20#include "../../include/linux/license.h"
@@ -253,7 +254,7 @@ static enum export export_no(const char *s)
253 return export_unknown; 254 return export_unknown;
254} 255}
255 256
256static enum export export_from_sec(struct elf_info *elf, Elf_Section sec) 257static enum export export_from_sec(struct elf_info *elf, unsigned int sec)
257{ 258{
258 if (sec == elf->export_sec) 259 if (sec == elf->export_sec)
259 return export_plain; 260 return export_plain;
@@ -373,6 +374,8 @@ static int parse_elf(struct elf_info *info, const char *filename)
373 Elf_Ehdr *hdr; 374 Elf_Ehdr *hdr;
374 Elf_Shdr *sechdrs; 375 Elf_Shdr *sechdrs;
375 Elf_Sym *sym; 376 Elf_Sym *sym;
377 const char *secstrings;
378 unsigned int symtab_idx = ~0U, symtab_shndx_idx = ~0U;
376 379
377 hdr = grab_file(filename, &info->size); 380 hdr = grab_file(filename, &info->size);
378 if (!hdr) { 381 if (!hdr) {
@@ -417,8 +420,27 @@ static int parse_elf(struct elf_info *info, const char *filename)
417 return 0; 420 return 0;
418 } 421 }
419 422
423 if (hdr->e_shnum == 0) {
424 /*
425 * There are more than 64k sections,
426 * read count from .sh_size.
427 * note: it doesn't need shndx2secindex()
428 */
429 info->num_sections = TO_NATIVE(sechdrs[0].sh_size);
430 }
431 else {
432 info->num_sections = hdr->e_shnum;
433 }
434 if (hdr->e_shstrndx == SHN_XINDEX) {
435 info->secindex_strings =
436 shndx2secindex(TO_NATIVE(sechdrs[0].sh_link));
437 }
438 else {
439 info->secindex_strings = hdr->e_shstrndx;
440 }
441
420 /* Fix endianness in section headers */ 442 /* Fix endianness in section headers */
421 for (i = 0; i < hdr->e_shnum; i++) { 443 for (i = 0; i < info->num_sections; i++) {
422 sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name); 444 sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name);
423 sechdrs[i].sh_type = TO_NATIVE(sechdrs[i].sh_type); 445 sechdrs[i].sh_type = TO_NATIVE(sechdrs[i].sh_type);
424 sechdrs[i].sh_flags = TO_NATIVE(sechdrs[i].sh_flags); 446 sechdrs[i].sh_flags = TO_NATIVE(sechdrs[i].sh_flags);
@@ -431,9 +453,8 @@ static int parse_elf(struct elf_info *info, const char *filename)
431 sechdrs[i].sh_entsize = TO_NATIVE(sechdrs[i].sh_entsize); 453 sechdrs[i].sh_entsize = TO_NATIVE(sechdrs[i].sh_entsize);
432 } 454 }
433 /* Find symbol table. */ 455 /* Find symbol table. */
434 for (i = 1; i < hdr->e_shnum; i++) { 456 secstrings = (void *)hdr + sechdrs[info->secindex_strings].sh_offset;
435 const char *secstrings 457 for (i = 1; i < info->num_sections; i++) {
436 = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
437 const char *secname; 458 const char *secname;
438 int nobits = sechdrs[i].sh_type == SHT_NOBITS; 459 int nobits = sechdrs[i].sh_type == SHT_NOBITS;
439 460
@@ -461,14 +482,26 @@ static int parse_elf(struct elf_info *info, const char *filename)
461 else if (strcmp(secname, "__ksymtab_gpl_future") == 0) 482 else if (strcmp(secname, "__ksymtab_gpl_future") == 0)
462 info->export_gpl_future_sec = i; 483 info->export_gpl_future_sec = i;
463 484
464 if (sechdrs[i].sh_type != SHT_SYMTAB) 485 if (sechdrs[i].sh_type == SHT_SYMTAB) {
465 continue; 486 unsigned int sh_link_idx;
487 symtab_idx = i;
488 info->symtab_start = (void *)hdr +
489 sechdrs[i].sh_offset;
490 info->symtab_stop = (void *)hdr +
491 sechdrs[i].sh_offset + sechdrs[i].sh_size;
492 sh_link_idx = shndx2secindex(sechdrs[i].sh_link);
493 info->strtab = (void *)hdr +
494 sechdrs[sh_link_idx].sh_offset;
495 }
466 496
467 info->symtab_start = (void *)hdr + sechdrs[i].sh_offset; 497 /* 32bit section no. table? ("more than 64k sections") */
468 info->symtab_stop = (void *)hdr + sechdrs[i].sh_offset 498 if (sechdrs[i].sh_type == SHT_SYMTAB_SHNDX) {
469 + sechdrs[i].sh_size; 499 symtab_shndx_idx = i;
470 info->strtab = (void *)hdr + 500 info->symtab_shndx_start = (void *)hdr +
471 sechdrs[sechdrs[i].sh_link].sh_offset; 501 sechdrs[i].sh_offset;
502 info->symtab_shndx_stop = (void *)hdr +
503 sechdrs[i].sh_offset + sechdrs[i].sh_size;
504 }
472 } 505 }
473 if (!info->symtab_start) 506 if (!info->symtab_start)
474 fatal("%s has no symtab?\n", filename); 507 fatal("%s has no symtab?\n", filename);
@@ -480,6 +513,21 @@ static int parse_elf(struct elf_info *info, const char *filename)
480 sym->st_value = TO_NATIVE(sym->st_value); 513 sym->st_value = TO_NATIVE(sym->st_value);
481 sym->st_size = TO_NATIVE(sym->st_size); 514 sym->st_size = TO_NATIVE(sym->st_size);
482 } 515 }
516
517 if (symtab_shndx_idx != ~0U) {
518 Elf32_Word *p;
519 if (symtab_idx !=
520 shndx2secindex(sechdrs[symtab_shndx_idx].sh_link))
521 fatal("%s: SYMTAB_SHNDX has bad sh_link: %u!=%u\n",
522 filename,
523 shndx2secindex(sechdrs[symtab_shndx_idx].sh_link),
524 symtab_idx);
525 /* Fix endianness */
526 for (p = info->symtab_shndx_start; p < info->symtab_shndx_stop;
527 p++)
528 *p = TO_NATIVE(*p);
529 }
530
483 return 1; 531 return 1;
484} 532}
485 533
@@ -503,6 +551,11 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname)
503 strncmp(symname, "_rest32gpr_", sizeof("_rest32gpr_") - 1) == 0 || 551 strncmp(symname, "_rest32gpr_", sizeof("_rest32gpr_") - 1) == 0 ||
504 strncmp(symname, "_save32gpr_", sizeof("_save32gpr_") - 1) == 0) 552 strncmp(symname, "_save32gpr_", sizeof("_save32gpr_") - 1) == 0)
505 return 1; 553 return 1;
554 if (info->hdr->e_machine == EM_PPC64)
555 /* Special register function linked on all modules during final link of .ko */
556 if (strncmp(symname, "_restgpr0_", sizeof("_restgpr0_") - 1) == 0 ||
557 strncmp(symname, "_savegpr0_", sizeof("_savegpr0_") - 1) == 0)
558 return 1;
506 /* Do not ignore this symbol */ 559 /* Do not ignore this symbol */
507 return 0; 560 return 0;
508} 561}
@@ -514,7 +567,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
514 Elf_Sym *sym, const char *symname) 567 Elf_Sym *sym, const char *symname)
515{ 568{
516 unsigned int crc; 569 unsigned int crc;
517 enum export export = export_from_sec(info, sym->st_shndx); 570 enum export export = export_from_sec(info, get_secindex(info, sym));
518 571
519 switch (sym->st_shndx) { 572 switch (sym->st_shndx) {
520 case SHN_COMMON: 573 case SHN_COMMON:
@@ -656,19 +709,19 @@ static const char *sym_name(struct elf_info *elf, Elf_Sym *sym)
656 return "(unknown)"; 709 return "(unknown)";
657} 710}
658 711
659static const char *sec_name(struct elf_info *elf, int shndx) 712static const char *sec_name(struct elf_info *elf, int secindex)
660{ 713{
661 Elf_Shdr *sechdrs = elf->sechdrs; 714 Elf_Shdr *sechdrs = elf->sechdrs;
662 return (void *)elf->hdr + 715 return (void *)elf->hdr +
663 elf->sechdrs[elf->hdr->e_shstrndx].sh_offset + 716 elf->sechdrs[elf->secindex_strings].sh_offset +
664 sechdrs[shndx].sh_name; 717 sechdrs[secindex].sh_name;
665} 718}
666 719
667static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr) 720static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr)
668{ 721{
669 return (void *)elf->hdr + 722 return (void *)elf->hdr +
670 elf->sechdrs[elf->hdr->e_shstrndx].sh_offset + 723 elf->sechdrs[elf->secindex_strings].sh_offset +
671 sechdr->sh_name; 724 sechdr->sh_name;
672} 725}
673 726
674/* if sym is empty or point to a string 727/* if sym is empty or point to a string
@@ -737,6 +790,7 @@ static const char *section_white_list[] =
737{ 790{
738 ".comment*", 791 ".comment*",
739 ".debug*", 792 ".debug*",
793 ".GCC-command-line", /* mn10300 */
740 ".mdebug*", /* alpha, score, mips etc. */ 794 ".mdebug*", /* alpha, score, mips etc. */
741 ".pdr", /* alpha, score, mips etc. */ 795 ".pdr", /* alpha, score, mips etc. */
742 ".stab*", 796 ".stab*",
@@ -981,6 +1035,13 @@ static const struct sectioncheck *section_mismatch(
981 * fromsec = .data* 1035 * fromsec = .data*
982 * atsym =__param* 1036 * atsym =__param*
983 * 1037 *
1038 * Pattern 1a:
1039 * module_param_call() ops can refer to __init set function if permissions=0
1040 * The pattern is identified by:
1041 * tosec = .init.text
1042 * fromsec = .data*
1043 * atsym = __param_ops_*
1044 *
984 * Pattern 2: 1045 * Pattern 2:
985 * Many drivers utilise a *driver container with references to 1046 * Many drivers utilise a *driver container with references to
986 * add, remove, probe functions etc. 1047 * add, remove, probe functions etc.
@@ -1015,6 +1076,12 @@ static int secref_whitelist(const struct sectioncheck *mismatch,
1015 (strncmp(fromsym, "__param", strlen("__param")) == 0)) 1076 (strncmp(fromsym, "__param", strlen("__param")) == 0))
1016 return 0; 1077 return 0;
1017 1078
1079 /* Check for pattern 1a */
1080 if (strcmp(tosec, ".init.text") == 0 &&
1081 match(fromsec, data_sections) &&
1082 (strncmp(fromsym, "__param_ops_", strlen("__param_ops_")) == 0))
1083 return 0;
1084
1018 /* Check for pattern 2 */ 1085 /* Check for pattern 2 */
1019 if (match(tosec, init_exit_sections) && 1086 if (match(tosec, init_exit_sections) &&
1020 match(fromsec, data_sections) && 1087 match(fromsec, data_sections) &&
@@ -1047,11 +1114,14 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
1047 Elf_Sym *near = NULL; 1114 Elf_Sym *near = NULL;
1048 Elf64_Sword distance = 20; 1115 Elf64_Sword distance = 20;
1049 Elf64_Sword d; 1116 Elf64_Sword d;
1117 unsigned int relsym_secindex;
1050 1118
1051 if (relsym->st_name != 0) 1119 if (relsym->st_name != 0)
1052 return relsym; 1120 return relsym;
1121
1122 relsym_secindex = get_secindex(elf, relsym);
1053 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { 1123 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {
1054 if (sym->st_shndx != relsym->st_shndx) 1124 if (get_secindex(elf, sym) != relsym_secindex)
1055 continue; 1125 continue;
1056 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) 1126 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
1057 continue; 1127 continue;
@@ -1113,9 +1183,9 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr,
1113 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { 1183 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {
1114 const char *symsec; 1184 const char *symsec;
1115 1185
1116 if (sym->st_shndx >= SHN_LORESERVE) 1186 if (is_shndx_special(sym->st_shndx))
1117 continue; 1187 continue;
1118 symsec = sec_name(elf, sym->st_shndx); 1188 symsec = sec_name(elf, get_secindex(elf, sym));
1119 if (strcmp(symsec, sec) != 0) 1189 if (strcmp(symsec, sec) != 0)
1120 continue; 1190 continue;
1121 if (!is_valid_name(elf, sym)) 1191 if (!is_valid_name(elf, sym))
@@ -1162,7 +1232,7 @@ static char *sec2annotation(const char *s)
1162 strcat(p, " "); 1232 strcat(p, " ");
1163 return r; /* we leak her but we do not care */ 1233 return r; /* we leak her but we do not care */
1164 } else { 1234 } else {
1165 return ""; 1235 return strdup("");
1166 } 1236 }
1167} 1237}
1168 1238
@@ -1190,6 +1260,8 @@ static void report_sec_mismatch(const char *modname,
1190{ 1260{
1191 const char *from, *from_p; 1261 const char *from, *from_p;
1192 const char *to, *to_p; 1262 const char *to, *to_p;
1263 char *prl_from;
1264 char *prl_to;
1193 1265
1194 switch (from_is_func) { 1266 switch (from_is_func) {
1195 case 0: from = "variable"; from_p = ""; break; 1267 case 0: from = "variable"; from_p = ""; break;
@@ -1213,16 +1285,21 @@ static void report_sec_mismatch(const char *modname,
1213 1285
1214 switch (mismatch->mismatch) { 1286 switch (mismatch->mismatch) {
1215 case TEXT_TO_ANY_INIT: 1287 case TEXT_TO_ANY_INIT:
1288 prl_from = sec2annotation(fromsec);
1289 prl_to = sec2annotation(tosec);
1216 fprintf(stderr, 1290 fprintf(stderr,
1217 "The function %s%s() references\n" 1291 "The function %s%s() references\n"
1218 "the %s %s%s%s.\n" 1292 "the %s %s%s%s.\n"
1219 "This is often because %s lacks a %s\n" 1293 "This is often because %s lacks a %s\n"
1220 "annotation or the annotation of %s is wrong.\n", 1294 "annotation or the annotation of %s is wrong.\n",
1221 sec2annotation(fromsec), fromsym, 1295 prl_from, fromsym,
1222 to, sec2annotation(tosec), tosym, to_p, 1296 to, prl_to, tosym, to_p,
1223 fromsym, sec2annotation(tosec), tosym); 1297 fromsym, prl_to, tosym);
1298 free(prl_from);
1299 free(prl_to);
1224 break; 1300 break;
1225 case DATA_TO_ANY_INIT: { 1301 case DATA_TO_ANY_INIT: {
1302 prl_to = sec2annotation(tosec);
1226 const char *const *s = mismatch->symbol_white_list; 1303 const char *const *s = mismatch->symbol_white_list;
1227 fprintf(stderr, 1304 fprintf(stderr,
1228 "The variable %s references\n" 1305 "The variable %s references\n"
@@ -1230,20 +1307,24 @@ static void report_sec_mismatch(const char *modname,
1230 "If the reference is valid then annotate the\n" 1307 "If the reference is valid then annotate the\n"
1231 "variable with __init* or __refdata (see linux/init.h) " 1308 "variable with __init* or __refdata (see linux/init.h) "
1232 "or name the variable:\n", 1309 "or name the variable:\n",
1233 fromsym, to, sec2annotation(tosec), tosym, to_p); 1310 fromsym, to, prl_to, tosym, to_p);
1234 while (*s) 1311 while (*s)
1235 fprintf(stderr, "%s, ", *s++); 1312 fprintf(stderr, "%s, ", *s++);
1236 fprintf(stderr, "\n"); 1313 fprintf(stderr, "\n");
1314 free(prl_to);
1237 break; 1315 break;
1238 } 1316 }
1239 case TEXT_TO_ANY_EXIT: 1317 case TEXT_TO_ANY_EXIT:
1318 prl_to = sec2annotation(tosec);
1240 fprintf(stderr, 1319 fprintf(stderr,
1241 "The function %s() references a %s in an exit section.\n" 1320 "The function %s() references a %s in an exit section.\n"
1242 "Often the %s %s%s has valid usage outside the exit section\n" 1321 "Often the %s %s%s has valid usage outside the exit section\n"
1243 "and the fix is to remove the %sannotation of %s.\n", 1322 "and the fix is to remove the %sannotation of %s.\n",
1244 fromsym, to, to, tosym, to_p, sec2annotation(tosec), tosym); 1323 fromsym, to, to, tosym, to_p, prl_to, tosym);
1324 free(prl_to);
1245 break; 1325 break;
1246 case DATA_TO_ANY_EXIT: { 1326 case DATA_TO_ANY_EXIT: {
1327 prl_to = sec2annotation(tosec);
1247 const char *const *s = mismatch->symbol_white_list; 1328 const char *const *s = mismatch->symbol_white_list;
1248 fprintf(stderr, 1329 fprintf(stderr,
1249 "The variable %s references\n" 1330 "The variable %s references\n"
@@ -1251,24 +1332,31 @@ static void report_sec_mismatch(const char *modname,
1251 "If the reference is valid then annotate the\n" 1332 "If the reference is valid then annotate the\n"
1252 "variable with __exit* (see linux/init.h) or " 1333 "variable with __exit* (see linux/init.h) or "
1253 "name the variable:\n", 1334 "name the variable:\n",
1254 fromsym, to, sec2annotation(tosec), tosym, to_p); 1335 fromsym, to, prl_to, tosym, to_p);
1255 while (*s) 1336 while (*s)
1256 fprintf(stderr, "%s, ", *s++); 1337 fprintf(stderr, "%s, ", *s++);
1257 fprintf(stderr, "\n"); 1338 fprintf(stderr, "\n");
1339 free(prl_to);
1258 break; 1340 break;
1259 } 1341 }
1260 case XXXINIT_TO_SOME_INIT: 1342 case XXXINIT_TO_SOME_INIT:
1261 case XXXEXIT_TO_SOME_EXIT: 1343 case XXXEXIT_TO_SOME_EXIT:
1344 prl_from = sec2annotation(fromsec);
1345 prl_to = sec2annotation(tosec);
1262 fprintf(stderr, 1346 fprintf(stderr,
1263 "The %s %s%s%s references\n" 1347 "The %s %s%s%s references\n"
1264 "a %s %s%s%s.\n" 1348 "a %s %s%s%s.\n"
1265 "If %s is only used by %s then\n" 1349 "If %s is only used by %s then\n"
1266 "annotate %s with a matching annotation.\n", 1350 "annotate %s with a matching annotation.\n",
1267 from, sec2annotation(fromsec), fromsym, from_p, 1351 from, prl_from, fromsym, from_p,
1268 to, sec2annotation(tosec), tosym, to_p, 1352 to, prl_to, tosym, to_p,
1269 tosym, fromsym, tosym); 1353 tosym, fromsym, tosym);
1354 free(prl_from);
1355 free(prl_to);
1270 break; 1356 break;
1271 case ANY_INIT_TO_ANY_EXIT: 1357 case ANY_INIT_TO_ANY_EXIT:
1358 prl_from = sec2annotation(fromsec);
1359 prl_to = sec2annotation(tosec);
1272 fprintf(stderr, 1360 fprintf(stderr,
1273 "The %s %s%s%s references\n" 1361 "The %s %s%s%s references\n"
1274 "a %s %s%s%s.\n" 1362 "a %s %s%s%s.\n"
@@ -1277,11 +1365,15 @@ static void report_sec_mismatch(const char *modname,
1277 "uses functionality in the exit path.\n" 1365 "uses functionality in the exit path.\n"
1278 "The fix is often to remove the %sannotation of\n" 1366 "The fix is often to remove the %sannotation of\n"
1279 "%s%s so it may be used outside an exit section.\n", 1367 "%s%s so it may be used outside an exit section.\n",
1280 from, sec2annotation(fromsec), fromsym, from_p, 1368 from, prl_from, fromsym, from_p,
1281 to, sec2annotation(tosec), tosym, to_p, 1369 to, prl_to, tosym, to_p,
1282 sec2annotation(tosec), tosym, to_p); 1370 prl_to, tosym, to_p);
1371 free(prl_from);
1372 free(prl_to);
1283 break; 1373 break;
1284 case ANY_EXIT_TO_ANY_INIT: 1374 case ANY_EXIT_TO_ANY_INIT:
1375 prl_from = sec2annotation(fromsec);
1376 prl_to = sec2annotation(tosec);
1285 fprintf(stderr, 1377 fprintf(stderr,
1286 "The %s %s%s%s references\n" 1378 "The %s %s%s%s references\n"
1287 "a %s %s%s%s.\n" 1379 "a %s %s%s%s.\n"
@@ -1290,16 +1382,20 @@ static void report_sec_mismatch(const char *modname,
1290 "uses functionality in the init path.\n" 1382 "uses functionality in the init path.\n"
1291 "The fix is often to remove the %sannotation of\n" 1383 "The fix is often to remove the %sannotation of\n"
1292 "%s%s so it may be used outside an init section.\n", 1384 "%s%s so it may be used outside an init section.\n",
1293 from, sec2annotation(fromsec), fromsym, from_p, 1385 from, prl_from, fromsym, from_p,
1294 to, sec2annotation(tosec), tosym, to_p, 1386 to, prl_to, tosym, to_p,
1295 sec2annotation(tosec), tosym, to_p); 1387 prl_to, tosym, to_p);
1388 free(prl_from);
1389 free(prl_to);
1296 break; 1390 break;
1297 case EXPORT_TO_INIT_EXIT: 1391 case EXPORT_TO_INIT_EXIT:
1392 prl_to = sec2annotation(tosec);
1298 fprintf(stderr, 1393 fprintf(stderr,
1299 "The symbol %s is exported and annotated %s\n" 1394 "The symbol %s is exported and annotated %s\n"
1300 "Fix this by removing the %sannotation of %s " 1395 "Fix this by removing the %sannotation of %s "
1301 "or drop the export.\n", 1396 "or drop the export.\n",
1302 tosym, sec2annotation(tosec), sec2annotation(tosec), tosym); 1397 tosym, prl_to, prl_to, tosym);
1398 free(prl_to);
1303 break; 1399 break;
1304 } 1400 }
1305 fprintf(stderr, "\n"); 1401 fprintf(stderr, "\n");
@@ -1311,7 +1407,7 @@ static void check_section_mismatch(const char *modname, struct elf_info *elf,
1311 const char *tosec; 1407 const char *tosec;
1312 const struct sectioncheck *mismatch; 1408 const struct sectioncheck *mismatch;
1313 1409
1314 tosec = sec_name(elf, sym->st_shndx); 1410 tosec = sec_name(elf, get_secindex(elf, sym));
1315 mismatch = section_mismatch(fromsec, tosec); 1411 mismatch = section_mismatch(fromsec, tosec);
1316 if (mismatch) { 1412 if (mismatch) {
1317 Elf_Sym *to; 1413 Elf_Sym *to;
@@ -1339,10 +1435,10 @@ static unsigned int *reloc_location(struct elf_info *elf,
1339 Elf_Shdr *sechdr, Elf_Rela *r) 1435 Elf_Shdr *sechdr, Elf_Rela *r)
1340{ 1436{
1341 Elf_Shdr *sechdrs = elf->sechdrs; 1437 Elf_Shdr *sechdrs = elf->sechdrs;
1342 int section = sechdr->sh_info; 1438 int section = shndx2secindex(sechdr->sh_info);
1343 1439
1344 return (void *)elf->hdr + sechdrs[section].sh_offset + 1440 return (void *)elf->hdr + sechdrs[section].sh_offset +
1345 (r->r_offset - sechdrs[section].sh_addr); 1441 r->r_offset - sechdrs[section].sh_addr;
1346} 1442}
1347 1443
1348static int addend_386_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) 1444static int addend_386_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r)
@@ -1447,7 +1543,7 @@ static void section_rela(const char *modname, struct elf_info *elf,
1447 r.r_addend = TO_NATIVE(rela->r_addend); 1543 r.r_addend = TO_NATIVE(rela->r_addend);
1448 sym = elf->symtab_start + r_sym; 1544 sym = elf->symtab_start + r_sym;
1449 /* Skip special sections */ 1545 /* Skip special sections */
1450 if (sym->st_shndx >= SHN_LORESERVE) 1546 if (is_shndx_special(sym->st_shndx))
1451 continue; 1547 continue;
1452 check_section_mismatch(modname, elf, &r, sym, fromsec); 1548 check_section_mismatch(modname, elf, &r, sym, fromsec);
1453 } 1549 }
@@ -1505,7 +1601,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
1505 } 1601 }
1506 sym = elf->symtab_start + r_sym; 1602 sym = elf->symtab_start + r_sym;
1507 /* Skip special sections */ 1603 /* Skip special sections */
1508 if (sym->st_shndx >= SHN_LORESERVE) 1604 if (is_shndx_special(sym->st_shndx))
1509 continue; 1605 continue;
1510 check_section_mismatch(modname, elf, &r, sym, fromsec); 1606 check_section_mismatch(modname, elf, &r, sym, fromsec);
1511 } 1607 }
@@ -1530,7 +1626,7 @@ static void check_sec_ref(struct module *mod, const char *modname,
1530 Elf_Shdr *sechdrs = elf->sechdrs; 1626 Elf_Shdr *sechdrs = elf->sechdrs;
1531 1627
1532 /* Walk through all sections */ 1628 /* Walk through all sections */
1533 for (i = 0; i < elf->hdr->e_shnum; i++) { 1629 for (i = 0; i < elf->num_sections; i++) {
1534 check_section(modname, elf, &elf->sechdrs[i]); 1630 check_section(modname, elf, &elf->sechdrs[i]);
1535 /* We want to process only relocation sections and not .init */ 1631 /* We want to process only relocation sections and not .init */
1536 if (sechdrs[i].sh_type == SHT_RELA) 1632 if (sechdrs[i].sh_type == SHT_RELA)
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index be987a44f250..0388cfccac8d 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -129,8 +129,51 @@ struct elf_info {
129 const char *strtab; 129 const char *strtab;
130 char *modinfo; 130 char *modinfo;
131 unsigned int modinfo_len; 131 unsigned int modinfo_len;
132
133 /* support for 32bit section numbers */
134
135 unsigned int num_sections; /* max_secindex + 1 */
136 unsigned int secindex_strings;
137 /* if Nth symbol table entry has .st_shndx = SHN_XINDEX,
138 * take shndx from symtab_shndx_start[N] instead */
139 Elf32_Word *symtab_shndx_start;
140 Elf32_Word *symtab_shndx_stop;
132}; 141};
133 142
143static inline int is_shndx_special(unsigned int i)
144{
145 return i != SHN_XINDEX && i >= SHN_LORESERVE && i <= SHN_HIRESERVE;
146}
147
148/* shndx is in [0..SHN_LORESERVE) U (SHN_HIRESERVE, 0xfffffff], thus:
149 * shndx == 0 <=> sechdrs[0]
150 * ......
151 * shndx == SHN_LORESERVE-1 <=> sechdrs[SHN_LORESERVE-1]
152 * shndx == SHN_HIRESERVE+1 <=> sechdrs[SHN_LORESERVE]
153 * shndx == SHN_HIRESERVE+2 <=> sechdrs[SHN_LORESERVE+1]
154 * ......
155 * fyi: sym->st_shndx is uint16, SHN_LORESERVE = ff00, SHN_HIRESERVE = ffff,
156 * so basically we map 0000..feff -> 0000..feff
157 * ff00..ffff -> (you are a bad boy, dont do it)
158 * 10000..xxxx -> ff00..(xxxx-0x100)
159 */
160static inline unsigned int shndx2secindex(unsigned int i)
161{
162 if (i <= SHN_HIRESERVE)
163 return i;
164 return i - (SHN_HIRESERVE + 1 - SHN_LORESERVE);
165}
166
167/* Accessor for sym->st_shndx, hides ugliness of "64k sections" */
168static inline unsigned int get_secindex(const struct elf_info *info,
169 const Elf_Sym *sym)
170{
171 if (sym->st_shndx != SHN_XINDEX)
172 return sym->st_shndx;
173 return shndx2secindex(info->symtab_shndx_start[sym -
174 info->symtab_start]);
175}
176
134/* file2alias.c */ 177/* file2alias.c */
135extern unsigned int cross_build; 178extern unsigned int cross_build;
136void handle_moddevtable(struct module *mod, struct elf_info *info, 179void handle_moddevtable(struct module *mod, struct elf_info *info,
diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index 62fcc3a7f4d3..d0b931b994fc 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -44,7 +44,7 @@ rpm-pkg rpm: $(objtree)/kernel.spec FORCE
44 fi 44 fi
45 $(MAKE) clean 45 $(MAKE) clean
46 $(PREV) ln -sf $(srctree) $(KERNELPATH) 46 $(PREV) ln -sf $(srctree) $(KERNELPATH)
47 $(CONFIG_SHELL) $(srctree)/scripts/setlocalversion > $(objtree)/.scmversion 47 $(CONFIG_SHELL) $(srctree)/scripts/setlocalversion --save-scmversion
48 $(PREV) tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/. 48 $(PREV) tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/.
49 $(PREV) rm $(KERNELPATH) 49 $(PREV) rm $(KERNELPATH)
50 rm -f $(objtree)/.scmversion 50 rm -f $(objtree)/.scmversion
@@ -111,13 +111,38 @@ tar%pkg: FORCE
111clean-dirs += $(objtree)/tar-install/ 111clean-dirs += $(objtree)/tar-install/
112 112
113 113
114# perf-pkg - generate a source tarball with perf source
115# ---------------------------------------------------------------------------
116
117perf-tar=perf-$(KERNELVERSION)
118
119quiet_cmd_perf_tar = TAR
120 cmd_perf_tar = \
121git archive --prefix=$(perf-tar)/ HEAD^{tree} \
122 $$(cat $(srctree)/tools/perf/MANIFEST) -o $(perf-tar).tar; \
123mkdir -p $(perf-tar); \
124git rev-parse HEAD > $(perf-tar)/HEAD; \
125tar rf $(perf-tar).tar $(perf-tar)/HEAD; \
126rm -r $(perf-tar); \
127$(if $(findstring tar-src,$@),, \
128$(if $(findstring bz2,$@),bzip2, \
129$(if $(findstring gz,$@),gzip, \
130$(error unknown target $@))) \
131 -f -9 $(perf-tar).tar)
132
133perf-%pkg: FORCE
134 $(call cmd,perf_tar)
135
114# Help text displayed when executing 'make help' 136# Help text displayed when executing 'make help'
115# --------------------------------------------------------------------------- 137# ---------------------------------------------------------------------------
116help: FORCE 138help: FORCE
117 @echo ' rpm-pkg - Build both source and binary RPM kernel packages' 139 @echo ' rpm-pkg - Build both source and binary RPM kernel packages'
118 @echo ' binrpm-pkg - Build only the binary kernel package' 140 @echo ' binrpm-pkg - Build only the binary kernel package'
119 @echo ' deb-pkg - Build the kernel as an deb package' 141 @echo ' deb-pkg - Build the kernel as an deb package'
120 @echo ' tar-pkg - Build the kernel as an uncompressed tarball' 142 @echo ' tar-pkg - Build the kernel as an uncompressed tarball'
121 @echo ' targz-pkg - Build the kernel as a gzip compressed tarball' 143 @echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
122 @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball' 144 @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
145 @echo ' perf-tar-src-pkg - Build $(perf-tar).tar source tarball'
146 @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball'
147 @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball'
123 148
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 07f2fbde2abf..5f1e2fc7f171 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -148,10 +148,11 @@ EOF
148# Generate a control file 148# Generate a control file
149cat <<EOF > debian/control 149cat <<EOF > debian/control
150Source: linux-upstream 150Source: linux-upstream
151Section: admin 151Section: kernel
152Priority: optional 152Priority: optional
153Maintainer: $maintainer 153Maintainer: $maintainer
154Standards-Version: 3.8.1 154Standards-Version: 3.8.4
155Homepage: http://www.kernel.org/
155EOF 156EOF
156 157
157if [ "$ARCH" = "um" ]; then 158if [ "$ARCH" = "um" ]; then
diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index 16ae0dd746e1..15440f55aef6 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -1,6 +1,6 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# Output a simple RPM spec file that uses no fancy features requring 3# Output a simple RPM spec file that uses no fancy features requiring
4# RPM v4. This is intended to work with any RPM distro. 4# RPM v4. This is intended to work with any RPM distro.
5# 5#
6# The only gothic bit here is redefining install_post to avoid 6# The only gothic bit here is redefining install_post to avoid
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index ea6f6e3adaea..e67f05486087 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -136,13 +136,14 @@ my %text_sections = (
136 ".text.unlikely" => 1, 136 ".text.unlikely" => 1,
137); 137);
138 138
139$objdump = "objdump" if ((length $objdump) == 0); 139# Note: we are nice to C-programmers here, thus we skip the '||='-idiom.
140$objcopy = "objcopy" if ((length $objcopy) == 0); 140$objdump = 'objdump' if (!$objdump);
141$cc = "gcc" if ((length $cc) == 0); 141$objcopy = 'objcopy' if (!$objcopy);
142$ld = "ld" if ((length $ld) == 0); 142$cc = 'gcc' if (!$cc);
143$nm = "nm" if ((length $nm) == 0); 143$ld = 'ld' if (!$ld);
144$rm = "rm" if ((length $rm) == 0); 144$nm = 'nm' if (!$nm);
145$mv = "mv" if ((length $mv) == 0); 145$rm = 'rm' if (!$rm);
146$mv = 'mv' if (!$mv);
146 147
147#print STDERR "running: $P '$arch' '$objdump' '$objcopy' '$cc' '$ld' " . 148#print STDERR "running: $P '$arch' '$objdump' '$objcopy' '$cc' '$ld' " .
148# "'$nm' '$rm' '$mv' '$inputfile'\n"; 149# "'$nm' '$rm' '$mv' '$inputfile'\n";
@@ -158,6 +159,7 @@ my $section_regex; # Find the start of a section
158my $function_regex; # Find the name of a function 159my $function_regex; # Find the name of a function
159 # (return offset and func name) 160 # (return offset and func name)
160my $mcount_regex; # Find the call site to mcount (return offset) 161my $mcount_regex; # Find the call site to mcount (return offset)
162my $mcount_adjust; # Address adjustment to mcount offset
161my $alignment; # The .align value to use for $mcount_section 163my $alignment; # The .align value to use for $mcount_section
162my $section_type; # Section header plus possible alignment command 164my $section_type; # Section header plus possible alignment command
163my $can_use_local = 0; # If we can use local function references 165my $can_use_local = 0; # If we can use local function references
@@ -212,6 +214,7 @@ $section_regex = "Disassembly of section\\s+(\\S+):";
212$function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:"; 214$function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:";
213$mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$"; 215$mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$";
214$section_type = '@progbits'; 216$section_type = '@progbits';
217$mcount_adjust = 0;
215$type = ".long"; 218$type = ".long";
216 219
217if ($arch eq "x86_64") { 220if ($arch eq "x86_64") {
@@ -325,7 +328,7 @@ if ($arch eq "x86_64") {
325 # 14: R_MIPS_NONE *ABS* 328 # 14: R_MIPS_NONE *ABS*
326 # 18: 00020021 nop 329 # 18: 00020021 nop
327 if ($is_module eq "0") { 330 if ($is_module eq "0") {
328 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$"; 331 $mcount_regex = "^\\s*([0-9a-fA-F]+): R_MIPS_26\\s+_mcount\$";
329 } else { 332 } else {
330 $mcount_regex = "^\\s*([0-9a-fA-F]+): R_MIPS_HI16\\s+_mcount\$"; 333 $mcount_regex = "^\\s*([0-9a-fA-F]+): R_MIPS_HI16\\s+_mcount\$";
331 } 334 }
@@ -350,6 +353,9 @@ if ($arch eq "x86_64") {
350} elsif ($arch eq "microblaze") { 353} elsif ($arch eq "microblaze") {
351 # Microblaze calls '_mcount' instead of plain 'mcount'. 354 # Microblaze calls '_mcount' instead of plain 'mcount'.
352 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$"; 355 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$";
356} elsif ($arch eq "blackfin") {
357 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s__mcount\$";
358 $mcount_adjust = -4;
353} else { 359} else {
354 die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD"; 360 die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD";
355} 361}
@@ -432,14 +438,14 @@ sub update_funcs
432 438
433 # Loop through all the mcount caller offsets and print a reference 439 # Loop through all the mcount caller offsets and print a reference
434 # to the caller based from the ref_func. 440 # to the caller based from the ref_func.
435 for (my $i=0; $i <= $#offsets; $i++) { 441 if (!$opened) {
436 if (!$opened) { 442 open(FILE, ">$mcount_s") || die "can't create $mcount_s\n";
437 open(FILE, ">$mcount_s") || die "can't create $mcount_s\n"; 443 $opened = 1;
438 $opened = 1; 444 print FILE "\t.section $mcount_section,\"a\",$section_type\n";
439 print FILE "\t.section $mcount_section,\"a\",$section_type\n"; 445 print FILE "\t.align $alignment\n" if (defined($alignment));
440 print FILE "\t.align $alignment\n" if (defined($alignment)); 446 }
441 } 447 foreach my $cur_offset (@offsets) {
442 printf FILE "\t%s %s + %d\n", $type, $ref_func, $offsets[$i] - $offset; 448 printf FILE "\t%s %s + %d\n", $type, $ref_func, $cur_offset - $offset;
443 } 449 }
444} 450}
445 451
@@ -476,11 +482,7 @@ while (<IN>) {
476 $read_headers = 0; 482 $read_headers = 0;
477 483
478 # Only record text sections that we know are safe 484 # Only record text sections that we know are safe
479 if (defined($text_sections{$1})) { 485 $read_function = defined($text_sections{$1});
480 $read_function = 1;
481 } else {
482 $read_function = 0;
483 }
484 # print out any recorded offsets 486 # print out any recorded offsets
485 update_funcs(); 487 update_funcs();
486 488
@@ -514,7 +516,7 @@ while (<IN>) {
514 } 516 }
515 # is this a call site to mcount? If so, record it to print later 517 # is this a call site to mcount? If so, record it to print later
516 if ($text_found && /$mcount_regex/) { 518 if ($text_found && /$mcount_regex/) {
517 $offsets[$#offsets + 1] = hex $1; 519 push(@offsets, (hex $1) + $mcount_adjust);
518 } 520 }
519} 521}
520 522
diff --git a/scripts/selinux/genheaders/genheaders.c b/scripts/selinux/genheaders/genheaders.c
index 24626968055d..58a12c278706 100644
--- a/scripts/selinux/genheaders/genheaders.c
+++ b/scripts/selinux/genheaders/genheaders.c
@@ -81,7 +81,7 @@ int main(int argc, char *argv[])
81 fprintf(fout, "\n"); 81 fprintf(fout, "\n");
82 82
83 for (i = 1; i < isids_len; i++) { 83 for (i = 1; i < isids_len; i++) {
84 char *s = initial_sid_to_string[i]; 84 const char *s = initial_sid_to_string[i];
85 fprintf(fout, "#define SECINITSID_%s", s); 85 fprintf(fout, "#define SECINITSID_%s", s);
86 for (j = 0; j < max(1, 40 - strlen(s)); j++) 86 for (j = 0; j < max(1, 40 - strlen(s)); j++)
87 fprintf(fout, " "); 87 fprintf(fout, " ");
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 46989b88d734..057b6b3c5dfb 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -10,73 +10,162 @@
10# 10#
11 11
12usage() { 12usage() {
13 echo "Usage: $0 [srctree]" >&2 13 echo "Usage: $0 [--save-scmversion] [srctree]" >&2
14 exit 1 14 exit 1
15} 15}
16 16
17cd "${1:-.}" || usage 17scm_only=false
18srctree=.
19if test "$1" = "--save-scmversion"; then
20 scm_only=true
21 shift
22fi
23if test $# -gt 0; then
24 srctree=$1
25 shift
26fi
27if test $# -gt 0 -o ! -d "$srctree"; then
28 usage
29fi
18 30
19# Check for git and a git repo. 31scm_version()
20if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then 32{
33 local short
34 short=false
21 35
22 # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore it, 36 cd "$srctree"
23 # because this version is defined in the top level Makefile. 37 if test -e .scmversion; then
24 if [ -z "`git describe --exact-match 2>/dev/null`" ]; then 38 cat .scmversion
39 return
40 fi
41 if test "$1" = "--short"; then
42 short=true
43 fi
25 44
26 # If we are past a tagged commit (like "v2.6.30-rc5-302-g72357d5"), 45 # Check for git and a git repo.
27 # we pretty print it. 46 if test -d .git && head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
28 if atag="`git describe 2>/dev/null`"; then 47
29 echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}' 48 # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore
49 # it, because this version is defined in the top level Makefile.
50 if [ -z "`git describe --exact-match 2>/dev/null`" ]; then
51
52 # If only the short version is requested, don't bother
53 # running further git commands
54 if $short; then
55 echo "+"
56 return
57 fi
58 # If we are past a tagged commit (like
59 # "v2.6.30-rc5-302-g72357d5"), we pretty print it.
60 if atag="`git describe 2>/dev/null`"; then
61 echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
62
63 # If we don't have a tag at all we print -g{commitish}.
64 else
65 printf '%s%s' -g $head
66 fi
67 fi
30 68
31 # If we don't have a tag at all we print -g{commitish}. 69 # Is this git on svn?
32 else 70 if git config --get svn-remote.svn.url >/dev/null; then
33 printf '%s%s' -g $head 71 printf -- '-svn%s' "`git svn find-rev $head`"
34 fi 72 fi
35 fi
36 73
37 # Is this git on svn? 74 # Update index only on r/w media
38 if git config --get svn-remote.svn.url >/dev/null; then 75 [ -w . ] && git update-index --refresh --unmerged > /dev/null
39 printf -- '-svn%s' "`git svn find-rev $head`"
40 fi
41 76
42 # Update index only on r/w media 77 # Check for uncommitted changes
43 [ -w . ] && git update-index --refresh --unmerged > /dev/null 78 if git diff-index --name-only HEAD | grep -v "^scripts/package" \
79 | read dummy; then
80 printf '%s' -dirty
81 fi
44 82
45 # Check for uncommitted changes 83 # All done with git
46 if git diff-index --name-only HEAD | grep -v "^scripts/package" \ 84 return
47 | read dummy; then
48 printf '%s' -dirty
49 fi 85 fi
50 86
51 # All done with git 87 # Check for mercurial and a mercurial repo.
52 exit 88 if test -d .hg && hgid=`hg id 2>/dev/null`; then
53fi 89 tag=`printf '%s' "$hgid" | cut -s -d' ' -f2`
54 90
55# Check for mercurial and a mercurial repo. 91 # Do we have an untagged version?
56if hgid=`hg id 2>/dev/null`; then 92 if [ -z "$tag" -o "$tag" = tip ]; then
57 tag=`printf '%s' "$hgid" | cut -d' ' -f2` 93 id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`
94 printf '%s%s' -hg "$id"
95 fi
96
97 # Are there uncommitted changes?
98 # These are represented by + after the changeset id.
99 case "$hgid" in
100 *+|*+\ *) printf '%s' -dirty ;;
101 esac
58 102
59 # Do we have an untagged version? 103 # All done with mercurial
60 if [ -z "$tag" -o "$tag" = tip ]; then 104 return
61 id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`
62 printf '%s%s' -hg "$id"
63 fi 105 fi
64 106
65 # Are there uncommitted changes? 107 # Check for svn and a svn repo.
66 # These are represented by + after the changeset id. 108 if rev=`svn info 2>/dev/null | grep '^Last Changed Rev'`; then
67 case "$hgid" in 109 rev=`echo $rev | awk '{print $NF}'`
68 *+|*+\ *) printf '%s' -dirty ;; 110 printf -- '-svn%s' "$rev"
69 esac
70 111
71 # All done with mercurial 112 # All done with svn
113 return
114 fi
115}
116
117collect_files()
118{
119 local file res
120
121 for file; do
122 case "$file" in
123 *\~*)
124 continue
125 ;;
126 esac
127 if test -e "$file"; then
128 res="$res$(cat "$file")"
129 fi
130 done
131 echo "$res"
132}
133
134if $scm_only; then
135 if test ! -e .scmversion; then
136 res=$(scm_version)
137 echo "$res" >.scmversion
138 fi
72 exit 139 exit
73fi 140fi
74 141
75# Check for svn and a svn repo. 142if test -e include/config/auto.conf; then
76if rev=`svn info 2>/dev/null | grep '^Last Changed Rev'`; then 143 . include/config/auto.conf
77 rev=`echo $rev | awk '{print $NF}'` 144else
78 printf -- '-svn%s' "$rev" 145 echo "Error: kernelrelease not valid - run 'make prepare' to update it"
146 exit 1
147fi
79 148
80 # All done with svn 149# localversion* files in the build and source directory
81 exit 150res="$(collect_files localversion*)"
151if test ! "$srctree" -ef .; then
152 res="$res$(collect_files "$srctree"/localversion*)"
153fi
154
155# CONFIG_LOCALVERSION and LOCALVERSION (if set)
156res="${res}${CONFIG_LOCALVERSION}${LOCALVERSION}"
157
158# scm version string if not at a tagged commit
159if test "$CONFIG_LOCALVERSION_AUTO" = "y"; then
160 # full scm version string
161 res="$res$(scm_version)"
162else
163 # apped a plus sign if the repository is not in a clean tagged
164 # state and LOCALVERSION= is not specified
165 if test "${LOCALVERSION+set}" != "set"; then
166 scm=$(scm_version --short)
167 res="$res${scm:++}"
168 fi
82fi 169fi
170
171echo "$res"