diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-06-17 19:55:13 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-06-17 19:55:13 -0400 |
commit | 9d066a252786e1a18484a6283f82614d42a9f4ac (patch) | |
tree | 72188d2f86b3d0c4100257c8d5734f2c648a8bc7 /scripts | |
parent | 79ee2e8f730411a30b271d5f9cdeae189fa66174 (diff) | |
parent | b00345d1994d588fa2687e1238fcd542f0320cba (diff) |
Merge branches 'pm-opp' and 'pm-cpufreq-fixes'
* pm-opp:
PM / OPP: Add 'UNKNOWN' status for shared_opp in struct opp_table
* pm-cpufreq-fixes:
cpufreq: intel_pstate: Adjust _PSS[0] freqeuency if needed
Diffstat (limited to 'scripts')
44 files changed, 1507 insertions, 422 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index b2ab2a92a375..0f82314621f2 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include | |||
@@ -7,6 +7,7 @@ quote := " | |||
7 | squote := ' | 7 | squote := ' |
8 | empty := | 8 | empty := |
9 | space := $(empty) $(empty) | 9 | space := $(empty) $(empty) |
10 | space_escape := _-_SPACE_-_ | ||
10 | 11 | ||
11 | ### | 12 | ### |
12 | # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o | 13 | # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o |
@@ -226,10 +227,10 @@ objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o))) | |||
226 | # See Documentation/kbuild/makefiles.txt for more info | 227 | # See Documentation/kbuild/makefiles.txt for more info |
227 | 228 | ||
228 | ifneq ($(KBUILD_NOCMDDEP),1) | 229 | ifneq ($(KBUILD_NOCMDDEP),1) |
229 | # Check if both arguments has same arguments. Result is empty string if equal. | 230 | # Check if both arguments are the same including their order. Result is empty |
230 | # User may override this check using make KBUILD_NOCMDDEP=1 | 231 | # string if equal. User may override this check using make KBUILD_NOCMDDEP=1 |
231 | arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ | 232 | arg-check = $(filter-out $(subst $(space),$(space_escape),$(strip $(cmd_$@))), \ |
232 | $(filter-out $(cmd_$@), $(cmd_$(1))) ) | 233 | $(subst $(space),$(space_escape),$(strip $(cmd_$1)))) |
233 | else | 234 | else |
234 | arg-check = $(if $(strip $(cmd_$@)),,1) | 235 | arg-check = $(if $(strip $(cmd_$@)),,1) |
235 | endif | 236 | endif |
@@ -256,10 +257,42 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ | |||
256 | # Execute the command and also postprocess generated .d dependencies file. | 257 | # Execute the command and also postprocess generated .d dependencies file. |
257 | if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ | 258 | if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ |
258 | @set -e; \ | 259 | @set -e; \ |
260 | $(cmd_and_fixdep), @:) | ||
261 | |||
262 | ifndef CONFIG_TRIM_UNUSED_KSYMS | ||
263 | |||
264 | cmd_and_fixdep = \ | ||
259 | $(echo-cmd) $(cmd_$(1)); \ | 265 | $(echo-cmd) $(cmd_$(1)); \ |
260 | scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ | 266 | scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ |
261 | rm -f $(depfile); \ | 267 | rm -f $(depfile); \ |
262 | mv -f $(dot-target).tmp $(dot-target).cmd, @:) | 268 | mv -f $(dot-target).tmp $(dot-target).cmd; |
269 | |||
270 | else | ||
271 | |||
272 | # Filter out exported kernel symbol names from the preprocessor output. | ||
273 | # See also __KSYM_DEPS__ in include/linux/export.h. | ||
274 | # We disable the depfile generation here, so as not to overwrite the existing | ||
275 | # depfile while fixdep is parsing it. | ||
276 | flags_nodeps = $(filter-out -Wp$(comma)-M%, $($(1))) | ||
277 | ksym_dep_filter = \ | ||
278 | case "$(1)" in \ | ||
279 | cc_*_c|cpp_i_c) \ | ||
280 | $(CPP) $(call flags_nodeps,c_flags) -D__KSYM_DEPS__ $< ;; \ | ||
281 | as_*_S|cpp_s_S) \ | ||
282 | $(CPP) $(call flags_nodeps,a_flags) -D__KSYM_DEPS__ $< ;; \ | ||
283 | boot*|build*|*cpp_lds_S|dtc|host*|vdso*) : ;; \ | ||
284 | *) echo "Don't know how to preprocess $(1)" >&2; false ;; \ | ||
285 | esac | tr ";" "\n" | sed -rn 's/^.*=== __KSYM_(.*) ===.*$$/KSYM_\1/p' | ||
286 | |||
287 | cmd_and_fixdep = \ | ||
288 | $(echo-cmd) $(cmd_$(1)); \ | ||
289 | $(ksym_dep_filter) | \ | ||
290 | scripts/basic/fixdep -e $(depfile) $@ '$(make-cmd)' \ | ||
291 | > $(dot-target).tmp; \ | ||
292 | rm -f $(depfile); \ | ||
293 | mv -f $(dot-target).tmp $(dot-target).cmd; | ||
294 | |||
295 | endif | ||
263 | 296 | ||
264 | # Usage: $(call if_changed_rule,foo) | 297 | # Usage: $(call if_changed_rule,foo) |
265 | # Will check if $(cmd_foo) or any of the prerequisites changed, | 298 | # Will check if $(cmd_foo) or any of the prerequisites changed, |
@@ -341,8 +374,6 @@ endif | |||
341 | # | 374 | # |
342 | ############################################################################### | 375 | ############################################################################### |
343 | # | 376 | # |
344 | space_escape := %%%SPACE%%% | ||
345 | # | ||
346 | define config_filename | 377 | define config_filename |
347 | ifneq ($$(CONFIG_$(1)),"") | 378 | ifneq ($$(CONFIG_$(1)),"") |
348 | $(1)_FILENAME := $$(subst \\,\,$$(subst \$$(quote),$$(quote),$$(subst $$(space_escape),\$$(space),$$(patsubst "%",%,$$(subst $$(space),$$(space_escape),$$(CONFIG_$(1))))))) | 379 | $(1)_FILENAME := $$(subst \\,\,$$(subst \$$(quote),$$(quote),$$(subst $$(space_escape),\$$(space),$$(patsubst "%",%,$$(subst $$(space),$$(space_escape),$$(CONFIG_$(1))))))) |
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index e1bc1907090e..0d1ca5bf42fb 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
@@ -152,11 +152,11 @@ cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< | |||
152 | $(obj)/%.s: $(src)/%.c FORCE | 152 | $(obj)/%.s: $(src)/%.c FORCE |
153 | $(call if_changed_dep,cc_s_c) | 153 | $(call if_changed_dep,cc_s_c) |
154 | 154 | ||
155 | quiet_cmd_cc_i_c = CPP $(quiet_modtag) $@ | 155 | quiet_cmd_cpp_i_c = CPP $(quiet_modtag) $@ |
156 | cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $< | 156 | cmd_cpp_i_c = $(CPP) $(c_flags) -o $@ $< |
157 | 157 | ||
158 | $(obj)/%.i: $(src)/%.c FORCE | 158 | $(obj)/%.i: $(src)/%.c FORCE |
159 | $(call if_changed_dep,cc_i_c) | 159 | $(call if_changed_dep,cpp_i_c) |
160 | 160 | ||
161 | cmd_gensymtypes = \ | 161 | cmd_gensymtypes = \ |
162 | $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ | 162 | $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ |
@@ -266,26 +266,24 @@ endif # CONFIG_STACK_VALIDATION | |||
266 | 266 | ||
267 | define rule_cc_o_c | 267 | define rule_cc_o_c |
268 | $(call echo-cmd,checksrc) $(cmd_checksrc) \ | 268 | $(call echo-cmd,checksrc) $(cmd_checksrc) \ |
269 | $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \ | 269 | $(call cmd_and_fixdep,cc_o_c) \ |
270 | $(cmd_modversions) \ | 270 | $(cmd_modversions) \ |
271 | $(cmd_objtool) \ | 271 | $(cmd_objtool) \ |
272 | $(call echo-cmd,record_mcount) \ | 272 | $(call echo-cmd,record_mcount) $(cmd_record_mcount) |
273 | $(cmd_record_mcount) \ | ||
274 | scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \ | ||
275 | $(dot-target).tmp; \ | ||
276 | rm -f $(depfile); \ | ||
277 | mv -f $(dot-target).tmp $(dot-target).cmd | ||
278 | endef | 273 | endef |
279 | 274 | ||
280 | define rule_as_o_S | 275 | define rule_as_o_S |
281 | $(call echo-cmd,as_o_S) $(cmd_as_o_S); \ | 276 | $(call cmd_and_fixdep,as_o_S) \ |
282 | $(cmd_objtool) \ | 277 | $(cmd_objtool) |
283 | scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,as_o_S)' > \ | ||
284 | $(dot-target).tmp; \ | ||
285 | rm -f $(depfile); \ | ||
286 | mv -f $(dot-target).tmp $(dot-target).cmd | ||
287 | endef | 278 | endef |
288 | 279 | ||
280 | # List module undefined symbols (or empty line if not enabled) | ||
281 | ifdef CONFIG_TRIM_UNUSED_KSYMS | ||
282 | cmd_undef_syms = $(NM) $@ | sed -n 's/^ \+U //p' | xargs echo | ||
283 | else | ||
284 | cmd_undef_syms = echo | ||
285 | endif | ||
286 | |||
289 | # Built-in and composite module parts | 287 | # Built-in and composite module parts |
290 | $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_obj) FORCE | 288 | $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_obj) FORCE |
291 | $(call cmd,force_checksrc) | 289 | $(call cmd,force_checksrc) |
@@ -296,7 +294,8 @@ $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_obj) FORCE | |||
296 | $(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_obj) FORCE | 294 | $(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_obj) FORCE |
297 | $(call cmd,force_checksrc) | 295 | $(call cmd,force_checksrc) |
298 | $(call if_changed_rule,cc_o_c) | 296 | $(call if_changed_rule,cc_o_c) |
299 | @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod) | 297 | @{ echo $(@:.o=.ko); echo $@; \ |
298 | $(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod) | ||
300 | 299 | ||
301 | quiet_cmd_cc_lst_c = MKLST $@ | 300 | quiet_cmd_cc_lst_c = MKLST $@ |
302 | cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \ | 301 | cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \ |
@@ -314,11 +313,11 @@ modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL) | |||
314 | $(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) | 313 | $(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) |
315 | $(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) | 314 | $(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) |
316 | 315 | ||
317 | quiet_cmd_as_s_S = CPP $(quiet_modtag) $@ | 316 | quiet_cmd_cpp_s_S = CPP $(quiet_modtag) $@ |
318 | cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< | 317 | cmd_cpp_s_S = $(CPP) $(a_flags) -o $@ $< |
319 | 318 | ||
320 | $(obj)/%.s: $(src)/%.S FORCE | 319 | $(obj)/%.s: $(src)/%.S FORCE |
321 | $(call if_changed_dep,as_s_S) | 320 | $(call if_changed_dep,cpp_s_S) |
322 | 321 | ||
323 | quiet_cmd_as_o_S = AS $(quiet_modtag) $@ | 322 | quiet_cmd_as_o_S = AS $(quiet_modtag) $@ |
324 | cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< | 323 | cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< |
@@ -426,7 +425,8 @@ $(call multi_depend, $(multi-used-y), .o, -objs -y) | |||
426 | 425 | ||
427 | $(multi-used-m): FORCE | 426 | $(multi-used-m): FORCE |
428 | $(call if_changed,link_multi-m) | 427 | $(call if_changed,link_multi-m) |
429 | @{ echo $(@:.o=.ko); echo $(link_multi_deps); } > $(MODVERDIR)/$(@F:.o=.mod) | 428 | @{ echo $(@:.o=.ko); echo $(link_multi_deps); \ |
429 | $(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod) | ||
430 | $(call multi_depend, $(multi-used-m), .o, -objs -y -m) | 430 | $(call multi_depend, $(multi-used-m), .o, -objs -y -m) |
431 | 431 | ||
432 | targets += $(multi-used-y) $(multi-used-m) | 432 | targets += $(multi-used-y) $(multi-used-m) |
diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index f9e47a70509c..53449a6ff6aa 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn | |||
@@ -24,6 +24,7 @@ warning-1 += $(call cc-option, -Wmissing-prototypes) | |||
24 | warning-1 += -Wold-style-definition | 24 | warning-1 += -Wold-style-definition |
25 | warning-1 += $(call cc-option, -Wmissing-include-dirs) | 25 | warning-1 += $(call cc-option, -Wmissing-include-dirs) |
26 | warning-1 += $(call cc-option, -Wunused-but-set-variable) | 26 | warning-1 += $(call cc-option, -Wunused-but-set-variable) |
27 | warning-1 += $(call cc-option, -Wunused-const-variable) | ||
27 | warning-1 += $(call cc-disable-warning, missing-field-initializers) | 28 | warning-1 += $(call cc-disable-warning, missing-field-initializers) |
28 | warning-1 += $(call cc-disable-warning, sign-compare) | 29 | warning-1 += $(call cc-disable-warning, sign-compare) |
29 | 30 | ||
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index ddf83d0181e7..e7df0f5db7ec 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
@@ -96,10 +96,10 @@ obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) | |||
96 | # Note: Files that end up in two or more modules are compiled without the | 96 | # Note: Files that end up in two or more modules are compiled without the |
97 | # KBUILD_MODNAME definition. The reason is that any made-up name would | 97 | # KBUILD_MODNAME definition. The reason is that any made-up name would |
98 | # differ in different configs. | 98 | # differ in different configs. |
99 | name-fix = $(subst $(comma),_,$(subst -,_,$1)) | 99 | name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote) |
100 | basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))" | 100 | basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) |
101 | modname_flags = $(if $(filter 1,$(words $(modname))),\ | 101 | modname_flags = $(if $(filter 1,$(words $(modname))),\ |
102 | -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") | 102 | -DKBUILD_MODNAME=$(call name-fix,$(modname))) |
103 | 103 | ||
104 | orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \ | 104 | orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \ |
105 | $(ccflags-y) $(CFLAGS_$(basetarget).o) | 105 | $(ccflags-y) $(CFLAGS_$(basetarget).o) |
@@ -162,7 +162,7 @@ endif | |||
162 | 162 | ||
163 | c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ | 163 | c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ |
164 | $(__c_flags) $(modkern_cflags) \ | 164 | $(__c_flags) $(modkern_cflags) \ |
165 | -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) | 165 | $(basename_flags) $(modname_flags) |
166 | 166 | ||
167 | a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ | 167 | a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ |
168 | $(__a_flags) $(modkern_aflags) | 168 | $(__a_flags) $(modkern_aflags) |
@@ -277,6 +277,11 @@ cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \ | |||
277 | # --------------------------------------------------------------------------- | 277 | # --------------------------------------------------------------------------- |
278 | DTC ?= $(objtree)/scripts/dtc/dtc | 278 | DTC ?= $(objtree)/scripts/dtc/dtc |
279 | 279 | ||
280 | # Disable noisy checks by default | ||
281 | ifeq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),) | ||
282 | DTC_FLAGS += -Wno-unit_address_vs_reg | ||
283 | endif | ||
284 | |||
280 | # Generate an assembly file to wrap the output of the device tree compiler | 285 | # Generate an assembly file to wrap the output of the device tree compiler |
281 | quiet_cmd_dt_S_dtb= DTB $@ | 286 | quiet_cmd_dt_S_dtb= DTB $@ |
282 | cmd_dt_S_dtb= \ | 287 | cmd_dt_S_dtb= \ |
diff --git a/scripts/adjust_autoksyms.sh b/scripts/adjust_autoksyms.sh new file mode 100755 index 000000000000..8dc1918b6783 --- /dev/null +++ b/scripts/adjust_autoksyms.sh | |||
@@ -0,0 +1,101 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Script to create/update include/generated/autoksyms.h and dependency files | ||
4 | # | ||
5 | # Copyright: (C) 2016 Linaro Limited | ||
6 | # Created by: Nicolas Pitre, January 2016 | ||
7 | # | ||
8 | # This program is free software; you can redistribute it and/or modify | ||
9 | # it under the terms of the GNU General Public License version 2 as | ||
10 | # published by the Free Software Foundation. | ||
11 | |||
12 | # Create/update the include/generated/autoksyms.h file from the list | ||
13 | # of all module's needed symbols as recorded on the third line of | ||
14 | # .tmp_versions/*.mod files. | ||
15 | # | ||
16 | # For each symbol being added or removed, the corresponding dependency | ||
17 | # file's timestamp is updated to force a rebuild of the affected source | ||
18 | # file. All arguments passed to this script are assumed to be a command | ||
19 | # to be exec'd to trigger a rebuild of those files. | ||
20 | |||
21 | set -e | ||
22 | |||
23 | cur_ksyms_file="include/generated/autoksyms.h" | ||
24 | new_ksyms_file="include/generated/autoksyms.h.tmpnew" | ||
25 | |||
26 | info() { | ||
27 | if [ "$quiet" != "silent_" ]; then | ||
28 | printf " %-7s %s\n" "$1" "$2" | ||
29 | fi | ||
30 | } | ||
31 | |||
32 | info "CHK" "$cur_ksyms_file" | ||
33 | |||
34 | # Use "make V=1" to debug this script. | ||
35 | case "$KBUILD_VERBOSE" in | ||
36 | *1*) | ||
37 | set -x | ||
38 | ;; | ||
39 | esac | ||
40 | |||
41 | # We need access to CONFIG_ symbols | ||
42 | case "${KCONFIG_CONFIG}" in | ||
43 | */*) | ||
44 | . "${KCONFIG_CONFIG}" | ||
45 | ;; | ||
46 | *) | ||
47 | # Force using a file from the current directory | ||
48 | . "./${KCONFIG_CONFIG}" | ||
49 | esac | ||
50 | |||
51 | # In case it doesn't exist yet... | ||
52 | if [ -e "$cur_ksyms_file" ]; then touch "$cur_ksyms_file"; fi | ||
53 | |||
54 | # Generate a new ksym list file with symbols needed by the current | ||
55 | # set of modules. | ||
56 | cat > "$new_ksyms_file" << EOT | ||
57 | /* | ||
58 | * Automatically generated file; DO NOT EDIT. | ||
59 | */ | ||
60 | |||
61 | EOT | ||
62 | sed -ns -e '3{s/ /\n/g;/^$/!p;}' "$MODVERDIR"/*.mod | sort -u | | ||
63 | while read sym; do | ||
64 | if [ -n "$CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX" ]; then | ||
65 | sym="${sym#_}" | ||
66 | fi | ||
67 | echo "#define __KSYM_${sym} 1" | ||
68 | done >> "$new_ksyms_file" | ||
69 | |||
70 | # Special case for modversions (see modpost.c) | ||
71 | if [ -n "$CONFIG_MODVERSIONS" ]; then | ||
72 | echo "#define __KSYM_module_layout 1" >> "$new_ksyms_file" | ||
73 | fi | ||
74 | |||
75 | # Extract changes between old and new list and touch corresponding | ||
76 | # dependency files. | ||
77 | changed=$( | ||
78 | count=0 | ||
79 | sort "$cur_ksyms_file" "$new_ksyms_file" | uniq -u | | ||
80 | sed -n 's/^#define __KSYM_\(.*\) 1/\1/p' | tr "A-Z_" "a-z/" | | ||
81 | while read sympath; do | ||
82 | if [ -z "$sympath" ]; then continue; fi | ||
83 | depfile="include/config/ksym/${sympath}.h" | ||
84 | mkdir -p "$(dirname "$depfile")" | ||
85 | touch "$depfile" | ||
86 | echo $((count += 1)) | ||
87 | done | tail -1 ) | ||
88 | changed=${changed:-0} | ||
89 | |||
90 | if [ $changed -gt 0 ]; then | ||
91 | # Replace the old list with tne new one | ||
92 | old=$(grep -c "^#define __KSYM_" "$cur_ksyms_file" || true) | ||
93 | new=$(grep -c "^#define __KSYM_" "$new_ksyms_file" || true) | ||
94 | info "KSYMS" "symbols: before=$old, after=$new, changed=$changed" | ||
95 | info "UPD" "$cur_ksyms_file" | ||
96 | mv -f "$new_ksyms_file" "$cur_ksyms_file" | ||
97 | # Then trigger a rebuild of affected source files | ||
98 | exec $@ | ||
99 | else | ||
100 | rm -f "$new_ksyms_file" | ||
101 | fi | ||
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index caef815d1743..746ec1ece614 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c | |||
@@ -120,13 +120,15 @@ | |||
120 | #define INT_NFIG ntohl(0x4e464947) | 120 | #define INT_NFIG ntohl(0x4e464947) |
121 | #define INT_FIG_ ntohl(0x4649475f) | 121 | #define INT_FIG_ ntohl(0x4649475f) |
122 | 122 | ||
123 | int insert_extra_deps; | ||
123 | char *target; | 124 | char *target; |
124 | char *depfile; | 125 | char *depfile; |
125 | char *cmdline; | 126 | char *cmdline; |
126 | 127 | ||
127 | static void usage(void) | 128 | static void usage(void) |
128 | { | 129 | { |
129 | fprintf(stderr, "Usage: fixdep <depfile> <target> <cmdline>\n"); | 130 | fprintf(stderr, "Usage: fixdep [-e] <depfile> <target> <cmdline>\n"); |
131 | fprintf(stderr, " -e insert extra dependencies given on stdin\n"); | ||
130 | exit(1); | 132 | exit(1); |
131 | } | 133 | } |
132 | 134 | ||
@@ -138,6 +140,40 @@ static void print_cmdline(void) | |||
138 | printf("cmd_%s := %s\n\n", target, cmdline); | 140 | printf("cmd_%s := %s\n\n", target, cmdline); |
139 | } | 141 | } |
140 | 142 | ||
143 | /* | ||
144 | * Print out a dependency path from a symbol name | ||
145 | */ | ||
146 | static void print_config(const char *m, int slen) | ||
147 | { | ||
148 | int c, i; | ||
149 | |||
150 | printf(" $(wildcard include/config/"); | ||
151 | for (i = 0; i < slen; i++) { | ||
152 | c = m[i]; | ||
153 | if (c == '_') | ||
154 | c = '/'; | ||
155 | else | ||
156 | c = tolower(c); | ||
157 | putchar(c); | ||
158 | } | ||
159 | printf(".h) \\\n"); | ||
160 | } | ||
161 | |||
162 | static void do_extra_deps(void) | ||
163 | { | ||
164 | if (insert_extra_deps) { | ||
165 | char buf[80]; | ||
166 | while(fgets(buf, sizeof(buf), stdin)) { | ||
167 | int len = strlen(buf); | ||
168 | if (len < 2 || buf[len-1] != '\n') { | ||
169 | fprintf(stderr, "fixdep: bad data on stdin\n"); | ||
170 | exit(1); | ||
171 | } | ||
172 | print_config(buf, len-1); | ||
173 | } | ||
174 | } | ||
175 | } | ||
176 | |||
141 | struct item { | 177 | struct item { |
142 | struct item *next; | 178 | struct item *next; |
143 | unsigned int len; | 179 | unsigned int len; |
@@ -197,23 +233,12 @@ static void define_config(const char *name, int len, unsigned int hash) | |||
197 | static void use_config(const char *m, int slen) | 233 | static void use_config(const char *m, int slen) |
198 | { | 234 | { |
199 | unsigned int hash = strhash(m, slen); | 235 | unsigned int hash = strhash(m, slen); |
200 | int c, i; | ||
201 | 236 | ||
202 | if (is_defined_config(m, slen, hash)) | 237 | if (is_defined_config(m, slen, hash)) |
203 | return; | 238 | return; |
204 | 239 | ||
205 | define_config(m, slen, hash); | 240 | define_config(m, slen, hash); |
206 | 241 | print_config(m, slen); | |
207 | printf(" $(wildcard include/config/"); | ||
208 | for (i = 0; i < slen; i++) { | ||
209 | c = m[i]; | ||
210 | if (c == '_') | ||
211 | c = '/'; | ||
212 | else | ||
213 | c = tolower(c); | ||
214 | putchar(c); | ||
215 | } | ||
216 | printf(".h) \\\n"); | ||
217 | } | 242 | } |
218 | 243 | ||
219 | static void parse_config_file(const char *map, size_t len) | 244 | static void parse_config_file(const char *map, size_t len) |
@@ -250,7 +275,7 @@ static void parse_config_file(const char *map, size_t len) | |||
250 | } | 275 | } |
251 | } | 276 | } |
252 | 277 | ||
253 | /* test is s ends in sub */ | 278 | /* test if s ends in sub */ |
254 | static int strrcmp(const char *s, const char *sub) | 279 | static int strrcmp(const char *s, const char *sub) |
255 | { | 280 | { |
256 | int slen = strlen(s); | 281 | int slen = strlen(s); |
@@ -333,6 +358,7 @@ static void parse_dep_file(void *map, size_t len) | |||
333 | 358 | ||
334 | /* Ignore certain dependencies */ | 359 | /* Ignore certain dependencies */ |
335 | if (strrcmp(s, "include/generated/autoconf.h") && | 360 | if (strrcmp(s, "include/generated/autoconf.h") && |
361 | strrcmp(s, "include/generated/autoksyms.h") && | ||
336 | strrcmp(s, "arch/um/include/uml-config.h") && | 362 | strrcmp(s, "arch/um/include/uml-config.h") && |
337 | strrcmp(s, "include/linux/kconfig.h") && | 363 | strrcmp(s, "include/linux/kconfig.h") && |
338 | strrcmp(s, ".ver")) { | 364 | strrcmp(s, ".ver")) { |
@@ -378,6 +404,8 @@ static void parse_dep_file(void *map, size_t len) | |||
378 | exit(1); | 404 | exit(1); |
379 | } | 405 | } |
380 | 406 | ||
407 | do_extra_deps(); | ||
408 | |||
381 | printf("\n%s: $(deps_%s)\n\n", target, target); | 409 | printf("\n%s: $(deps_%s)\n\n", target, target); |
382 | printf("$(deps_%s):\n", target); | 410 | printf("$(deps_%s):\n", target); |
383 | } | 411 | } |
@@ -434,7 +462,10 @@ int main(int argc, char *argv[]) | |||
434 | { | 462 | { |
435 | traps(); | 463 | traps(); |
436 | 464 | ||
437 | if (argc != 4) | 465 | if (argc == 5 && !strcmp(argv[1], "-e")) { |
466 | insert_extra_deps = 1; | ||
467 | argv++; | ||
468 | } else if (argc != 4) | ||
438 | usage(); | 469 | usage(); |
439 | 470 | ||
440 | depfile = argv[1]; | 471 | depfile = argv[1]; |
diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter index 38b64f487315..0254f3ba0dba 100755 --- a/scripts/bloat-o-meter +++ b/scripts/bloat-o-meter | |||
@@ -32,18 +32,21 @@ old = getsizes(sys.argv[1]) | |||
32 | new = getsizes(sys.argv[2]) | 32 | new = getsizes(sys.argv[2]) |
33 | grow, shrink, add, remove, up, down = 0, 0, 0, 0, 0, 0 | 33 | grow, shrink, add, remove, up, down = 0, 0, 0, 0, 0, 0 |
34 | delta, common = [], {} | 34 | delta, common = [], {} |
35 | otot, ntot = 0, 0 | ||
35 | 36 | ||
36 | for a in old: | 37 | for a in old: |
37 | if a in new: | 38 | if a in new: |
38 | common[a] = 1 | 39 | common[a] = 1 |
39 | 40 | ||
40 | for name in old: | 41 | for name in old: |
42 | otot += old[name] | ||
41 | if name not in common: | 43 | if name not in common: |
42 | remove += 1 | 44 | remove += 1 |
43 | down += old[name] | 45 | down += old[name] |
44 | delta.append((-old[name], name)) | 46 | delta.append((-old[name], name)) |
45 | 47 | ||
46 | for name in new: | 48 | for name in new: |
49 | ntot += new[name] | ||
47 | if name not in common: | 50 | if name not in common: |
48 | add += 1 | 51 | add += 1 |
49 | up += new[name] | 52 | up += new[name] |
@@ -63,3 +66,6 @@ print("add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \ | |||
63 | print("%-40s %7s %7s %+7s" % ("function", "old", "new", "delta")) | 66 | print("%-40s %7s %7s %+7s" % ("function", "old", "new", "delta")) |
64 | for d, n in delta: | 67 | for d, n in delta: |
65 | if d: print("%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d)) | 68 | if d: print("%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d)) |
69 | |||
70 | print("Total: Before=%d, After=%d, chg %f%%" % \ | ||
71 | (otot, ntot, (ntot - otot)*100/otot)) | ||
diff --git a/scripts/checkkconfigsymbols.py b/scripts/checkkconfigsymbols.py index d8f6c094cce5..df643f60bb41 100755 --- a/scripts/checkkconfigsymbols.py +++ b/scripts/checkkconfigsymbols.py | |||
@@ -89,7 +89,7 @@ def parse_options(): | |||
89 | 89 | ||
90 | if opts.diff and not re.match(r"^[\w\-\.]+\.\.[\w\-\.]+$", opts.diff): | 90 | if opts.diff and not re.match(r"^[\w\-\.]+\.\.[\w\-\.]+$", opts.diff): |
91 | sys.exit("Please specify valid input in the following format: " | 91 | sys.exit("Please specify valid input in the following format: " |
92 | "\'commmit1..commit2\'") | 92 | "\'commit1..commit2\'") |
93 | 93 | ||
94 | if opts.commit or opts.diff: | 94 | if opts.commit or opts.diff: |
95 | if not opts.force and tree_is_dirty(): | 95 | if not opts.force and tree_is_dirty(): |
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index d574d13ba963..4904ced676d4 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -27,12 +27,15 @@ my $emacs = 0; | |||
27 | my $terse = 0; | 27 | my $terse = 0; |
28 | my $showfile = 0; | 28 | my $showfile = 0; |
29 | my $file = 0; | 29 | my $file = 0; |
30 | my $git = 0; | ||
31 | my %git_commits = (); | ||
30 | my $check = 0; | 32 | my $check = 0; |
31 | my $check_orig = 0; | 33 | my $check_orig = 0; |
32 | my $summary = 1; | 34 | my $summary = 1; |
33 | my $mailback = 0; | 35 | my $mailback = 0; |
34 | my $summary_file = 0; | 36 | my $summary_file = 0; |
35 | my $show_types = 0; | 37 | my $show_types = 0; |
38 | my $list_types = 0; | ||
36 | my $fix = 0; | 39 | my $fix = 0; |
37 | my $fix_inplace = 0; | 40 | my $fix_inplace = 0; |
38 | my $root; | 41 | my $root; |
@@ -68,13 +71,24 @@ Options: | |||
68 | --emacs emacs compile window format | 71 | --emacs emacs compile window format |
69 | --terse one line per report | 72 | --terse one line per report |
70 | --showfile emit diffed file position, not input file position | 73 | --showfile emit diffed file position, not input file position |
74 | -g, --git treat FILE as a single commit or git revision range | ||
75 | single git commit with: | ||
76 | <rev> | ||
77 | <rev>^ | ||
78 | <rev>~n | ||
79 | multiple git commits with: | ||
80 | <rev1>..<rev2> | ||
81 | <rev1>...<rev2> | ||
82 | <rev>-<count> | ||
83 | git merges are ignored | ||
71 | -f, --file treat FILE as regular source file | 84 | -f, --file treat FILE as regular source file |
72 | --subjective, --strict enable more subjective tests | 85 | --subjective, --strict enable more subjective tests |
86 | --list-types list the possible message types | ||
73 | --types TYPE(,TYPE2...) show only these comma separated message types | 87 | --types TYPE(,TYPE2...) show only these comma separated message types |
74 | --ignore TYPE(,TYPE2...) ignore various comma separated message types | 88 | --ignore TYPE(,TYPE2...) ignore various comma separated message types |
89 | --show-types show the specific message type in the output | ||
75 | --max-line-length=n set the maximum line length, if exceeded, warn | 90 | --max-line-length=n set the maximum line length, if exceeded, warn |
76 | --min-conf-desc-length=n set the min description length, if shorter, warn | 91 | --min-conf-desc-length=n set the min description length, if shorter, warn |
77 | --show-types show the message "types" in the output | ||
78 | --root=PATH PATH to the kernel tree root | 92 | --root=PATH PATH to the kernel tree root |
79 | --no-summary suppress the per-file summary | 93 | --no-summary suppress the per-file summary |
80 | --mailback only produce a report in case of warnings/errors | 94 | --mailback only produce a report in case of warnings/errors |
@@ -106,6 +120,37 @@ EOM | |||
106 | exit($exitcode); | 120 | exit($exitcode); |
107 | } | 121 | } |
108 | 122 | ||
123 | sub uniq { | ||
124 | my %seen; | ||
125 | return grep { !$seen{$_}++ } @_; | ||
126 | } | ||
127 | |||
128 | sub list_types { | ||
129 | my ($exitcode) = @_; | ||
130 | |||
131 | my $count = 0; | ||
132 | |||
133 | local $/ = undef; | ||
134 | |||
135 | open(my $script, '<', abs_path($P)) or | ||
136 | die "$P: Can't read '$P' $!\n"; | ||
137 | |||
138 | my $text = <$script>; | ||
139 | close($script); | ||
140 | |||
141 | my @types = (); | ||
142 | for ($text =~ /\b(?:(?:CHK|WARN|ERROR)\s*\(\s*"([^"]+)")/g) { | ||
143 | push (@types, $_); | ||
144 | } | ||
145 | @types = sort(uniq(@types)); | ||
146 | print("#\tMessage type\n\n"); | ||
147 | foreach my $type (@types) { | ||
148 | print(++$count . "\t" . $type . "\n"); | ||
149 | } | ||
150 | |||
151 | exit($exitcode); | ||
152 | } | ||
153 | |||
109 | my $conf = which_conf($configuration_file); | 154 | my $conf = which_conf($configuration_file); |
110 | if (-f $conf) { | 155 | if (-f $conf) { |
111 | my @conf_args; | 156 | my @conf_args; |
@@ -141,11 +186,13 @@ GetOptions( | |||
141 | 'terse!' => \$terse, | 186 | 'terse!' => \$terse, |
142 | 'showfile!' => \$showfile, | 187 | 'showfile!' => \$showfile, |
143 | 'f|file!' => \$file, | 188 | 'f|file!' => \$file, |
189 | 'g|git!' => \$git, | ||
144 | 'subjective!' => \$check, | 190 | 'subjective!' => \$check, |
145 | 'strict!' => \$check, | 191 | 'strict!' => \$check, |
146 | 'ignore=s' => \@ignore, | 192 | 'ignore=s' => \@ignore, |
147 | 'types=s' => \@use, | 193 | 'types=s' => \@use, |
148 | 'show-types!' => \$show_types, | 194 | 'show-types!' => \$show_types, |
195 | 'list-types!' => \$list_types, | ||
149 | 'max-line-length=i' => \$max_line_length, | 196 | 'max-line-length=i' => \$max_line_length, |
150 | 'min-conf-desc-length=i' => \$min_conf_desc_length, | 197 | 'min-conf-desc-length=i' => \$min_conf_desc_length, |
151 | 'root=s' => \$root, | 198 | 'root=s' => \$root, |
@@ -166,6 +213,8 @@ GetOptions( | |||
166 | 213 | ||
167 | help(0) if ($help); | 214 | help(0) if ($help); |
168 | 215 | ||
216 | list_types(0) if ($list_types); | ||
217 | |||
169 | $fix = 1 if ($fix_inplace); | 218 | $fix = 1 if ($fix_inplace); |
170 | $check_orig = $check; | 219 | $check_orig = $check; |
171 | 220 | ||
@@ -752,10 +801,42 @@ my @fixed_inserted = (); | |||
752 | my @fixed_deleted = (); | 801 | my @fixed_deleted = (); |
753 | my $fixlinenr = -1; | 802 | my $fixlinenr = -1; |
754 | 803 | ||
804 | # If input is git commits, extract all commits from the commit expressions. | ||
805 | # For example, HEAD-3 means we need check 'HEAD, HEAD~1, HEAD~2'. | ||
806 | die "$P: No git repository found\n" if ($git && !-e ".git"); | ||
807 | |||
808 | if ($git) { | ||
809 | my @commits = (); | ||
810 | foreach my $commit_expr (@ARGV) { | ||
811 | my $git_range; | ||
812 | if ($commit_expr =~ m/^(.*)-(\d+)$/) { | ||
813 | $git_range = "-$2 $1"; | ||
814 | } elsif ($commit_expr =~ m/\.\./) { | ||
815 | $git_range = "$commit_expr"; | ||
816 | } else { | ||
817 | $git_range = "-1 $commit_expr"; | ||
818 | } | ||
819 | my $lines = `git log --no-color --no-merges --pretty=format:'%H %s' $git_range`; | ||
820 | foreach my $line (split(/\n/, $lines)) { | ||
821 | $line =~ /^([0-9a-fA-F]{40,40}) (.*)$/; | ||
822 | next if (!defined($1) || !defined($2)); | ||
823 | my $sha1 = $1; | ||
824 | my $subject = $2; | ||
825 | unshift(@commits, $sha1); | ||
826 | $git_commits{$sha1} = $subject; | ||
827 | } | ||
828 | } | ||
829 | die "$P: no git commits after extraction!\n" if (@commits == 0); | ||
830 | @ARGV = @commits; | ||
831 | } | ||
832 | |||
755 | my $vname; | 833 | my $vname; |
756 | for my $filename (@ARGV) { | 834 | for my $filename (@ARGV) { |
757 | my $FILE; | 835 | my $FILE; |
758 | if ($file) { | 836 | if ($git) { |
837 | open($FILE, '-|', "git format-patch -M --stdout -1 $filename") || | ||
838 | die "$P: $filename: git format-patch failed - $!\n"; | ||
839 | } elsif ($file) { | ||
759 | open($FILE, '-|', "diff -u /dev/null $filename") || | 840 | open($FILE, '-|', "diff -u /dev/null $filename") || |
760 | die "$P: $filename: diff failed - $!\n"; | 841 | die "$P: $filename: diff failed - $!\n"; |
761 | } elsif ($filename eq '-') { | 842 | } elsif ($filename eq '-') { |
@@ -766,6 +847,8 @@ for my $filename (@ARGV) { | |||
766 | } | 847 | } |
767 | if ($filename eq '-') { | 848 | if ($filename eq '-') { |
768 | $vname = 'Your patch'; | 849 | $vname = 'Your patch'; |
850 | } elsif ($git) { | ||
851 | $vname = "Commit " . substr($filename, 0, 12) . ' ("' . $git_commits{$filename} . '")'; | ||
769 | } else { | 852 | } else { |
770 | $vname = $filename; | 853 | $vname = $filename; |
771 | } | 854 | } |
@@ -2371,6 +2454,7 @@ sub process { | |||
2371 | 2454 | ||
2372 | # Check for git id commit length and improperly formed commit descriptions | 2455 | # Check for git id commit length and improperly formed commit descriptions |
2373 | if ($in_commit_log && !$commit_log_possible_stack_dump && | 2456 | if ($in_commit_log && !$commit_log_possible_stack_dump && |
2457 | $line !~ /^\s*(?:Link|Patchwork|http|BugLink):/i && | ||
2374 | ($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i || | 2458 | ($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i || |
2375 | ($line =~ /\b[0-9a-f]{12,40}\b/i && | 2459 | ($line =~ /\b[0-9a-f]{12,40}\b/i && |
2376 | $line !~ /[\<\[][0-9a-f]{12,40}[\>\]]/i && | 2460 | $line !~ /[\<\[][0-9a-f]{12,40}[\>\]]/i && |
@@ -2755,6 +2839,19 @@ sub process { | |||
2755 | "Logical continuations should be on the previous line\n" . $hereprev); | 2839 | "Logical continuations should be on the previous line\n" . $hereprev); |
2756 | } | 2840 | } |
2757 | 2841 | ||
2842 | # check indentation starts on a tab stop | ||
2843 | if ($^V && $^V ge 5.10.0 && | ||
2844 | $sline =~ /^\+\t+( +)(?:$c90_Keywords\b|\{\s*$|\}\s*(?:else\b|while\b|\s*$))/) { | ||
2845 | my $indent = length($1); | ||
2846 | if ($indent % 8) { | ||
2847 | if (WARN("TABSTOP", | ||
2848 | "Statements should start on a tabstop\n" . $herecurr) && | ||
2849 | $fix) { | ||
2850 | $fixed[$fixlinenr] =~ s@(^\+\t+) +@$1 . "\t" x ($indent/8)@e; | ||
2851 | } | ||
2852 | } | ||
2853 | } | ||
2854 | |||
2758 | # check multi-line statement indentation matches previous line | 2855 | # check multi-line statement indentation matches previous line |
2759 | if ($^V && $^V ge 5.10.0 && | 2856 | if ($^V && $^V ge 5.10.0 && |
2760 | $prevline =~ /^\+([ \t]*)((?:$c90_Keywords(?:\s+if)\s*)|(?:$Declare\s*)?(?:$Ident|\(\s*\*\s*$Ident\s*\))\s*|$Ident\s*=\s*$Ident\s*)\(.*(\&\&|\|\||,)\s*$/) { | 2857 | $prevline =~ /^\+([ \t]*)((?:$c90_Keywords(?:\s+if)\s*)|(?:$Declare\s*)?(?:$Ident|\(\s*\*\s*$Ident\s*\))\s*|$Ident\s*=\s*$Ident\s*)\(.*(\&\&|\|\||,)\s*$/) { |
@@ -4291,7 +4388,7 @@ sub process { | |||
4291 | my $comp = $3; | 4388 | my $comp = $3; |
4292 | my $to = $4; | 4389 | my $to = $4; |
4293 | my $newcomp = $comp; | 4390 | my $newcomp = $comp; |
4294 | if ($lead !~ /$Operators\s*$/ && | 4391 | if ($lead !~ /(?:$Operators|\.)\s*$/ && |
4295 | $to !~ /^(?:Constant|[A-Z_][A-Z0-9_]*)$/ && | 4392 | $to !~ /^(?:Constant|[A-Z_][A-Z0-9_]*)$/ && |
4296 | WARN("CONSTANT_COMPARISON", | 4393 | WARN("CONSTANT_COMPARISON", |
4297 | "Comparisons should place the constant on the right side of the test\n" . $herecurr) && | 4394 | "Comparisons should place the constant on the right side of the test\n" . $herecurr) && |
@@ -5637,6 +5734,16 @@ sub process { | |||
5637 | } | 5734 | } |
5638 | } | 5735 | } |
5639 | 5736 | ||
5737 | # check for #if defined CONFIG_<FOO> || defined CONFIG_<FOO>_MODULE | ||
5738 | if ($line =~ /^\+\s*#\s*if\s+defined(?:\s*\(?\s*|\s+)(CONFIG_[A-Z_]+)\s*\)?\s*\|\|\s*defined(?:\s*\(?\s*|\s+)\1_MODULE\s*\)?\s*$/) { | ||
5739 | my $config = $1; | ||
5740 | if (WARN("PREFER_IS_ENABLED", | ||
5741 | "Prefer IS_ENABLED(<FOO>) to CONFIG_<FOO> || CONFIG_<FOO>_MODULE\n" . $herecurr) && | ||
5742 | $fix) { | ||
5743 | $fixed[$fixlinenr] = "\+#if IS_ENABLED($config)"; | ||
5744 | } | ||
5745 | } | ||
5746 | |||
5640 | # check for case / default statements not preceded by break/fallthrough/switch | 5747 | # check for case / default statements not preceded by break/fallthrough/switch |
5641 | if ($line =~ /^.\s*(?:case\s+(?:$Ident|$Constant)\s*|default):/) { | 5748 | if ($line =~ /^.\s*(?:case\s+(?:$Ident|$Constant)\s*|default):/) { |
5642 | my $has_break = 0; | 5749 | my $has_break = 0; |
@@ -5827,6 +5934,28 @@ sub process { | |||
5827 | } | 5934 | } |
5828 | } | 5935 | } |
5829 | 5936 | ||
5937 | # whine about ACCESS_ONCE | ||
5938 | if ($^V && $^V ge 5.10.0 && | ||
5939 | $line =~ /\bACCESS_ONCE\s*$balanced_parens\s*(=(?!=))?\s*($FuncArg)?/) { | ||
5940 | my $par = $1; | ||
5941 | my $eq = $2; | ||
5942 | my $fun = $3; | ||
5943 | $par =~ s/^\(\s*(.*)\s*\)$/$1/; | ||
5944 | if (defined($eq)) { | ||
5945 | if (WARN("PREFER_WRITE_ONCE", | ||
5946 | "Prefer WRITE_ONCE(<FOO>, <BAR>) over ACCESS_ONCE(<FOO>) = <BAR>\n" . $herecurr) && | ||
5947 | $fix) { | ||
5948 | $fixed[$fixlinenr] =~ s/\bACCESS_ONCE\s*\(\s*\Q$par\E\s*\)\s*$eq\s*\Q$fun\E/WRITE_ONCE($par, $fun)/; | ||
5949 | } | ||
5950 | } else { | ||
5951 | if (WARN("PREFER_READ_ONCE", | ||
5952 | "Prefer READ_ONCE(<FOO>) over ACCESS_ONCE(<FOO>)\n" . $herecurr) && | ||
5953 | $fix) { | ||
5954 | $fixed[$fixlinenr] =~ s/\bACCESS_ONCE\s*\(\s*\Q$par\E\s*\)/READ_ONCE($par)/; | ||
5955 | } | ||
5956 | } | ||
5957 | } | ||
5958 | |||
5830 | # check for lockdep_set_novalidate_class | 5959 | # check for lockdep_set_novalidate_class |
5831 | if ($line =~ /^.\s*lockdep_set_novalidate_class\s*\(/ || | 5960 | if ($line =~ /^.\s*lockdep_set_novalidate_class\s*\(/ || |
5832 | $line =~ /__lockdep_no_validate__\s*\)/ ) { | 5961 | $line =~ /__lockdep_no_validate__\s*\)/ ) { |
@@ -5930,6 +6059,14 @@ sub process { | |||
5930 | } | 6059 | } |
5931 | 6060 | ||
5932 | if ($quiet == 0) { | 6061 | if ($quiet == 0) { |
6062 | # If there were any defects found and not already fixing them | ||
6063 | if (!$clean and !$fix) { | ||
6064 | print << "EOM" | ||
6065 | |||
6066 | NOTE: For some of the reported defects, checkpatch may be able to | ||
6067 | mechanically convert to the typical style using --fix or --fix-inplace. | ||
6068 | EOM | ||
6069 | } | ||
5933 | # If there were whitespace errors which cleanpatch can fix | 6070 | # If there were whitespace errors which cleanpatch can fix |
5934 | # then suggest that. | 6071 | # then suggest that. |
5935 | if ($rpt_cleaners) { | 6072 | if ($rpt_cleaners) { |
diff --git a/scripts/coccicheck b/scripts/coccicheck index b2d758188f2f..dd85a455b2ba 100755 --- a/scripts/coccicheck +++ b/scripts/coccicheck | |||
@@ -98,7 +98,7 @@ run_cmd() { | |||
98 | } | 98 | } |
99 | 99 | ||
100 | kill_running() { | 100 | kill_running() { |
101 | for i in $(seq $(( NPROC - 1 )) ); do | 101 | for i in $(seq 0 $(( NPROC - 1 )) ); do |
102 | if [ $VERBOSE -eq 2 ] ; then | 102 | if [ $VERBOSE -eq 2 ] ; then |
103 | echo "Killing ${SPATCH_PID[$i]}" | 103 | echo "Killing ${SPATCH_PID[$i]}" |
104 | fi | 104 | fi |
diff --git a/scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci b/scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci new file mode 100644 index 000000000000..85cf5408d378 --- /dev/null +++ b/scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci | |||
@@ -0,0 +1,67 @@ | |||
1 | /// Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE | ||
2 | /// for debugfs files. | ||
3 | /// | ||
4 | //# Rationale: DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file() | ||
5 | //# imposes some significant overhead as compared to | ||
6 | //# DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe(). | ||
7 | // | ||
8 | // Copyright (C): 2016 Nicolai Stange | ||
9 | // Options: --no-includes | ||
10 | // | ||
11 | |||
12 | virtual context | ||
13 | virtual patch | ||
14 | virtual org | ||
15 | virtual report | ||
16 | |||
17 | @dsa@ | ||
18 | declarer name DEFINE_SIMPLE_ATTRIBUTE; | ||
19 | identifier dsa_fops; | ||
20 | expression dsa_get, dsa_set, dsa_fmt; | ||
21 | position p; | ||
22 | @@ | ||
23 | DEFINE_SIMPLE_ATTRIBUTE@p(dsa_fops, dsa_get, dsa_set, dsa_fmt); | ||
24 | |||
25 | @dcf@ | ||
26 | expression name, mode, parent, data; | ||
27 | identifier dsa.dsa_fops; | ||
28 | @@ | ||
29 | debugfs_create_file(name, mode, parent, data, &dsa_fops) | ||
30 | |||
31 | |||
32 | @context_dsa depends on context && dcf@ | ||
33 | declarer name DEFINE_DEBUGFS_ATTRIBUTE; | ||
34 | identifier dsa.dsa_fops; | ||
35 | expression dsa.dsa_get, dsa.dsa_set, dsa.dsa_fmt; | ||
36 | @@ | ||
37 | * DEFINE_SIMPLE_ATTRIBUTE(dsa_fops, dsa_get, dsa_set, dsa_fmt); | ||
38 | |||
39 | |||
40 | @patch_dcf depends on patch expression@ | ||
41 | expression name, mode, parent, data; | ||
42 | identifier dsa.dsa_fops; | ||
43 | @@ | ||
44 | - debugfs_create_file(name, mode, parent, data, &dsa_fops) | ||
45 | + debugfs_create_file_unsafe(name, mode, parent, data, &dsa_fops) | ||
46 | |||
47 | @patch_dsa depends on patch_dcf && patch@ | ||
48 | identifier dsa.dsa_fops; | ||
49 | expression dsa.dsa_get, dsa.dsa_set, dsa.dsa_fmt; | ||
50 | @@ | ||
51 | - DEFINE_SIMPLE_ATTRIBUTE(dsa_fops, dsa_get, dsa_set, dsa_fmt); | ||
52 | + DEFINE_DEBUGFS_ATTRIBUTE(dsa_fops, dsa_get, dsa_set, dsa_fmt); | ||
53 | |||
54 | |||
55 | @script:python depends on org && dcf@ | ||
56 | fops << dsa.dsa_fops; | ||
57 | p << dsa.p; | ||
58 | @@ | ||
59 | msg="%s should be defined with DEFINE_DEBUGFS_ATTRIBUTE" % (fops) | ||
60 | coccilib.org.print_todo(p[0], msg) | ||
61 | |||
62 | @script:python depends on report && dcf@ | ||
63 | fops << dsa.dsa_fops; | ||
64 | p << dsa.p; | ||
65 | @@ | ||
66 | msg="WARNING: %s should be defined with DEFINE_DEBUGFS_ATTRIBUTE" % (fops) | ||
67 | coccilib.report.print_report(p[0], msg) | ||
diff --git a/scripts/coccinelle/api/setup_timer.cocci b/scripts/coccinelle/api/setup_timer.cocci index 8ee0ac30e547..eb6bd9e4ab1a 100644 --- a/scripts/coccinelle/api/setup_timer.cocci +++ b/scripts/coccinelle/api/setup_timer.cocci | |||
@@ -106,7 +106,7 @@ position j0, j1, j2; | |||
106 | @match_function_and_data_after_init_timer_context | 106 | @match_function_and_data_after_init_timer_context |
107 | depends on !patch && | 107 | depends on !patch && |
108 | !match_immediate_function_data_after_init_timer_context && | 108 | !match_immediate_function_data_after_init_timer_context && |
109 | (context || org || report)@ | 109 | (context || org || report)@ |
110 | expression a, b, e1, e2, e3, e4, e5; | 110 | expression a, b, e1, e2, e3, e4, e5; |
111 | position j0, j1, j2; | 111 | position j0, j1, j2; |
112 | @@ | 112 | @@ |
@@ -127,7 +127,7 @@ position j0, j1, j2; | |||
127 | @r3_context depends on !patch && | 127 | @r3_context depends on !patch && |
128 | !match_immediate_function_data_after_init_timer_context && | 128 | !match_immediate_function_data_after_init_timer_context && |
129 | !match_function_and_data_after_init_timer_context && | 129 | !match_function_and_data_after_init_timer_context && |
130 | (context || org || report)@ | 130 | (context || org || report)@ |
131 | expression c, e6, e7; | 131 | expression c, e6, e7; |
132 | position r1.p; | 132 | position r1.p; |
133 | position j0, j1; | 133 | position j0, j1; |
diff --git a/scripts/coccinelle/misc/compare_const_fl.cocci b/scripts/coccinelle/misc/compare_const_fl.cocci deleted file mode 100644 index b5d4bab60263..000000000000 --- a/scripts/coccinelle/misc/compare_const_fl.cocci +++ /dev/null | |||
@@ -1,171 +0,0 @@ | |||
1 | /// Move constants to the right of binary operators. | ||
2 | //# Depends on personal taste in some cases. | ||
3 | /// | ||
4 | // Confidence: Moderate | ||
5 | // Copyright: (C) 2015 Copyright: (C) 2015 Julia Lawall, Inria. GPLv2. | ||
6 | // URL: http://coccinelle.lip6.fr/ | ||
7 | // Options: --no-includes --include-headers | ||
8 | |||
9 | virtual patch | ||
10 | virtual context | ||
11 | virtual org | ||
12 | virtual report | ||
13 | |||
14 | @r1 depends on patch && !context && !org && !report | ||
15 | disable bitor_comm, neg_if_exp@ | ||
16 | constant c,c1; | ||
17 | local idexpression i; | ||
18 | expression e,e1,e2; | ||
19 | binary operator b = {==,!=,&,|}; | ||
20 | type t; | ||
21 | @@ | ||
22 | |||
23 | ( | ||
24 | c b (c1) | ||
25 | | | ||
26 | sizeof(t) b e1 | ||
27 | | | ||
28 | sizeof e b e1 | ||
29 | | | ||
30 | i b e1 | ||
31 | | | ||
32 | c | e1 | e2 | ... | ||
33 | | | ||
34 | c | (e ? e1 : e2) | ||
35 | | | ||
36 | - c | ||
37 | + e | ||
38 | b | ||
39 | - e | ||
40 | + c | ||
41 | ) | ||
42 | |||
43 | @r2 depends on patch && !context && !org && !report | ||
44 | disable gtr_lss, gtr_lss_eq, not_int2@ | ||
45 | constant c,c1; | ||
46 | expression e,e1,e2; | ||
47 | binary operator b; | ||
48 | binary operator b1 = {<,<=},b2 = {<,<=}; | ||
49 | binary operator b3 = {>,>=},b4 = {>,>=}; | ||
50 | local idexpression i; | ||
51 | type t; | ||
52 | @@ | ||
53 | |||
54 | ( | ||
55 | c b c1 | ||
56 | | | ||
57 | sizeof(t) b e1 | ||
58 | | | ||
59 | sizeof e b e1 | ||
60 | | | ||
61 | (e1 b1 e) && (e b2 e2) | ||
62 | | | ||
63 | (e1 b3 e) && (e b4 e2) | ||
64 | | | ||
65 | i b e | ||
66 | | | ||
67 | - c < e | ||
68 | + e > c | ||
69 | | | ||
70 | - c <= e | ||
71 | + e >= c | ||
72 | | | ||
73 | - c > e | ||
74 | + e < c | ||
75 | | | ||
76 | - c >= e | ||
77 | + e <= c | ||
78 | ) | ||
79 | |||
80 | // ---------------------------------------------------------------------------- | ||
81 | |||
82 | @r1_context depends on !patch && (context || org || report) | ||
83 | disable bitor_comm, neg_if_exp exists@ | ||
84 | type t; | ||
85 | binary operator b = {==,!=,&,|}; | ||
86 | constant c, c1; | ||
87 | expression e, e1, e2; | ||
88 | local idexpression i; | ||
89 | position j0; | ||
90 | @@ | ||
91 | |||
92 | ( | ||
93 | c b (c1) | ||
94 | | | ||
95 | sizeof(t) b e1 | ||
96 | | | ||
97 | sizeof e b e1 | ||
98 | | | ||
99 | i b e1 | ||
100 | | | ||
101 | c | e1 | e2 | ... | ||
102 | | | ||
103 | c | (e ? e1 : e2) | ||
104 | | | ||
105 | * c@j0 b e | ||
106 | ) | ||
107 | |||
108 | @r2_context depends on !patch && (context || org || report) | ||
109 | disable gtr_lss, gtr_lss_eq, not_int2 exists@ | ||
110 | type t; | ||
111 | binary operator b, b1 = {<,<=}, b2 = {<,<=}, b3 = {>,>=}, b4 = {>,>=}; | ||
112 | constant c, c1; | ||
113 | expression e, e1, e2; | ||
114 | local idexpression i; | ||
115 | position j0; | ||
116 | @@ | ||
117 | |||
118 | ( | ||
119 | c b c1 | ||
120 | | | ||
121 | sizeof(t) b e1 | ||
122 | | | ||
123 | sizeof e b e1 | ||
124 | | | ||
125 | (e1 b1 e) && (e b2 e2) | ||
126 | | | ||
127 | (e1 b3 e) && (e b4 e2) | ||
128 | | | ||
129 | i b e | ||
130 | | | ||
131 | * c@j0 < e | ||
132 | | | ||
133 | * c@j0 <= e | ||
134 | | | ||
135 | * c@j0 > e | ||
136 | | | ||
137 | * c@j0 >= e | ||
138 | ) | ||
139 | |||
140 | // ---------------------------------------------------------------------------- | ||
141 | |||
142 | @script:python r1_org depends on org@ | ||
143 | j0 << r1_context.j0; | ||
144 | @@ | ||
145 | |||
146 | msg = "Move constant to right." | ||
147 | coccilib.org.print_todo(j0[0], msg) | ||
148 | |||
149 | @script:python r2_org depends on org@ | ||
150 | j0 << r2_context.j0; | ||
151 | @@ | ||
152 | |||
153 | msg = "Move constant to right." | ||
154 | coccilib.org.print_todo(j0[0], msg) | ||
155 | |||
156 | // ---------------------------------------------------------------------------- | ||
157 | |||
158 | @script:python r1_report depends on report@ | ||
159 | j0 << r1_context.j0; | ||
160 | @@ | ||
161 | |||
162 | msg = "Move constant to right." | ||
163 | coccilib.report.print_report(j0[0], msg) | ||
164 | |||
165 | @script:python r2_report depends on report@ | ||
166 | j0 << r2_context.j0; | ||
167 | @@ | ||
168 | |||
169 | msg = "Move constant to right." | ||
170 | coccilib.report.print_report(j0[0], msg) | ||
171 | |||
diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh index 00d6d53c2681..c332684e1b5a 100755 --- a/scripts/decode_stacktrace.sh +++ b/scripts/decode_stacktrace.sh | |||
@@ -2,15 +2,17 @@ | |||
2 | # (c) 2014, Sasha Levin <sasha.levin@oracle.com> | 2 | # (c) 2014, Sasha Levin <sasha.levin@oracle.com> |
3 | #set -x | 3 | #set -x |
4 | 4 | ||
5 | if [[ $# != 2 ]]; then | 5 | if [[ $# < 2 ]]; then |
6 | echo "Usage:" | 6 | echo "Usage:" |
7 | echo " $0 [vmlinux] [base path]" | 7 | echo " $0 [vmlinux] [base path] [modules path]" |
8 | exit 1 | 8 | exit 1 |
9 | fi | 9 | fi |
10 | 10 | ||
11 | vmlinux=$1 | 11 | vmlinux=$1 |
12 | basepath=$2 | 12 | basepath=$2 |
13 | modpath=$3 | ||
13 | declare -A cache | 14 | declare -A cache |
15 | declare -A modcache | ||
14 | 16 | ||
15 | parse_symbol() { | 17 | parse_symbol() { |
16 | # The structure of symbol at this point is: | 18 | # The structure of symbol at this point is: |
@@ -19,6 +21,17 @@ parse_symbol() { | |||
19 | # For example: | 21 | # For example: |
20 | # do_basic_setup+0x9c/0xbf | 22 | # do_basic_setup+0x9c/0xbf |
21 | 23 | ||
24 | if [[ $module == "" ]] ; then | ||
25 | local objfile=$vmlinux | ||
26 | elif [[ "${modcache[$module]+isset}" == "isset" ]]; then | ||
27 | local objfile=${modcache[$module]} | ||
28 | else | ||
29 | [[ $modpath == "" ]] && return | ||
30 | local objfile=$(find "$modpath" -name $module.ko -print -quit) | ||
31 | [[ $objfile == "" ]] && return | ||
32 | modcache[$module]=$objfile | ||
33 | fi | ||
34 | |||
22 | # Remove the englobing parenthesis | 35 | # Remove the englobing parenthesis |
23 | symbol=${symbol#\(} | 36 | symbol=${symbol#\(} |
24 | symbol=${symbol%\)} | 37 | symbol=${symbol%\)} |
@@ -29,11 +42,11 @@ parse_symbol() { | |||
29 | # Use 'nm vmlinux' to figure out the base address of said symbol. | 42 | # Use 'nm vmlinux' to figure out the base address of said symbol. |
30 | # It's actually faster to call it every time than to load it | 43 | # It's actually faster to call it every time than to load it |
31 | # all into bash. | 44 | # all into bash. |
32 | if [[ "${cache[$name]+isset}" == "isset" ]]; then | 45 | if [[ "${cache[$module,$name]+isset}" == "isset" ]]; then |
33 | local base_addr=${cache[$name]} | 46 | local base_addr=${cache[$module,$name]} |
34 | else | 47 | else |
35 | local base_addr=$(nm "$vmlinux" | grep -i ' t ' | awk "/ $name\$/ {print \$1}" | head -n1) | 48 | local base_addr=$(nm "$objfile" | grep -i ' t ' | awk "/ $name\$/ {print \$1}" | head -n1) |
36 | cache["$name"]="$base_addr" | 49 | cache[$module,$name]="$base_addr" |
37 | fi | 50 | fi |
38 | # Let's start doing the math to get the exact address into the | 51 | # Let's start doing the math to get the exact address into the |
39 | # symbol. First, strip out the symbol total length. | 52 | # symbol. First, strip out the symbol total length. |
@@ -48,12 +61,12 @@ parse_symbol() { | |||
48 | local address=$(printf "%x\n" "$expr") | 61 | local address=$(printf "%x\n" "$expr") |
49 | 62 | ||
50 | # Pass it to addr2line to get filename and line number | 63 | # Pass it to addr2line to get filename and line number |
51 | # Could get more than one result | 64 | # Could get more than one result |
52 | if [[ "${cache[$address]+isset}" == "isset" ]]; then | 65 | if [[ "${cache[$module,$address]+isset}" == "isset" ]]; then |
53 | local code=${cache[$address]} | 66 | local code=${cache[$module,$address]} |
54 | else | 67 | else |
55 | local code=$(addr2line -i -e "$vmlinux" "$address") | 68 | local code=$(addr2line -i -e "$objfile" "$address") |
56 | cache[$address]=$code | 69 | cache[$module,$address]=$code |
57 | fi | 70 | fi |
58 | 71 | ||
59 | # addr2line doesn't return a proper error code if it fails, so | 72 | # addr2line doesn't return a proper error code if it fails, so |
@@ -105,13 +118,23 @@ handle_line() { | |||
105 | fi | 118 | fi |
106 | done | 119 | done |
107 | 120 | ||
108 | # The symbol is the last element, process it | 121 | if [[ ${words[$last]} =~ \[([^]]+)\] ]]; then |
109 | symbol=${words[$last]} | 122 | module=${words[$last]} |
123 | module=${module#\[} | ||
124 | module=${module%\]} | ||
125 | symbol=${words[$last-1]} | ||
126 | unset words[$last-1] | ||
127 | else | ||
128 | # The symbol is the last element, process it | ||
129 | symbol=${words[$last]} | ||
130 | module= | ||
131 | fi | ||
132 | |||
110 | unset words[$last] | 133 | unset words[$last] |
111 | parse_symbol # modifies $symbol | 134 | parse_symbol # modifies $symbol |
112 | 135 | ||
113 | # Add up the line number to the symbol | 136 | # Add up the line number to the symbol |
114 | echo "${words[@]}" "$symbol" | 137 | echo "${words[@]}" "$symbol $module" |
115 | } | 138 | } |
116 | 139 | ||
117 | while read line; do | 140 | while read line; do |
@@ -121,8 +144,8 @@ while read line; do | |||
121 | handle_line "$line" | 144 | handle_line "$line" |
122 | # Is it a code line? | 145 | # Is it a code line? |
123 | elif [[ $line == *Code:* ]]; then | 146 | elif [[ $line == *Code:* ]]; then |
124 | decode_code "$line" | 147 | decode_code "$line" |
125 | else | 148 | else |
126 | # Nothing special in this line, show it as is | 149 | # Nothing special in this line, show it as is |
127 | echo "$line" | 150 | echo "$line" |
128 | fi | 151 | fi |
diff --git a/scripts/docproc.c b/scripts/docproc.c index e267e621431a..0a12593b9041 100644 --- a/scripts/docproc.c +++ b/scripts/docproc.c | |||
@@ -42,8 +42,10 @@ | |||
42 | #include <unistd.h> | 42 | #include <unistd.h> |
43 | #include <limits.h> | 43 | #include <limits.h> |
44 | #include <errno.h> | 44 | #include <errno.h> |
45 | #include <getopt.h> | ||
45 | #include <sys/types.h> | 46 | #include <sys/types.h> |
46 | #include <sys/wait.h> | 47 | #include <sys/wait.h> |
48 | #include <time.h> | ||
47 | 49 | ||
48 | /* exitstatus is used to keep track of any failing calls to kernel-doc, | 50 | /* exitstatus is used to keep track of any failing calls to kernel-doc, |
49 | * but execution continues. */ | 51 | * but execution continues. */ |
@@ -68,12 +70,23 @@ FILELINE * docsection; | |||
68 | #define KERNELDOCPATH "scripts/" | 70 | #define KERNELDOCPATH "scripts/" |
69 | #define KERNELDOC "kernel-doc" | 71 | #define KERNELDOC "kernel-doc" |
70 | #define DOCBOOK "-docbook" | 72 | #define DOCBOOK "-docbook" |
73 | #define RST "-rst" | ||
71 | #define LIST "-list" | 74 | #define LIST "-list" |
72 | #define FUNCTION "-function" | 75 | #define FUNCTION "-function" |
73 | #define NOFUNCTION "-nofunction" | 76 | #define NOFUNCTION "-nofunction" |
74 | #define NODOCSECTIONS "-no-doc-sections" | 77 | #define NODOCSECTIONS "-no-doc-sections" |
75 | #define SHOWNOTFOUND "-show-not-found" | 78 | #define SHOWNOTFOUND "-show-not-found" |
76 | 79 | ||
80 | enum file_format { | ||
81 | FORMAT_AUTO, | ||
82 | FORMAT_DOCBOOK, | ||
83 | FORMAT_RST, | ||
84 | }; | ||
85 | |||
86 | static enum file_format file_format = FORMAT_AUTO; | ||
87 | |||
88 | #define KERNELDOC_FORMAT (file_format == FORMAT_RST ? RST : DOCBOOK) | ||
89 | |||
77 | static char *srctree, *kernsrctree; | 90 | static char *srctree, *kernsrctree; |
78 | 91 | ||
79 | static char **all_list = NULL; | 92 | static char **all_list = NULL; |
@@ -95,7 +108,7 @@ static void consume_symbol(const char *sym) | |||
95 | 108 | ||
96 | static void usage (void) | 109 | static void usage (void) |
97 | { | 110 | { |
98 | fprintf(stderr, "Usage: docproc {doc|depend} file\n"); | 111 | fprintf(stderr, "Usage: docproc [{--docbook|--rst}] {doc|depend} file\n"); |
99 | fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n"); | 112 | fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n"); |
100 | fprintf(stderr, "doc: frontend when generating kernel documentation\n"); | 113 | fprintf(stderr, "doc: frontend when generating kernel documentation\n"); |
101 | fprintf(stderr, "depend: generate list of files referenced within file\n"); | 114 | fprintf(stderr, "depend: generate list of files referenced within file\n"); |
@@ -242,7 +255,7 @@ static void find_export_symbols(char * filename) | |||
242 | /* | 255 | /* |
243 | * Document all external or internal functions in a file. | 256 | * Document all external or internal functions in a file. |
244 | * Call kernel-doc with following parameters: | 257 | * Call kernel-doc with following parameters: |
245 | * kernel-doc -docbook -nofunction function_name1 filename | 258 | * kernel-doc [-docbook|-rst] -nofunction function_name1 filename |
246 | * Function names are obtained from all the src files | 259 | * Function names are obtained from all the src files |
247 | * by find_export_symbols. | 260 | * by find_export_symbols. |
248 | * intfunc uses -nofunction | 261 | * intfunc uses -nofunction |
@@ -263,7 +276,7 @@ static void docfunctions(char * filename, char * type) | |||
263 | exit(1); | 276 | exit(1); |
264 | } | 277 | } |
265 | vec[idx++] = KERNELDOC; | 278 | vec[idx++] = KERNELDOC; |
266 | vec[idx++] = DOCBOOK; | 279 | vec[idx++] = KERNELDOC_FORMAT; |
267 | vec[idx++] = NODOCSECTIONS; | 280 | vec[idx++] = NODOCSECTIONS; |
268 | for (i=0; i < symfilecnt; i++) { | 281 | for (i=0; i < symfilecnt; i++) { |
269 | struct symfile * sym = &symfilelist[i]; | 282 | struct symfile * sym = &symfilelist[i]; |
@@ -275,7 +288,10 @@ static void docfunctions(char * filename, char * type) | |||
275 | } | 288 | } |
276 | vec[idx++] = filename; | 289 | vec[idx++] = filename; |
277 | vec[idx] = NULL; | 290 | vec[idx] = NULL; |
278 | printf("<!-- %s -->\n", filename); | 291 | if (file_format == FORMAT_RST) |
292 | printf(".. %s\n", filename); | ||
293 | else | ||
294 | printf("<!-- %s -->\n", filename); | ||
279 | exec_kernel_doc(vec); | 295 | exec_kernel_doc(vec); |
280 | fflush(stdout); | 296 | fflush(stdout); |
281 | free(vec); | 297 | free(vec); |
@@ -294,7 +310,7 @@ static void singfunc(char * filename, char * line) | |||
294 | int i, idx = 0; | 310 | int i, idx = 0; |
295 | int startofsym = 1; | 311 | int startofsym = 1; |
296 | vec[idx++] = KERNELDOC; | 312 | vec[idx++] = KERNELDOC; |
297 | vec[idx++] = DOCBOOK; | 313 | vec[idx++] = KERNELDOC_FORMAT; |
298 | vec[idx++] = SHOWNOTFOUND; | 314 | vec[idx++] = SHOWNOTFOUND; |
299 | 315 | ||
300 | /* Split line up in individual parameters preceded by FUNCTION */ | 316 | /* Split line up in individual parameters preceded by FUNCTION */ |
@@ -343,7 +359,7 @@ static void docsect(char *filename, char *line) | |||
343 | free(s); | 359 | free(s); |
344 | 360 | ||
345 | vec[0] = KERNELDOC; | 361 | vec[0] = KERNELDOC; |
346 | vec[1] = DOCBOOK; | 362 | vec[1] = KERNELDOC_FORMAT; |
347 | vec[2] = SHOWNOTFOUND; | 363 | vec[2] = SHOWNOTFOUND; |
348 | vec[3] = FUNCTION; | 364 | vec[3] = FUNCTION; |
349 | vec[4] = line; | 365 | vec[4] = line; |
@@ -431,6 +447,32 @@ static void find_all_symbols(char *filename) | |||
431 | } | 447 | } |
432 | 448 | ||
433 | /* | 449 | /* |
450 | * Terminate s at first space, if any. If there was a space, return pointer to | ||
451 | * the character after that. Otherwise, return pointer to the terminating NUL. | ||
452 | */ | ||
453 | static char *chomp(char *s) | ||
454 | { | ||
455 | while (*s && !isspace(*s)) | ||
456 | s++; | ||
457 | |||
458 | if (*s) | ||
459 | *s++ = '\0'; | ||
460 | |||
461 | return s; | ||
462 | } | ||
463 | |||
464 | /* Return pointer to directive content, or NULL if not a directive. */ | ||
465 | static char *is_directive(char *line) | ||
466 | { | ||
467 | if (file_format == FORMAT_DOCBOOK && line[0] == '!') | ||
468 | return line + 1; | ||
469 | else if (file_format == FORMAT_RST && !strncmp(line, ".. !", 4)) | ||
470 | return line + 4; | ||
471 | |||
472 | return NULL; | ||
473 | } | ||
474 | |||
475 | /* | ||
434 | * Parse file, calling action specific functions for: | 476 | * Parse file, calling action specific functions for: |
435 | * 1) Lines containing !E | 477 | * 1) Lines containing !E |
436 | * 2) Lines containing !I | 478 | * 2) Lines containing !I |
@@ -443,63 +485,75 @@ static void find_all_symbols(char *filename) | |||
443 | static void parse_file(FILE *infile) | 485 | static void parse_file(FILE *infile) |
444 | { | 486 | { |
445 | char line[MAXLINESZ]; | 487 | char line[MAXLINESZ]; |
446 | char * s; | 488 | char *p, *s; |
447 | while (fgets(line, MAXLINESZ, infile)) { | 489 | while (fgets(line, MAXLINESZ, infile)) { |
448 | if (line[0] == '!') { | 490 | p = is_directive(line); |
449 | s = line + 2; | 491 | if (!p) { |
450 | switch (line[1]) { | 492 | defaultline(line); |
451 | case 'E': | 493 | continue; |
452 | while (*s && !isspace(*s)) s++; | 494 | } |
453 | *s = '\0'; | 495 | |
454 | externalfunctions(line+2); | 496 | switch (*p++) { |
455 | break; | 497 | case 'E': |
456 | case 'I': | 498 | chomp(p); |
457 | while (*s && !isspace(*s)) s++; | 499 | externalfunctions(p); |
458 | *s = '\0'; | 500 | break; |
459 | internalfunctions(line+2); | 501 | case 'I': |
460 | break; | 502 | chomp(p); |
461 | case 'D': | 503 | internalfunctions(p); |
462 | while (*s && !isspace(*s)) s++; | 504 | break; |
463 | *s = '\0'; | 505 | case 'D': |
464 | symbolsonly(line+2); | 506 | chomp(p); |
465 | break; | 507 | symbolsonly(p); |
466 | case 'F': | 508 | break; |
467 | /* filename */ | 509 | case 'F': |
468 | while (*s && !isspace(*s)) s++; | 510 | /* filename */ |
469 | *s++ = '\0'; | 511 | s = chomp(p); |
470 | /* function names */ | 512 | /* function names */ |
471 | while (isspace(*s)) | 513 | while (isspace(*s)) |
472 | s++; | 514 | s++; |
473 | singlefunctions(line +2, s); | 515 | singlefunctions(p, s); |
474 | break; | 516 | break; |
475 | case 'P': | 517 | case 'P': |
476 | /* filename */ | 518 | /* filename */ |
477 | while (*s && !isspace(*s)) s++; | 519 | s = chomp(p); |
478 | *s++ = '\0'; | 520 | /* DOC: section name */ |
479 | /* DOC: section name */ | 521 | while (isspace(*s)) |
480 | while (isspace(*s)) | 522 | s++; |
481 | s++; | 523 | docsection(p, s); |
482 | docsection(line + 2, s); | 524 | break; |
483 | break; | 525 | case 'C': |
484 | case 'C': | 526 | chomp(p); |
485 | while (*s && !isspace(*s)) s++; | 527 | if (findall) |
486 | *s = '\0'; | 528 | findall(p); |
487 | if (findall) | 529 | break; |
488 | findall(line+2); | 530 | default: |
489 | break; | ||
490 | default: | ||
491 | defaultline(line); | ||
492 | } | ||
493 | } else { | ||
494 | defaultline(line); | 531 | defaultline(line); |
495 | } | 532 | } |
496 | } | 533 | } |
497 | fflush(stdout); | 534 | fflush(stdout); |
498 | } | 535 | } |
499 | 536 | ||
537 | /* | ||
538 | * Is this a RestructuredText template? Answer the question by seeing if its | ||
539 | * name ends in ".rst". | ||
540 | */ | ||
541 | static int is_rst(const char *file) | ||
542 | { | ||
543 | char *dot = strrchr(file, '.'); | ||
544 | |||
545 | return dot && !strcmp(dot + 1, "rst"); | ||
546 | } | ||
547 | |||
548 | enum opts { | ||
549 | OPT_DOCBOOK, | ||
550 | OPT_RST, | ||
551 | OPT_HELP, | ||
552 | }; | ||
500 | 553 | ||
501 | int main(int argc, char *argv[]) | 554 | int main(int argc, char *argv[]) |
502 | { | 555 | { |
556 | const char *subcommand, *filename; | ||
503 | FILE * infile; | 557 | FILE * infile; |
504 | int i; | 558 | int i; |
505 | 559 | ||
@@ -509,19 +563,66 @@ int main(int argc, char *argv[]) | |||
509 | kernsrctree = getenv("KBUILD_SRC"); | 563 | kernsrctree = getenv("KBUILD_SRC"); |
510 | if (!kernsrctree || !*kernsrctree) | 564 | if (!kernsrctree || !*kernsrctree) |
511 | kernsrctree = srctree; | 565 | kernsrctree = srctree; |
512 | if (argc != 3) { | 566 | |
567 | for (;;) { | ||
568 | int c; | ||
569 | struct option opts[] = { | ||
570 | { "docbook", no_argument, NULL, OPT_DOCBOOK }, | ||
571 | { "rst", no_argument, NULL, OPT_RST }, | ||
572 | { "help", no_argument, NULL, OPT_HELP }, | ||
573 | {} | ||
574 | }; | ||
575 | |||
576 | c = getopt_long_only(argc, argv, "", opts, NULL); | ||
577 | if (c == -1) | ||
578 | break; | ||
579 | |||
580 | switch (c) { | ||
581 | case OPT_DOCBOOK: | ||
582 | file_format = FORMAT_DOCBOOK; | ||
583 | break; | ||
584 | case OPT_RST: | ||
585 | file_format = FORMAT_RST; | ||
586 | break; | ||
587 | case OPT_HELP: | ||
588 | usage(); | ||
589 | return 0; | ||
590 | default: | ||
591 | case '?': | ||
592 | usage(); | ||
593 | return 1; | ||
594 | } | ||
595 | } | ||
596 | |||
597 | argc -= optind; | ||
598 | argv += optind; | ||
599 | |||
600 | if (argc != 2) { | ||
513 | usage(); | 601 | usage(); |
514 | exit(1); | 602 | exit(1); |
515 | } | 603 | } |
604 | |||
605 | subcommand = argv[0]; | ||
606 | filename = argv[1]; | ||
607 | |||
608 | if (file_format == FORMAT_AUTO) | ||
609 | file_format = is_rst(filename) ? FORMAT_RST : FORMAT_DOCBOOK; | ||
610 | |||
516 | /* Open file, exit on error */ | 611 | /* Open file, exit on error */ |
517 | infile = fopen(argv[2], "r"); | 612 | infile = fopen(filename, "r"); |
518 | if (infile == NULL) { | 613 | if (infile == NULL) { |
519 | fprintf(stderr, "docproc: "); | 614 | fprintf(stderr, "docproc: "); |
520 | perror(argv[2]); | 615 | perror(filename); |
521 | exit(2); | 616 | exit(2); |
522 | } | 617 | } |
523 | 618 | ||
524 | if (strcmp("doc", argv[1]) == 0) { | 619 | if (strcmp("doc", subcommand) == 0) { |
620 | if (file_format == FORMAT_RST) { | ||
621 | time_t t = time(NULL); | ||
622 | printf(".. generated from %s by docproc %s\n", | ||
623 | filename, ctime(&t)); | ||
624 | } | ||
625 | |||
525 | /* Need to do this in two passes. | 626 | /* Need to do this in two passes. |
526 | * First pass is used to collect all symbols exported | 627 | * First pass is used to collect all symbols exported |
527 | * in the various files; | 628 | * in the various files; |
@@ -557,10 +658,10 @@ int main(int argc, char *argv[]) | |||
557 | fprintf(stderr, "Warning: didn't use docs for %s\n", | 658 | fprintf(stderr, "Warning: didn't use docs for %s\n", |
558 | all_list[i]); | 659 | all_list[i]); |
559 | } | 660 | } |
560 | } else if (strcmp("depend", argv[1]) == 0) { | 661 | } else if (strcmp("depend", subcommand) == 0) { |
561 | /* Create first part of dependency chain | 662 | /* Create first part of dependency chain |
562 | * file.tmpl */ | 663 | * file.tmpl */ |
563 | printf("%s\t", argv[2]); | 664 | printf("%s\t", filename); |
564 | defaultline = noaction; | 665 | defaultline = noaction; |
565 | internalfunctions = adddep; | 666 | internalfunctions = adddep; |
566 | externalfunctions = adddep; | 667 | externalfunctions = adddep; |
@@ -571,7 +672,7 @@ int main(int argc, char *argv[]) | |||
571 | parse_file(infile); | 672 | parse_file(infile); |
572 | printf("\n"); | 673 | printf("\n"); |
573 | } else { | 674 | } else { |
574 | fprintf(stderr, "Unknown option: %s\n", argv[1]); | 675 | fprintf(stderr, "Unknown option: %s\n", subcommand); |
575 | exit(1); | 676 | exit(1); |
576 | } | 677 | } |
577 | fclose(infile); | 678 | fclose(infile); |
diff --git a/scripts/dtc/checks.c b/scripts/dtc/checks.c index 0c03ac9159c1..386f9563313f 100644 --- a/scripts/dtc/checks.c +++ b/scripts/dtc/checks.c | |||
@@ -294,6 +294,30 @@ static void check_node_name_format(struct check *c, struct node *dt, | |||
294 | } | 294 | } |
295 | NODE_ERROR(node_name_format, NULL, &node_name_chars); | 295 | NODE_ERROR(node_name_format, NULL, &node_name_chars); |
296 | 296 | ||
297 | static void check_unit_address_vs_reg(struct check *c, struct node *dt, | ||
298 | struct node *node) | ||
299 | { | ||
300 | const char *unitname = get_unitname(node); | ||
301 | struct property *prop = get_property(node, "reg"); | ||
302 | |||
303 | if (!prop) { | ||
304 | prop = get_property(node, "ranges"); | ||
305 | if (prop && !prop->val.len) | ||
306 | prop = NULL; | ||
307 | } | ||
308 | |||
309 | if (prop) { | ||
310 | if (!unitname[0]) | ||
311 | FAIL(c, "Node %s has a reg or ranges property, but no unit name", | ||
312 | node->fullpath); | ||
313 | } else { | ||
314 | if (unitname[0]) | ||
315 | FAIL(c, "Node %s has a unit name, but no reg property", | ||
316 | node->fullpath); | ||
317 | } | ||
318 | } | ||
319 | NODE_WARNING(unit_address_vs_reg, NULL); | ||
320 | |||
297 | static void check_property_name_chars(struct check *c, struct node *dt, | 321 | static void check_property_name_chars(struct check *c, struct node *dt, |
298 | struct node *node, struct property *prop) | 322 | struct node *node, struct property *prop) |
299 | { | 323 | { |
@@ -667,6 +691,8 @@ static struct check *check_table[] = { | |||
667 | 691 | ||
668 | &addr_size_cells, ®_format, &ranges_format, | 692 | &addr_size_cells, ®_format, &ranges_format, |
669 | 693 | ||
694 | &unit_address_vs_reg, | ||
695 | |||
670 | &avoid_default_addr_size, | 696 | &avoid_default_addr_size, |
671 | &obsolete_chosen_interrupt_controller, | 697 | &obsolete_chosen_interrupt_controller, |
672 | 698 | ||
diff --git a/scripts/dtc/flattree.c b/scripts/dtc/flattree.c index bd99fa2d33b8..ec14954f5810 100644 --- a/scripts/dtc/flattree.c +++ b/scripts/dtc/flattree.c | |||
@@ -889,7 +889,7 @@ struct boot_info *dt_from_blob(const char *fname) | |||
889 | 889 | ||
890 | if (version >= 3) { | 890 | if (version >= 3) { |
891 | uint32_t size_str = fdt32_to_cpu(fdt->size_dt_strings); | 891 | uint32_t size_str = fdt32_to_cpu(fdt->size_dt_strings); |
892 | if (off_str+size_str > totalsize) | 892 | if ((off_str+size_str < off_str) || (off_str+size_str > totalsize)) |
893 | die("String table extends past total size\n"); | 893 | die("String table extends past total size\n"); |
894 | inbuf_init(&strbuf, blob + off_str, blob + off_str + size_str); | 894 | inbuf_init(&strbuf, blob + off_str, blob + off_str + size_str); |
895 | } else { | 895 | } else { |
@@ -898,7 +898,7 @@ struct boot_info *dt_from_blob(const char *fname) | |||
898 | 898 | ||
899 | if (version >= 17) { | 899 | if (version >= 17) { |
900 | size_dt = fdt32_to_cpu(fdt->size_dt_struct); | 900 | size_dt = fdt32_to_cpu(fdt->size_dt_struct); |
901 | if (off_dt+size_dt > totalsize) | 901 | if ((off_dt+size_dt < off_dt) || (off_dt+size_dt > totalsize)) |
902 | die("Structure block extends past total size\n"); | 902 | die("Structure block extends past total size\n"); |
903 | } | 903 | } |
904 | 904 | ||
diff --git a/scripts/dtc/libfdt/fdt_ro.c b/scripts/dtc/libfdt/fdt_ro.c index e5b313682007..50cce864283c 100644 --- a/scripts/dtc/libfdt/fdt_ro.c +++ b/scripts/dtc/libfdt/fdt_ro.c | |||
@@ -647,10 +647,8 @@ int fdt_node_check_compatible(const void *fdt, int nodeoffset, | |||
647 | prop = fdt_getprop(fdt, nodeoffset, "compatible", &len); | 647 | prop = fdt_getprop(fdt, nodeoffset, "compatible", &len); |
648 | if (!prop) | 648 | if (!prop) |
649 | return len; | 649 | return len; |
650 | if (fdt_stringlist_contains(prop, len, compatible)) | 650 | |
651 | return 0; | 651 | return !fdt_stringlist_contains(prop, len, compatible); |
652 | else | ||
653 | return 1; | ||
654 | } | 652 | } |
655 | 653 | ||
656 | int fdt_node_offset_by_compatible(const void *fdt, int startoffset, | 654 | int fdt_node_offset_by_compatible(const void *fdt, int startoffset, |
diff --git a/scripts/dtc/version_gen.h b/scripts/dtc/version_gen.h index 11d93e6d8220..ad9b05ae698b 100644 --- a/scripts/dtc/version_gen.h +++ b/scripts/dtc/version_gen.h | |||
@@ -1 +1 @@ | |||
#define DTC_VERSION "DTC 1.4.1-gb06e55c8" | #define DTC_VERSION "DTC 1.4.1-g53bf130b" | ||
diff --git a/scripts/gdb/linux/Makefile b/scripts/gdb/linux/Makefile index 6cf1ecf61057..cd129e65d1ff 100644 --- a/scripts/gdb/linux/Makefile +++ b/scripts/gdb/linux/Makefile | |||
@@ -8,4 +8,14 @@ ifneq ($(KBUILD_SRC),) | |||
8 | endif | 8 | endif |
9 | @: | 9 | @: |
10 | 10 | ||
11 | clean-files := *.pyc *.pyo $(if $(KBUILD_SRC),*.py) | 11 | quiet_cmd_gen_constants_py = GEN $@ |
12 | cmd_gen_constants_py = \ | ||
13 | $(CPP) -E -x c -P $(c_flags) $< > $@ ;\ | ||
14 | sed -i '1,/<!-- end-c-headers -->/d;' $@ | ||
15 | |||
16 | $(obj)/constants.py: $(SRCTREE)/$(obj)/constants.py.in | ||
17 | $(call if_changed,gen_constants_py) | ||
18 | |||
19 | build_constants_py: $(obj)/constants.py | ||
20 | |||
21 | clean-files := *.pyc *.pyo $(if $(KBUILD_SRC),*.py) $(obj)/constants.py | ||
diff --git a/scripts/gdb/linux/constants.py.in b/scripts/gdb/linux/constants.py.in new file mode 100644 index 000000000000..07e6c2befe36 --- /dev/null +++ b/scripts/gdb/linux/constants.py.in | |||
@@ -0,0 +1,59 @@ | |||
1 | /* | ||
2 | * gdb helper commands and functions for Linux kernel debugging | ||
3 | * | ||
4 | * Kernel constants derived from include files. | ||
5 | * | ||
6 | * Copyright (c) 2016 Linaro Ltd | ||
7 | * | ||
8 | * Authors: | ||
9 | * Kieran Bingham <kieran.bingham@linaro.org> | ||
10 | * | ||
11 | * This work is licensed under the terms of the GNU GPL version 2. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/fs.h> | ||
16 | #include <linux/mount.h> | ||
17 | #include <linux/radix-tree.h> | ||
18 | |||
19 | /* We need to stringify expanded macros so that they can be parsed */ | ||
20 | |||
21 | #define STRING(x) #x | ||
22 | #define XSTRING(x) STRING(x) | ||
23 | |||
24 | #define LX_VALUE(x) LX_##x = x | ||
25 | #define LX_GDBPARSED(x) LX_##x = gdb.parse_and_eval(XSTRING(x)) | ||
26 | |||
27 | /* | ||
28 | * IS_ENABLED generates (a || b) which is not compatible with python | ||
29 | * We can only switch on configuration items we know are available | ||
30 | * Therefore - IS_BUILTIN() is more appropriate | ||
31 | */ | ||
32 | #define LX_CONFIG(x) LX_##x = IS_BUILTIN(x) | ||
33 | |||
34 | /* The build system will take care of deleting everything above this marker */ | ||
35 | <!-- end-c-headers --> | ||
36 | |||
37 | import gdb | ||
38 | |||
39 | /* linux/fs.h */ | ||
40 | LX_VALUE(MS_RDONLY) | ||
41 | LX_VALUE(MS_SYNCHRONOUS) | ||
42 | LX_VALUE(MS_MANDLOCK) | ||
43 | LX_VALUE(MS_DIRSYNC) | ||
44 | LX_VALUE(MS_NOATIME) | ||
45 | LX_VALUE(MS_NODIRATIME) | ||
46 | |||
47 | /* linux/mount.h */ | ||
48 | LX_VALUE(MNT_NOSUID) | ||
49 | LX_VALUE(MNT_NODEV) | ||
50 | LX_VALUE(MNT_NOEXEC) | ||
51 | LX_VALUE(MNT_NOATIME) | ||
52 | LX_VALUE(MNT_NODIRATIME) | ||
53 | LX_VALUE(MNT_RELATIME) | ||
54 | |||
55 | /* linux/radix-tree.h */ | ||
56 | LX_VALUE(RADIX_TREE_INDIRECT_PTR) | ||
57 | LX_GDBPARSED(RADIX_TREE_HEIGHT_MASK) | ||
58 | LX_GDBPARSED(RADIX_TREE_MAP_SHIFT) | ||
59 | LX_GDBPARSED(RADIX_TREE_MAP_MASK) | ||
diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py index 4297b83fedef..ca11e8df31b6 100644 --- a/scripts/gdb/linux/cpus.py +++ b/scripts/gdb/linux/cpus.py | |||
@@ -97,9 +97,47 @@ def cpu_list(mask_name): | |||
97 | bits >>= 1 | 97 | bits >>= 1 |
98 | bit += 1 | 98 | bit += 1 |
99 | 99 | ||
100 | yield int(cpu) | ||
101 | |||
102 | |||
103 | def each_online_cpu(): | ||
104 | for cpu in cpu_list("__cpu_online_mask"): | ||
105 | yield cpu | ||
106 | |||
107 | |||
108 | def each_present_cpu(): | ||
109 | for cpu in cpu_list("__cpu_present_mask"): | ||
110 | yield cpu | ||
111 | |||
112 | |||
113 | def each_possible_cpu(): | ||
114 | for cpu in cpu_list("__cpu_possible_mask"): | ||
115 | yield cpu | ||
116 | |||
117 | |||
118 | def each_active_cpu(): | ||
119 | for cpu in cpu_list("__cpu_active_mask"): | ||
100 | yield cpu | 120 | yield cpu |
101 | 121 | ||
102 | 122 | ||
123 | class LxCpus(gdb.Command): | ||
124 | """List CPU status arrays | ||
125 | |||
126 | Displays the known state of each CPU based on the kernel masks | ||
127 | and can help identify the state of hotplugged CPUs""" | ||
128 | |||
129 | def __init__(self): | ||
130 | super(LxCpus, self).__init__("lx-cpus", gdb.COMMAND_DATA) | ||
131 | |||
132 | def invoke(self, arg, from_tty): | ||
133 | gdb.write("Possible CPUs : {}\n".format(list(each_possible_cpu()))) | ||
134 | gdb.write("Present CPUs : {}\n".format(list(each_present_cpu()))) | ||
135 | gdb.write("Online CPUs : {}\n".format(list(each_online_cpu()))) | ||
136 | gdb.write("Active CPUs : {}\n".format(list(each_active_cpu()))) | ||
137 | |||
138 | LxCpus() | ||
139 | |||
140 | |||
103 | class PerCpu(gdb.Function): | 141 | class PerCpu(gdb.Function): |
104 | """Return per-cpu variable. | 142 | """Return per-cpu variable. |
105 | 143 | ||
diff --git a/scripts/gdb/linux/dmesg.py b/scripts/gdb/linux/dmesg.py index 927d0d2a3145..f9b92ece7834 100644 --- a/scripts/gdb/linux/dmesg.py +++ b/scripts/gdb/linux/dmesg.py | |||
@@ -33,11 +33,12 @@ class LxDmesg(gdb.Command): | |||
33 | if log_first_idx < log_next_idx: | 33 | if log_first_idx < log_next_idx: |
34 | log_buf_2nd_half = -1 | 34 | log_buf_2nd_half = -1 |
35 | length = log_next_idx - log_first_idx | 35 | length = log_next_idx - log_first_idx |
36 | log_buf = inf.read_memory(start, length) | 36 | log_buf = utils.read_memoryview(inf, start, length).tobytes() |
37 | else: | 37 | else: |
38 | log_buf_2nd_half = log_buf_len - log_first_idx | 38 | log_buf_2nd_half = log_buf_len - log_first_idx |
39 | log_buf = inf.read_memory(start, log_buf_2nd_half) + \ | 39 | a = utils.read_memoryview(inf, start, log_buf_2nd_half) |
40 | inf.read_memory(log_buf_addr, log_next_idx) | 40 | b = utils.read_memoryview(inf, log_buf_addr, log_next_idx) |
41 | log_buf = a.tobytes() + b.tobytes() | ||
41 | 42 | ||
42 | pos = 0 | 43 | pos = 0 |
43 | while pos < log_buf.__len__(): | 44 | while pos < log_buf.__len__(): |
@@ -50,10 +51,10 @@ class LxDmesg(gdb.Command): | |||
50 | continue | 51 | continue |
51 | 52 | ||
52 | text_len = utils.read_u16(log_buf[pos + 10:pos + 12]) | 53 | text_len = utils.read_u16(log_buf[pos + 10:pos + 12]) |
53 | text = log_buf[pos + 16:pos + 16 + text_len] | 54 | text = log_buf[pos + 16:pos + 16 + text_len].decode() |
54 | time_stamp = utils.read_u64(log_buf[pos:pos + 8]) | 55 | time_stamp = utils.read_u64(log_buf[pos:pos + 8]) |
55 | 56 | ||
56 | for line in memoryview(text).tobytes().splitlines(): | 57 | for line in text.splitlines(): |
57 | gdb.write("[{time:12.6f}] {line}\n".format( | 58 | gdb.write("[{time:12.6f}] {line}\n".format( |
58 | time=time_stamp / 1000000000.0, | 59 | time=time_stamp / 1000000000.0, |
59 | line=line)) | 60 | line=line)) |
diff --git a/scripts/gdb/linux/lists.py b/scripts/gdb/linux/lists.py index 3a3775bc162b..2f335fbd86fd 100644 --- a/scripts/gdb/linux/lists.py +++ b/scripts/gdb/linux/lists.py | |||
@@ -18,6 +18,27 @@ from linux import utils | |||
18 | list_head = utils.CachedType("struct list_head") | 18 | list_head = utils.CachedType("struct list_head") |
19 | 19 | ||
20 | 20 | ||
21 | def list_for_each(head): | ||
22 | if head.type == list_head.get_type().pointer(): | ||
23 | head = head.dereference() | ||
24 | elif head.type != list_head.get_type(): | ||
25 | raise gdb.GdbError("Must be struct list_head not {}" | ||
26 | .format(head.type)) | ||
27 | |||
28 | node = head['next'].dereference() | ||
29 | while node.address != head.address: | ||
30 | yield node.address | ||
31 | node = node['next'].dereference() | ||
32 | |||
33 | |||
34 | def list_for_each_entry(head, gdbtype, member): | ||
35 | for node in list_for_each(head): | ||
36 | if node.type != list_head.get_type().pointer(): | ||
37 | raise TypeError("Type {} found. Expected struct list_head *." | ||
38 | .format(node.type)) | ||
39 | yield utils.container_of(node, gdbtype, member) | ||
40 | |||
41 | |||
21 | def list_check(head): | 42 | def list_check(head): |
22 | nb = 0 | 43 | nb = 0 |
23 | if (head.type == list_head.get_type().pointer()): | 44 | if (head.type == list_head.get_type().pointer()): |
diff --git a/scripts/gdb/linux/modules.py b/scripts/gdb/linux/modules.py index 0a35d6dbfb80..441b23239896 100644 --- a/scripts/gdb/linux/modules.py +++ b/scripts/gdb/linux/modules.py | |||
@@ -13,7 +13,7 @@ | |||
13 | 13 | ||
14 | import gdb | 14 | import gdb |
15 | 15 | ||
16 | from linux import cpus, utils | 16 | from linux import cpus, utils, lists |
17 | 17 | ||
18 | 18 | ||
19 | module_type = utils.CachedType("struct module") | 19 | module_type = utils.CachedType("struct module") |
@@ -21,14 +21,14 @@ module_type = utils.CachedType("struct module") | |||
21 | 21 | ||
22 | def module_list(): | 22 | def module_list(): |
23 | global module_type | 23 | global module_type |
24 | modules = utils.gdb_eval_or_none("modules") | ||
25 | if modules is None: | ||
26 | return | ||
27 | |||
24 | module_ptr_type = module_type.get_type().pointer() | 28 | module_ptr_type = module_type.get_type().pointer() |
25 | modules = gdb.parse_and_eval("modules") | ||
26 | entry = modules['next'] | ||
27 | end_of_list = modules.address | ||
28 | 29 | ||
29 | while entry != end_of_list: | 30 | for module in lists.list_for_each_entry(modules, module_ptr_type, "list"): |
30 | yield utils.container_of(entry, module_ptr_type, "list") | 31 | yield module |
31 | entry = entry['next'] | ||
32 | 32 | ||
33 | 33 | ||
34 | def find_module_by_name(name): | 34 | def find_module_by_name(name): |
@@ -78,19 +78,17 @@ class LxLsmod(gdb.Command): | |||
78 | address=str(layout['base']).split()[0], | 78 | address=str(layout['base']).split()[0], |
79 | name=module['name'].string(), | 79 | name=module['name'].string(), |
80 | size=str(layout['size']), | 80 | size=str(layout['size']), |
81 | ref=str(module['refcnt']['counter']))) | 81 | ref=str(module['refcnt']['counter'] - 1))) |
82 | 82 | ||
83 | source_list = module['source_list'] | ||
84 | t = self._module_use_type.get_type().pointer() | 83 | t = self._module_use_type.get_type().pointer() |
85 | entry = source_list['next'] | ||
86 | first = True | 84 | first = True |
87 | while entry != source_list.address: | 85 | sources = module['source_list'] |
88 | use = utils.container_of(entry, t, "source_list") | 86 | for use in lists.list_for_each_entry(sources, t, "source_list"): |
89 | gdb.write("{separator}{name}".format( | 87 | gdb.write("{separator}{name}".format( |
90 | separator=" " if first else ",", | 88 | separator=" " if first else ",", |
91 | name=use['source']['name'].string())) | 89 | name=use['source']['name'].string())) |
92 | first = False | 90 | first = False |
93 | entry = entry['next'] | 91 | |
94 | gdb.write("\n") | 92 | gdb.write("\n") |
95 | 93 | ||
96 | 94 | ||
diff --git a/scripts/gdb/linux/proc.py b/scripts/gdb/linux/proc.py index 6e6709c1830c..38b1f09d1cd9 100644 --- a/scripts/gdb/linux/proc.py +++ b/scripts/gdb/linux/proc.py | |||
@@ -12,6 +12,10 @@ | |||
12 | # | 12 | # |
13 | 13 | ||
14 | import gdb | 14 | import gdb |
15 | from linux import constants | ||
16 | from linux import utils | ||
17 | from linux import tasks | ||
18 | from linux import lists | ||
15 | 19 | ||
16 | 20 | ||
17 | class LxCmdLine(gdb.Command): | 21 | class LxCmdLine(gdb.Command): |
@@ -39,3 +43,155 @@ class LxVersion(gdb.Command): | |||
39 | gdb.write(gdb.parse_and_eval("linux_banner").string()) | 43 | gdb.write(gdb.parse_and_eval("linux_banner").string()) |
40 | 44 | ||
41 | LxVersion() | 45 | LxVersion() |
46 | |||
47 | |||
48 | # Resource Structure Printers | ||
49 | # /proc/iomem | ||
50 | # /proc/ioports | ||
51 | |||
52 | def get_resources(resource, depth): | ||
53 | while resource: | ||
54 | yield resource, depth | ||
55 | |||
56 | child = resource['child'] | ||
57 | if child: | ||
58 | for res, deep in get_resources(child, depth + 1): | ||
59 | yield res, deep | ||
60 | |||
61 | resource = resource['sibling'] | ||
62 | |||
63 | |||
64 | def show_lx_resources(resource_str): | ||
65 | resource = gdb.parse_and_eval(resource_str) | ||
66 | width = 4 if resource['end'] < 0x10000 else 8 | ||
67 | # Iterate straight to the first child | ||
68 | for res, depth in get_resources(resource['child'], 0): | ||
69 | start = int(res['start']) | ||
70 | end = int(res['end']) | ||
71 | gdb.write(" " * depth * 2 + | ||
72 | "{0:0{1}x}-".format(start, width) + | ||
73 | "{0:0{1}x} : ".format(end, width) + | ||
74 | res['name'].string() + "\n") | ||
75 | |||
76 | |||
77 | class LxIOMem(gdb.Command): | ||
78 | """Identify the IO memory resource locations defined by the kernel | ||
79 | |||
80 | Equivalent to cat /proc/iomem on a running target""" | ||
81 | |||
82 | def __init__(self): | ||
83 | super(LxIOMem, self).__init__("lx-iomem", gdb.COMMAND_DATA) | ||
84 | |||
85 | def invoke(self, arg, from_tty): | ||
86 | return show_lx_resources("iomem_resource") | ||
87 | |||
88 | LxIOMem() | ||
89 | |||
90 | |||
91 | class LxIOPorts(gdb.Command): | ||
92 | """Identify the IO port resource locations defined by the kernel | ||
93 | |||
94 | Equivalent to cat /proc/ioports on a running target""" | ||
95 | |||
96 | def __init__(self): | ||
97 | super(LxIOPorts, self).__init__("lx-ioports", gdb.COMMAND_DATA) | ||
98 | |||
99 | def invoke(self, arg, from_tty): | ||
100 | return show_lx_resources("ioport_resource") | ||
101 | |||
102 | LxIOPorts() | ||
103 | |||
104 | |||
105 | # Mount namespace viewer | ||
106 | # /proc/mounts | ||
107 | |||
108 | def info_opts(lst, opt): | ||
109 | opts = "" | ||
110 | for key, string in lst.items(): | ||
111 | if opt & key: | ||
112 | opts += string | ||
113 | return opts | ||
114 | |||
115 | |||
116 | FS_INFO = {constants.LX_MS_SYNCHRONOUS: ",sync", | ||
117 | constants.LX_MS_MANDLOCK: ",mand", | ||
118 | constants.LX_MS_DIRSYNC: ",dirsync", | ||
119 | constants.LX_MS_NOATIME: ",noatime", | ||
120 | constants.LX_MS_NODIRATIME: ",nodiratime"} | ||
121 | |||
122 | MNT_INFO = {constants.LX_MNT_NOSUID: ",nosuid", | ||
123 | constants.LX_MNT_NODEV: ",nodev", | ||
124 | constants.LX_MNT_NOEXEC: ",noexec", | ||
125 | constants.LX_MNT_NOATIME: ",noatime", | ||
126 | constants.LX_MNT_NODIRATIME: ",nodiratime", | ||
127 | constants.LX_MNT_RELATIME: ",relatime"} | ||
128 | |||
129 | mount_type = utils.CachedType("struct mount") | ||
130 | mount_ptr_type = mount_type.get_type().pointer() | ||
131 | |||
132 | |||
133 | class LxMounts(gdb.Command): | ||
134 | """Report the VFS mounts of the current process namespace. | ||
135 | |||
136 | Equivalent to cat /proc/mounts on a running target | ||
137 | An integer value can be supplied to display the mount | ||
138 | values of that process namespace""" | ||
139 | |||
140 | def __init__(self): | ||
141 | super(LxMounts, self).__init__("lx-mounts", gdb.COMMAND_DATA) | ||
142 | |||
143 | # Equivalent to proc_namespace.c:show_vfsmnt | ||
144 | # However, that has the ability to call into s_op functions | ||
145 | # whereas we cannot and must make do with the information we can obtain. | ||
146 | def invoke(self, arg, from_tty): | ||
147 | argv = gdb.string_to_argv(arg) | ||
148 | if len(argv) >= 1: | ||
149 | try: | ||
150 | pid = int(argv[0]) | ||
151 | except: | ||
152 | raise gdb.GdbError("Provide a PID as integer value") | ||
153 | else: | ||
154 | pid = 1 | ||
155 | |||
156 | task = tasks.get_task_by_pid(pid) | ||
157 | if not task: | ||
158 | raise gdb.GdbError("Couldn't find a process with PID {}" | ||
159 | .format(pid)) | ||
160 | |||
161 | namespace = task['nsproxy']['mnt_ns'] | ||
162 | if not namespace: | ||
163 | raise gdb.GdbError("No namespace for current process") | ||
164 | |||
165 | for vfs in lists.list_for_each_entry(namespace['list'], | ||
166 | mount_ptr_type, "mnt_list"): | ||
167 | devname = vfs['mnt_devname'].string() | ||
168 | devname = devname if devname else "none" | ||
169 | |||
170 | pathname = "" | ||
171 | parent = vfs | ||
172 | while True: | ||
173 | mntpoint = parent['mnt_mountpoint'] | ||
174 | pathname = utils.dentry_name(mntpoint) + pathname | ||
175 | if (parent == parent['mnt_parent']): | ||
176 | break | ||
177 | parent = parent['mnt_parent'] | ||
178 | |||
179 | if (pathname == ""): | ||
180 | pathname = "/" | ||
181 | |||
182 | superblock = vfs['mnt']['mnt_sb'] | ||
183 | fstype = superblock['s_type']['name'].string() | ||
184 | s_flags = int(superblock['s_flags']) | ||
185 | m_flags = int(vfs['mnt']['mnt_flags']) | ||
186 | rd = "ro" if (s_flags & constants.LX_MS_RDONLY) else "rw" | ||
187 | |||
188 | gdb.write( | ||
189 | "{} {} {} {}{}{} 0 0\n" | ||
190 | .format(devname, | ||
191 | pathname, | ||
192 | fstype, | ||
193 | rd, | ||
194 | info_opts(FS_INFO, s_flags), | ||
195 | info_opts(MNT_INFO, m_flags))) | ||
196 | |||
197 | LxMounts() | ||
diff --git a/scripts/gdb/linux/radixtree.py b/scripts/gdb/linux/radixtree.py new file mode 100644 index 000000000000..0fdef4e2971a --- /dev/null +++ b/scripts/gdb/linux/radixtree.py | |||
@@ -0,0 +1,97 @@ | |||
1 | # | ||
2 | # gdb helper commands and functions for Linux kernel debugging | ||
3 | # | ||
4 | # Radix Tree Parser | ||
5 | # | ||
6 | # Copyright (c) 2016 Linaro Ltd | ||
7 | # | ||
8 | # Authors: | ||
9 | # Kieran Bingham <kieran.bingham@linaro.org> | ||
10 | # | ||
11 | # This work is licensed under the terms of the GNU GPL version 2. | ||
12 | # | ||
13 | |||
14 | import gdb | ||
15 | |||
16 | from linux import utils | ||
17 | from linux import constants | ||
18 | |||
19 | radix_tree_root_type = utils.CachedType("struct radix_tree_root") | ||
20 | radix_tree_node_type = utils.CachedType("struct radix_tree_node") | ||
21 | |||
22 | |||
23 | def is_indirect_ptr(node): | ||
24 | long_type = utils.get_long_type() | ||
25 | return (node.cast(long_type) & constants.LX_RADIX_TREE_INDIRECT_PTR) | ||
26 | |||
27 | |||
28 | def indirect_to_ptr(node): | ||
29 | long_type = utils.get_long_type() | ||
30 | node_type = node.type | ||
31 | indirect_ptr = node.cast(long_type) & ~constants.LX_RADIX_TREE_INDIRECT_PTR | ||
32 | return indirect_ptr.cast(node_type) | ||
33 | |||
34 | |||
35 | def maxindex(height): | ||
36 | height = height & constants.LX_RADIX_TREE_HEIGHT_MASK | ||
37 | return gdb.parse_and_eval("height_to_maxindex["+str(height)+"]") | ||
38 | |||
39 | |||
40 | def lookup(root, index): | ||
41 | if root.type == radix_tree_root_type.get_type().pointer(): | ||
42 | root = root.dereference() | ||
43 | elif root.type != radix_tree_root_type.get_type(): | ||
44 | raise gdb.GdbError("Must be struct radix_tree_root not {}" | ||
45 | .format(root.type)) | ||
46 | |||
47 | node = root['rnode'] | ||
48 | if node is 0: | ||
49 | return None | ||
50 | |||
51 | if not (is_indirect_ptr(node)): | ||
52 | if (index > 0): | ||
53 | return None | ||
54 | return node | ||
55 | |||
56 | node = indirect_to_ptr(node) | ||
57 | |||
58 | height = node['path'] & constants.LX_RADIX_TREE_HEIGHT_MASK | ||
59 | if (index > maxindex(height)): | ||
60 | return None | ||
61 | |||
62 | shift = (height-1) * constants.LX_RADIX_TREE_MAP_SHIFT | ||
63 | |||
64 | while True: | ||
65 | new_index = (index >> shift) & constants.LX_RADIX_TREE_MAP_MASK | ||
66 | slot = node['slots'][new_index] | ||
67 | |||
68 | node = slot.cast(node.type.pointer()).dereference() | ||
69 | if node is 0: | ||
70 | return None | ||
71 | |||
72 | shift -= constants.LX_RADIX_TREE_MAP_SHIFT | ||
73 | height -= 1 | ||
74 | |||
75 | if (height <= 0): | ||
76 | break | ||
77 | |||
78 | return node | ||
79 | |||
80 | |||
81 | class LxRadixTree(gdb.Function): | ||
82 | """ Lookup and return a node from a RadixTree. | ||
83 | |||
84 | $lx_radix_tree_lookup(root_node [, index]): Return the node at the given index. | ||
85 | If index is omitted, the root node is dereferenced and returned.""" | ||
86 | |||
87 | def __init__(self): | ||
88 | super(LxRadixTree, self).__init__("lx_radix_tree_lookup") | ||
89 | |||
90 | def invoke(self, root, index=0): | ||
91 | result = lookup(root, index) | ||
92 | if result is None: | ||
93 | raise gdb.GdbError("No entry in tree at index {}".format(index)) | ||
94 | |||
95 | return result | ||
96 | |||
97 | LxRadixTree() | ||
diff --git a/scripts/gdb/linux/tasks.py b/scripts/gdb/linux/tasks.py index 862a4ae24d49..1bf949c43b76 100644 --- a/scripts/gdb/linux/tasks.py +++ b/scripts/gdb/linux/tasks.py | |||
@@ -114,3 +114,22 @@ variable.""" | |||
114 | 114 | ||
115 | 115 | ||
116 | LxThreadInfoFunc() | 116 | LxThreadInfoFunc() |
117 | |||
118 | |||
119 | class LxThreadInfoByPidFunc (gdb.Function): | ||
120 | """Calculate Linux thread_info from task variable found by pid | ||
121 | |||
122 | $lx_thread_info_by_pid(PID): Given PID, return the corresponding thread_info | ||
123 | variable.""" | ||
124 | |||
125 | def __init__(self): | ||
126 | super(LxThreadInfoByPidFunc, self).__init__("lx_thread_info_by_pid") | ||
127 | |||
128 | def invoke(self, pid): | ||
129 | task = get_task_by_pid(pid) | ||
130 | if task: | ||
131 | return get_thread_info(task.dereference()) | ||
132 | else: | ||
133 | raise gdb.GdbError("No task of PID " + str(pid)) | ||
134 | |||
135 | LxThreadInfoByPidFunc() | ||
diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py index 0893b326a28b..50805874cfc3 100644 --- a/scripts/gdb/linux/utils.py +++ b/scripts/gdb/linux/utils.py | |||
@@ -87,11 +87,24 @@ def get_target_endianness(): | |||
87 | return target_endianness | 87 | return target_endianness |
88 | 88 | ||
89 | 89 | ||
90 | def read_memoryview(inf, start, length): | ||
91 | return memoryview(inf.read_memory(start, length)) | ||
92 | |||
93 | |||
90 | def read_u16(buffer): | 94 | def read_u16(buffer): |
95 | value = [0, 0] | ||
96 | |||
97 | if type(buffer[0]) is str: | ||
98 | value[0] = ord(buffer[0]) | ||
99 | value[1] = ord(buffer[1]) | ||
100 | else: | ||
101 | value[0] = buffer[0] | ||
102 | value[1] = buffer[1] | ||
103 | |||
91 | if get_target_endianness() == LITTLE_ENDIAN: | 104 | if get_target_endianness() == LITTLE_ENDIAN: |
92 | return ord(buffer[0]) + (ord(buffer[1]) << 8) | 105 | return value[0] + (value[1] << 8) |
93 | else: | 106 | else: |
94 | return ord(buffer[1]) + (ord(buffer[0]) << 8) | 107 | return value[1] + (value[0] << 8) |
95 | 108 | ||
96 | 109 | ||
97 | def read_u32(buffer): | 110 | def read_u32(buffer): |
@@ -154,3 +167,18 @@ def get_gdbserver_type(): | |||
154 | if gdbserver_type is not None and hasattr(gdb, 'events'): | 167 | if gdbserver_type is not None and hasattr(gdb, 'events'): |
155 | gdb.events.exited.connect(exit_handler) | 168 | gdb.events.exited.connect(exit_handler) |
156 | return gdbserver_type | 169 | return gdbserver_type |
170 | |||
171 | |||
172 | def gdb_eval_or_none(expresssion): | ||
173 | try: | ||
174 | return gdb.parse_and_eval(expresssion) | ||
175 | except: | ||
176 | return None | ||
177 | |||
178 | |||
179 | def dentry_name(d): | ||
180 | parent = d['d_parent'] | ||
181 | if parent == d or parent == 0: | ||
182 | return "" | ||
183 | p = dentry_name(d['d_parent']) + "/" | ||
184 | return p + d['d_iname'].string() | ||
diff --git a/scripts/gdb/vmlinux-gdb.py b/scripts/gdb/vmlinux-gdb.py index d5943eca19cd..3a80ad6eecad 100644 --- a/scripts/gdb/vmlinux-gdb.py +++ b/scripts/gdb/vmlinux-gdb.py | |||
@@ -30,3 +30,5 @@ else: | |||
30 | import linux.cpus | 30 | import linux.cpus |
31 | import linux.lists | 31 | import linux.lists |
32 | import linux.proc | 32 | import linux.proc |
33 | import linux.constants | ||
34 | import linux.radixtree | ||
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c index dafaf96e0a34..06121ce524a7 100644 --- a/scripts/genksyms/genksyms.c +++ b/scripts/genksyms/genksyms.c | |||
@@ -873,5 +873,8 @@ int main(int argc, char **argv) | |||
873 | (double)nsyms / (double)HASH_BUCKETS); | 873 | (double)nsyms / (double)HASH_BUCKETS); |
874 | } | 874 | } |
875 | 875 | ||
876 | if (dumpfile) | ||
877 | fclose(dumpfile); | ||
878 | |||
876 | return errors != 0; | 879 | return errors != 0; |
877 | } | 880 | } |
diff --git a/scripts/headers_check.pl b/scripts/headers_check.pl index 62320f93e903..8b2da054cdc3 100755 --- a/scripts/headers_check.pl +++ b/scripts/headers_check.pl | |||
@@ -69,6 +69,10 @@ sub check_declarations | |||
69 | if ($line =~ m/^void seqbuf_dump\(void\);/) { | 69 | if ($line =~ m/^void seqbuf_dump\(void\);/) { |
70 | return; | 70 | return; |
71 | } | 71 | } |
72 | # drm headers are being C++ friendly | ||
73 | if ($line =~ m/^extern "C"/) { | ||
74 | return; | ||
75 | } | ||
72 | if ($line =~ m/^(\s*extern|unsigned|char|short|int|long|void)\b/) { | 76 | if ($line =~ m/^(\s*extern|unsigned|char|short|int|long|void)\b/) { |
73 | printf STDERR "$filename:$lineno: " . | 77 | printf STDERR "$filename:$lineno: " . |
74 | "userspace cannot reference function or " . | 78 | "userspace cannot reference function or " . |
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 638b143ee60f..1f22a186c18c 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c | |||
@@ -63,7 +63,6 @@ static unsigned int table_size, table_cnt; | |||
63 | static int all_symbols = 0; | 63 | static int all_symbols = 0; |
64 | static int absolute_percpu = 0; | 64 | static int absolute_percpu = 0; |
65 | static char symbol_prefix_char = '\0'; | 65 | static char symbol_prefix_char = '\0'; |
66 | static unsigned long long kernel_start_addr = 0; | ||
67 | static int base_relative = 0; | 66 | static int base_relative = 0; |
68 | 67 | ||
69 | int token_profit[0x10000]; | 68 | int token_profit[0x10000]; |
@@ -223,15 +222,13 @@ static int symbol_valid(struct sym_entry *s) | |||
223 | 222 | ||
224 | static char *special_suffixes[] = { | 223 | static char *special_suffixes[] = { |
225 | "_veneer", /* arm */ | 224 | "_veneer", /* arm */ |
225 | "_from_arm", /* arm */ | ||
226 | "_from_thumb", /* arm */ | ||
226 | NULL }; | 227 | NULL }; |
227 | 228 | ||
228 | int i; | 229 | int i; |
229 | char *sym_name = (char *)s->sym + 1; | 230 | char *sym_name = (char *)s->sym + 1; |
230 | 231 | ||
231 | |||
232 | if (s->addr < kernel_start_addr) | ||
233 | return 0; | ||
234 | |||
235 | /* skip prefix char */ | 232 | /* skip prefix char */ |
236 | if (symbol_prefix_char && *sym_name == symbol_prefix_char) | 233 | if (symbol_prefix_char && *sym_name == symbol_prefix_char) |
237 | sym_name++; | 234 | sym_name++; |
@@ -765,9 +762,6 @@ int main(int argc, char **argv) | |||
765 | if ((*p == '"' && *(p+2) == '"') || (*p == '\'' && *(p+2) == '\'')) | 762 | if ((*p == '"' && *(p+2) == '"') || (*p == '\'' && *(p+2) == '\'')) |
766 | p++; | 763 | p++; |
767 | symbol_prefix_char = *p; | 764 | symbol_prefix_char = *p; |
768 | } else if (strncmp(argv[i], "--page-offset=", 14) == 0) { | ||
769 | const char *p = &argv[i][14]; | ||
770 | kernel_start_addr = strtoull(p, NULL, 16); | ||
771 | } else if (strcmp(argv[i], "--base-relative") == 0) | 765 | } else if (strcmp(argv[i], "--base-relative") == 0) |
772 | base_relative = 1; | 766 | base_relative = 1; |
773 | else | 767 | else |
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index dd243d2abd87..297b079ae4d9 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c | |||
@@ -375,7 +375,9 @@ load: | |||
375 | continue; | 375 | continue; |
376 | } else { | 376 | } else { |
377 | if (line[0] != '\r' && line[0] != '\n') | 377 | if (line[0] != '\r' && line[0] != '\n') |
378 | conf_warning("unexpected data"); | 378 | conf_warning("unexpected data: %.*s", |
379 | (int)strcspn(line, "\r\n"), line); | ||
380 | |||
379 | continue; | 381 | continue; |
380 | } | 382 | } |
381 | setsym: | 383 | setsym: |
diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index f3d3fb42b873..b8c7b29affc5 100755 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl | |||
@@ -188,7 +188,7 @@ sub read_kconfig { | |||
188 | $cont = 0; | 188 | $cont = 0; |
189 | 189 | ||
190 | # collect any Kconfig sources | 190 | # collect any Kconfig sources |
191 | if (/^source\s*"(.*)"/) { | 191 | if (/^source\s+"?([^"]+)/) { |
192 | my $kconfig = $1; | 192 | my $kconfig = $1; |
193 | # prevent reading twice. | 193 | # prevent reading twice. |
194 | if (!defined($read_kconfigs{$kconfig})) { | 194 | if (!defined($read_kconfigs{$kconfig})) { |
@@ -237,7 +237,7 @@ sub read_kconfig { | |||
237 | } | 237 | } |
238 | 238 | ||
239 | # configs without prompts must be selected | 239 | # configs without prompts must be selected |
240 | } elsif ($state ne "NONE" && /^\s*tristate\s\S/) { | 240 | } elsif ($state ne "NONE" && /^\s*(tristate\s+\S|prompt\b)/) { |
241 | # note if the config has a prompt | 241 | # note if the config has a prompt |
242 | $prompts{$config} = 1; | 242 | $prompts{$config} = 1; |
243 | 243 | ||
@@ -256,8 +256,8 @@ sub read_kconfig { | |||
256 | 256 | ||
257 | $iflevel-- if ($iflevel); | 257 | $iflevel-- if ($iflevel); |
258 | 258 | ||
259 | # stop on "help" | 259 | # stop on "help" and keywords that end a menu entry |
260 | } elsif (/^\s*help\s*$/) { | 260 | } elsif (/^\s*(---)?help(---)?\s*$/ || /^(comment|choice|menu)\b/) { |
261 | $state = "NONE"; | 261 | $state = "NONE"; |
262 | } | 262 | } |
263 | } | 263 | } |
@@ -454,7 +454,7 @@ sub parse_config_depends | |||
454 | $p =~ s/^[^$valid]*[$valid]+//; | 454 | $p =~ s/^[^$valid]*[$valid]+//; |
455 | 455 | ||
456 | # We only need to process if the depend config is a module | 456 | # We only need to process if the depend config is a module |
457 | if (!defined($orig_configs{$conf}) || !$orig_configs{conf} eq "m") { | 457 | if (!defined($orig_configs{$conf}) || $orig_configs{$conf} eq "y") { |
458 | next; | 458 | next; |
459 | } | 459 | } |
460 | 460 | ||
@@ -610,6 +610,40 @@ foreach my $line (@config_file) { | |||
610 | next; | 610 | next; |
611 | } | 611 | } |
612 | 612 | ||
613 | if (/CONFIG_MODULE_SIG_KEY="(.+)"/) { | ||
614 | my $orig_cert = $1; | ||
615 | my $default_cert = "certs/signing_key.pem"; | ||
616 | |||
617 | # Check that the logic in this script still matches the one in Kconfig | ||
618 | if (!defined($depends{"MODULE_SIG_KEY"}) || | ||
619 | $depends{"MODULE_SIG_KEY"} !~ /"\Q$default_cert\E"/) { | ||
620 | print STDERR "WARNING: MODULE_SIG_KEY assertion failure, ", | ||
621 | "update needed to ", __FILE__, " line ", __LINE__, "\n"; | ||
622 | print; | ||
623 | } elsif ($orig_cert ne $default_cert && ! -f $orig_cert) { | ||
624 | print STDERR "Module signature verification enabled but ", | ||
625 | "module signing key \"$orig_cert\" not found. Resetting ", | ||
626 | "signing key to default value.\n"; | ||
627 | print "CONFIG_MODULE_SIG_KEY=\"$default_cert\"\n"; | ||
628 | } else { | ||
629 | print; | ||
630 | } | ||
631 | next; | ||
632 | } | ||
633 | |||
634 | if (/CONFIG_SYSTEM_TRUSTED_KEYS="(.+)"/) { | ||
635 | my $orig_keys = $1; | ||
636 | |||
637 | if (! -f $orig_keys) { | ||
638 | print STDERR "System keyring enabled but keys \"$orig_keys\" ", | ||
639 | "not found. Resetting keys to default value.\n"; | ||
640 | print "CONFIG_SYSTEM_TRUSTED_KEYS=\"\"\n"; | ||
641 | } else { | ||
642 | print; | ||
643 | } | ||
644 | next; | ||
645 | } | ||
646 | |||
613 | if (/^(CONFIG.*)=(m|y)/) { | 647 | if (/^(CONFIG.*)=(m|y)/) { |
614 | if (defined($configs{$1})) { | 648 | if (defined($configs{$1})) { |
615 | if ($localyesconfig) { | 649 | if ($localyesconfig) { |
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 25cf0c2c0c79..2432298487fb 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c | |||
@@ -209,12 +209,26 @@ static void sym_set_all_changed(void) | |||
209 | static void sym_calc_visibility(struct symbol *sym) | 209 | static void sym_calc_visibility(struct symbol *sym) |
210 | { | 210 | { |
211 | struct property *prop; | 211 | struct property *prop; |
212 | struct symbol *choice_sym = NULL; | ||
212 | tristate tri; | 213 | tristate tri; |
213 | 214 | ||
214 | /* any prompt visible? */ | 215 | /* any prompt visible? */ |
215 | tri = no; | 216 | tri = no; |
217 | |||
218 | if (sym_is_choice_value(sym)) | ||
219 | choice_sym = prop_get_symbol(sym_get_choice_prop(sym)); | ||
220 | |||
216 | for_all_prompts(sym, prop) { | 221 | for_all_prompts(sym, prop) { |
217 | prop->visible.tri = expr_calc_value(prop->visible.expr); | 222 | prop->visible.tri = expr_calc_value(prop->visible.expr); |
223 | /* | ||
224 | * Tristate choice_values with visibility 'mod' are | ||
225 | * not visible if the corresponding choice's value is | ||
226 | * 'yes'. | ||
227 | */ | ||
228 | if (choice_sym && sym->type == S_TRISTATE && | ||
229 | prop->visible.tri == mod && choice_sym->curr.tri == yes) | ||
230 | prop->visible.tri = no; | ||
231 | |||
218 | tri = EXPR_OR(tri, prop->visible.tri); | 232 | tri = EXPR_OR(tri, prop->visible.tri); |
219 | } | 233 | } |
220 | if (tri == mod && (sym->type != S_TRISTATE || modules_val == no)) | 234 | if (tri == mod && (sym->type != S_TRISTATE || modules_val == no)) |
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index c37255bb620d..2fc8fad5195e 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc | |||
@@ -39,41 +39,44 @@ use strict; | |||
39 | # 25/07/2012 - Added support for HTML5 | 39 | # 25/07/2012 - Added support for HTML5 |
40 | # -- Dan Luedtke <mail@danrl.de> | 40 | # -- Dan Luedtke <mail@danrl.de> |
41 | 41 | ||
42 | # | 42 | sub usage { |
43 | # This will read a 'c' file and scan for embedded comments in the | 43 | my $message = <<"EOF"; |
44 | # style of gnome comments (+minor extensions - see below). | 44 | Usage: $0 [OPTION ...] FILE ... |
45 | # | 45 | |
46 | 46 | Read C language source or header FILEs, extract embedded documentation comments, | |
47 | # Note: This only supports 'c'. | 47 | and print formatted documentation to standard output. |
48 | 48 | ||
49 | # usage: | 49 | The documentation comments are identified by "/**" opening comment mark. See |
50 | # kernel-doc [ -docbook | -html | -html5 | -text | -man | -list ] | 50 | Documentation/kernel-doc-nano-HOWTO.txt for the documentation comment syntax. |
51 | # [ -no-doc-sections ] | 51 | |
52 | # [ -function funcname [ -function funcname ...] ] | 52 | Output format selection (mutually exclusive): |
53 | # c file(s)s > outputfile | 53 | -docbook Output DocBook format. |
54 | # or | 54 | -html Output HTML format. |
55 | # [ -nofunction funcname [ -function funcname ...] ] | 55 | -html5 Output HTML5 format. |
56 | # c file(s)s > outputfile | 56 | -list Output symbol list format. This is for use by docproc. |
57 | # | 57 | -man Output troff manual page format. This is the default. |
58 | # Set output format using one of -docbook -html -html5 -text or -man. | 58 | -rst Output reStructuredText format. |
59 | # Default is man. | 59 | -text Output plain text format. |
60 | # The -list format is for internal use by docproc. | 60 | |
61 | # | 61 | Output selection (mutually exclusive): |
62 | # -no-doc-sections | 62 | -function NAME Only output documentation for the given function(s) |
63 | # Do not output DOC: sections | 63 | or DOC: section title(s). All other functions and DOC: |
64 | # | 64 | sections are ignored. May be specified multiple times. |
65 | # -function funcname | 65 | -nofunction NAME Do NOT output documentation for the given function(s); |
66 | # If set, then only generate documentation for the given function(s) or | 66 | only output documentation for the other functions and |
67 | # DOC: section titles. All other functions and DOC: sections are ignored. | 67 | DOC: sections. May be specified multiple times. |
68 | # | 68 | |
69 | # -nofunction funcname | 69 | Output selection modifiers: |
70 | # If set, then only generate documentation for the other function(s)/DOC: | 70 | -no-doc-sections Do not output DOC: sections. |
71 | # sections. Cannot be used together with -function (yes, that's a bug -- | 71 | |
72 | # perl hackers can fix it 8)) | 72 | Other parameters: |
73 | # | 73 | -v Verbose output, more warnings and other information. |
74 | # c files - list of 'c' files to process | 74 | -h Print this help. |
75 | # | 75 | |
76 | # All output goes to stdout, with errors to stderr. | 76 | EOF |
77 | print $message; | ||
78 | exit 1; | ||
79 | } | ||
77 | 80 | ||
78 | # | 81 | # |
79 | # format of comments. | 82 | # format of comments. |
@@ -201,6 +204,8 @@ my $type_param = '\@(\w+)'; | |||
201 | my $type_struct = '\&((struct\s*)*[_\w]+)'; | 204 | my $type_struct = '\&((struct\s*)*[_\w]+)'; |
202 | my $type_struct_xml = '\\&((struct\s*)*[_\w]+)'; | 205 | my $type_struct_xml = '\\&((struct\s*)*[_\w]+)'; |
203 | my $type_env = '(\$\w+)'; | 206 | my $type_env = '(\$\w+)'; |
207 | my $type_enum_full = '\&(enum)\s*([_\w]+)'; | ||
208 | my $type_struct_full = '\&(struct)\s*([_\w]+)'; | ||
204 | 209 | ||
205 | # Output conversion substitutions. | 210 | # Output conversion substitutions. |
206 | # One for each output format | 211 | # One for each output format |
@@ -266,6 +271,17 @@ my @highlights_text = ( | |||
266 | ); | 271 | ); |
267 | my $blankline_text = ""; | 272 | my $blankline_text = ""; |
268 | 273 | ||
274 | # rst-mode | ||
275 | my @highlights_rst = ( | ||
276 | [$type_constant, "``\$1``"], | ||
277 | [$type_func, "\\:c\\:func\\:`\$1`"], | ||
278 | [$type_struct_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"], | ||
279 | [$type_enum_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"], | ||
280 | [$type_struct, "\\:c\\:type\\:`struct \$1 <\$1>`"], | ||
281 | [$type_param, "**\$1**"] | ||
282 | ); | ||
283 | my $blankline_rst = "\n"; | ||
284 | |||
269 | # list mode | 285 | # list mode |
270 | my @highlights_list = ( | 286 | my @highlights_list = ( |
271 | [$type_constant, "\$1"], | 287 | [$type_constant, "\$1"], |
@@ -402,6 +418,10 @@ while ($ARGV[0] =~ m/^-(.*)/) { | |||
402 | $output_mode = "text"; | 418 | $output_mode = "text"; |
403 | @highlights = @highlights_text; | 419 | @highlights = @highlights_text; |
404 | $blankline = $blankline_text; | 420 | $blankline = $blankline_text; |
421 | } elsif ($cmd eq "-rst") { | ||
422 | $output_mode = "rst"; | ||
423 | @highlights = @highlights_rst; | ||
424 | $blankline = $blankline_rst; | ||
405 | } elsif ($cmd eq "-docbook") { | 425 | } elsif ($cmd eq "-docbook") { |
406 | $output_mode = "xml"; | 426 | $output_mode = "xml"; |
407 | @highlights = @highlights_xml; | 427 | @highlights = @highlights_xml; |
@@ -437,17 +457,6 @@ while ($ARGV[0] =~ m/^-(.*)/) { | |||
437 | 457 | ||
438 | # continue execution near EOF; | 458 | # continue execution near EOF; |
439 | 459 | ||
440 | sub usage { | ||
441 | print "Usage: $0 [ -docbook | -html | -html5 | -text | -man | -list ]\n"; | ||
442 | print " [ -no-doc-sections ]\n"; | ||
443 | print " [ -function funcname [ -function funcname ...] ]\n"; | ||
444 | print " [ -nofunction funcname [ -nofunction funcname ...] ]\n"; | ||
445 | print " [ -v ]\n"; | ||
446 | print " c source file(s) > outputfile\n"; | ||
447 | print " -v : verbose output, more warnings & other info listed\n"; | ||
448 | exit 1; | ||
449 | } | ||
450 | |||
451 | # get kernel version from env | 460 | # get kernel version from env |
452 | sub get_kernel_version() { | 461 | sub get_kernel_version() { |
453 | my $version = 'unknown kernel version'; | 462 | my $version = 'unknown kernel version'; |
@@ -1713,6 +1722,208 @@ sub output_blockhead_text(%) { | |||
1713 | } | 1722 | } |
1714 | } | 1723 | } |
1715 | 1724 | ||
1725 | ## | ||
1726 | # output in restructured text | ||
1727 | # | ||
1728 | |||
1729 | # | ||
1730 | # This could use some work; it's used to output the DOC: sections, and | ||
1731 | # starts by putting out the name of the doc section itself, but that tends | ||
1732 | # to duplicate a header already in the template file. | ||
1733 | # | ||
1734 | sub output_blockhead_rst(%) { | ||
1735 | my %args = %{$_[0]}; | ||
1736 | my ($parameter, $section); | ||
1737 | |||
1738 | foreach $section (@{$args{'sectionlist'}}) { | ||
1739 | print "**$section**\n\n"; | ||
1740 | output_highlight_rst($args{'sections'}{$section}); | ||
1741 | print "\n"; | ||
1742 | } | ||
1743 | } | ||
1744 | |||
1745 | sub output_highlight_rst { | ||
1746 | my $contents = join "\n",@_; | ||
1747 | my $line; | ||
1748 | |||
1749 | # undo the evil effects of xml_escape() earlier | ||
1750 | $contents = xml_unescape($contents); | ||
1751 | |||
1752 | eval $dohighlight; | ||
1753 | die $@ if $@; | ||
1754 | |||
1755 | foreach $line (split "\n", $contents) { | ||
1756 | if ($line eq "") { | ||
1757 | print $lineprefix, $blankline; | ||
1758 | } else { | ||
1759 | $line =~ s/\\\\\\/\&/g; | ||
1760 | print $lineprefix, $line; | ||
1761 | } | ||
1762 | print "\n"; | ||
1763 | } | ||
1764 | } | ||
1765 | |||
1766 | sub output_function_rst(%) { | ||
1767 | my %args = %{$_[0]}; | ||
1768 | my ($parameter, $section); | ||
1769 | my $start; | ||
1770 | |||
1771 | print ".. c:function:: "; | ||
1772 | if ($args{'functiontype'} ne "") { | ||
1773 | $start = $args{'functiontype'} . " " . $args{'function'} . " ("; | ||
1774 | } else { | ||
1775 | $start = $args{'function'} . " ("; | ||
1776 | } | ||
1777 | print $start; | ||
1778 | |||
1779 | my $count = 0; | ||
1780 | foreach my $parameter (@{$args{'parameterlist'}}) { | ||
1781 | if ($count ne 0) { | ||
1782 | print ", "; | ||
1783 | } | ||
1784 | $count++; | ||
1785 | $type = $args{'parametertypes'}{$parameter}; | ||
1786 | if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { | ||
1787 | # pointer-to-function | ||
1788 | print $1 . $parameter . ") (" . $2; | ||
1789 | } else { | ||
1790 | print $type . " " . $parameter; | ||
1791 | } | ||
1792 | } | ||
1793 | print ")\n\n " . $args{'purpose'} . "\n\n"; | ||
1794 | |||
1795 | print ":Parameters:\n\n"; | ||
1796 | foreach $parameter (@{$args{'parameterlist'}}) { | ||
1797 | my $parameter_name = $parameter; | ||
1798 | #$parameter_name =~ s/\[.*//; | ||
1799 | $type = $args{'parametertypes'}{$parameter}; | ||
1800 | |||
1801 | if ($type ne "") { | ||
1802 | print " ``$type $parameter``\n"; | ||
1803 | } else { | ||
1804 | print " ``$parameter``\n"; | ||
1805 | } | ||
1806 | if ($args{'parameterdescs'}{$parameter_name} ne $undescribed) { | ||
1807 | my $oldprefix = $lineprefix; | ||
1808 | $lineprefix = " "; | ||
1809 | output_highlight_rst($args{'parameterdescs'}{$parameter_name}); | ||
1810 | $lineprefix = $oldprefix; | ||
1811 | } else { | ||
1812 | print "\n _undescribed_\n"; | ||
1813 | } | ||
1814 | print "\n"; | ||
1815 | } | ||
1816 | output_section_rst(@_); | ||
1817 | } | ||
1818 | |||
1819 | sub output_section_rst(%) { | ||
1820 | my %args = %{$_[0]}; | ||
1821 | my $section; | ||
1822 | my $oldprefix = $lineprefix; | ||
1823 | $lineprefix = " "; | ||
1824 | |||
1825 | foreach $section (@{$args{'sectionlist'}}) { | ||
1826 | print ":$section:\n\n"; | ||
1827 | output_highlight_rst($args{'sections'}{$section}); | ||
1828 | print "\n"; | ||
1829 | } | ||
1830 | print "\n"; | ||
1831 | $lineprefix = $oldprefix; | ||
1832 | } | ||
1833 | |||
1834 | sub output_enum_rst(%) { | ||
1835 | my %args = %{$_[0]}; | ||
1836 | my ($parameter); | ||
1837 | my $count; | ||
1838 | my $name = "enum " . $args{'enum'}; | ||
1839 | |||
1840 | print "\n\n.. c:type:: " . $name . "\n\n"; | ||
1841 | print " " . $args{'purpose'} . "\n\n"; | ||
1842 | |||
1843 | print "..\n\n:Constants:\n\n"; | ||
1844 | my $oldprefix = $lineprefix; | ||
1845 | $lineprefix = " "; | ||
1846 | foreach $parameter (@{$args{'parameterlist'}}) { | ||
1847 | print " `$parameter`\n"; | ||
1848 | if ($args{'parameterdescs'}{$parameter} ne $undescribed) { | ||
1849 | output_highlight_rst($args{'parameterdescs'}{$parameter}); | ||
1850 | } else { | ||
1851 | print " undescribed\n"; | ||
1852 | } | ||
1853 | print "\n"; | ||
1854 | } | ||
1855 | $lineprefix = $oldprefix; | ||
1856 | output_section_rst(@_); | ||
1857 | } | ||
1858 | |||
1859 | sub output_typedef_rst(%) { | ||
1860 | my %args = %{$_[0]}; | ||
1861 | my ($parameter); | ||
1862 | my $count; | ||
1863 | my $name = "typedef " . $args{'typedef'}; | ||
1864 | |||
1865 | ### FIXME: should the name below contain "typedef" or not? | ||
1866 | print "\n\n.. c:type:: " . $name . "\n\n"; | ||
1867 | print " " . $args{'purpose'} . "\n\n"; | ||
1868 | |||
1869 | output_section_rst(@_); | ||
1870 | } | ||
1871 | |||
1872 | sub output_struct_rst(%) { | ||
1873 | my %args = %{$_[0]}; | ||
1874 | my ($parameter); | ||
1875 | my $name = $args{'type'} . " " . $args{'struct'}; | ||
1876 | |||
1877 | print "\n\n.. c:type:: " . $name . "\n\n"; | ||
1878 | print " " . $args{'purpose'} . "\n\n"; | ||
1879 | |||
1880 | print ":Definition:\n\n"; | ||
1881 | print " ::\n\n"; | ||
1882 | print " " . $args{'type'} . " " . $args{'struct'} . " {\n"; | ||
1883 | foreach $parameter (@{$args{'parameterlist'}}) { | ||
1884 | if ($parameter =~ /^#/) { | ||
1885 | print " " . "$parameter\n"; | ||
1886 | next; | ||
1887 | } | ||
1888 | |||
1889 | my $parameter_name = $parameter; | ||
1890 | $parameter_name =~ s/\[.*//; | ||
1891 | |||
1892 | ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; | ||
1893 | $type = $args{'parametertypes'}{$parameter}; | ||
1894 | if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { | ||
1895 | # pointer-to-function | ||
1896 | print " $1 $parameter) ($2);\n"; | ||
1897 | } elsif ($type =~ m/^(.*?)\s*(:.*)/) { | ||
1898 | # bitfield | ||
1899 | print " $1 $parameter$2;\n"; | ||
1900 | } else { | ||
1901 | print " " . $type . " " . $parameter . ";\n"; | ||
1902 | } | ||
1903 | } | ||
1904 | print " };\n\n"; | ||
1905 | |||
1906 | print ":Members:\n\n"; | ||
1907 | foreach $parameter (@{$args{'parameterlist'}}) { | ||
1908 | ($parameter =~ /^#/) && next; | ||
1909 | |||
1910 | my $parameter_name = $parameter; | ||
1911 | $parameter_name =~ s/\[.*//; | ||
1912 | |||
1913 | ($args{'parameterdescs'}{$parameter_name} ne $undescribed) || next; | ||
1914 | $type = $args{'parametertypes'}{$parameter}; | ||
1915 | print " `$type $parameter`" . "\n"; | ||
1916 | my $oldprefix = $lineprefix; | ||
1917 | $lineprefix = " "; | ||
1918 | output_highlight_rst($args{'parameterdescs'}{$parameter_name}); | ||
1919 | $lineprefix = $oldprefix; | ||
1920 | print "\n"; | ||
1921 | } | ||
1922 | print "\n"; | ||
1923 | output_section_rst(@_); | ||
1924 | } | ||
1925 | |||
1926 | |||
1716 | ## list mode output functions | 1927 | ## list mode output functions |
1717 | 1928 | ||
1718 | sub output_function_list(%) { | 1929 | sub output_function_list(%) { |
@@ -2414,6 +2625,18 @@ sub xml_escape($) { | |||
2414 | return $text; | 2625 | return $text; |
2415 | } | 2626 | } |
2416 | 2627 | ||
2628 | # xml_unescape: reverse the effects of xml_escape | ||
2629 | sub xml_unescape($) { | ||
2630 | my $text = shift; | ||
2631 | if (($output_mode eq "text") || ($output_mode eq "man")) { | ||
2632 | return $text; | ||
2633 | } | ||
2634 | $text =~ s/\\\\\\amp;/\&/g; | ||
2635 | $text =~ s/\\\\\\lt;/</g; | ||
2636 | $text =~ s/\\\\\\gt;/>/g; | ||
2637 | return $text; | ||
2638 | } | ||
2639 | |||
2417 | # convert local escape strings to html | 2640 | # convert local escape strings to html |
2418 | # local escape strings look like: '\\\\menmonic:' (that's 4 backslashes) | 2641 | # local escape strings look like: '\\\\menmonic:' (that's 4 backslashes) |
2419 | sub local_unescape($) { | 2642 | sub local_unescape($) { |
diff --git a/scripts/ld-version.sh b/scripts/ld-version.sh index 7bfe9fa1c8dc..d135882e2c40 100755 --- a/scripts/ld-version.sh +++ b/scripts/ld-version.sh | |||
@@ -5,6 +5,6 @@ | |||
5 | gsub(".*version ", ""); | 5 | gsub(".*version ", ""); |
6 | gsub("-.*", ""); | 6 | gsub("-.*", ""); |
7 | split($1,a, "."); | 7 | split($1,a, "."); |
8 | print a[1]*100000000 + a[2]*1000000 + a[3]*10000 + a[4]*100 + a[5]; | 8 | print a[1]*100000000 + a[2]*1000000 + a[3]*10000; |
9 | exit | 9 | exit |
10 | } | 10 | } |
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 49d61ade9425..f0f6d9d75435 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh | |||
@@ -82,10 +82,6 @@ kallsyms() | |||
82 | kallsymopt="${kallsymopt} --all-symbols" | 82 | kallsymopt="${kallsymopt} --all-symbols" |
83 | fi | 83 | fi |
84 | 84 | ||
85 | if [ -n "${CONFIG_ARM}" ] && [ -z "${CONFIG_XIP_KERNEL}" ] && [ -n "${CONFIG_PAGE_OFFSET}" ]; then | ||
86 | kallsymopt="${kallsymopt} --page-offset=$CONFIG_PAGE_OFFSET" | ||
87 | fi | ||
88 | |||
89 | if [ -n "${CONFIG_KALLSYMS_ABSOLUTE_PERCPU}" ]; then | 85 | if [ -n "${CONFIG_KALLSYMS_ABSOLUTE_PERCPU}" ]; then |
90 | kallsymopt="${kallsymopt} --absolute-percpu" | 86 | kallsymopt="${kallsymopt} --absolute-percpu" |
91 | fi | 87 | fi |
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 161dd0d67da8..fec75786f75b 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -371,6 +371,49 @@ static void do_usb_table(void *symval, unsigned long size, | |||
371 | do_usb_entry_multi(symval + i, mod); | 371 | do_usb_entry_multi(symval + i, mod); |
372 | } | 372 | } |
373 | 373 | ||
374 | static void do_of_entry_multi(void *symval, struct module *mod) | ||
375 | { | ||
376 | char alias[500]; | ||
377 | int len; | ||
378 | char *tmp; | ||
379 | |||
380 | DEF_FIELD_ADDR(symval, of_device_id, name); | ||
381 | DEF_FIELD_ADDR(symval, of_device_id, type); | ||
382 | DEF_FIELD_ADDR(symval, of_device_id, compatible); | ||
383 | |||
384 | len = sprintf(alias, "of:N%sT%s", (*name)[0] ? *name : "*", | ||
385 | (*type)[0] ? *type : "*"); | ||
386 | |||
387 | if ((*compatible)[0]) | ||
388 | sprintf(&alias[len], "%sC%s", (*type)[0] ? "*" : "", | ||
389 | *compatible); | ||
390 | |||
391 | /* Replace all whitespace with underscores */ | ||
392 | for (tmp = alias; tmp && *tmp; tmp++) | ||
393 | if (isspace(*tmp)) | ||
394 | *tmp = '_'; | ||
395 | |||
396 | buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"%s\");\n", alias); | ||
397 | strcat(alias, "C"); | ||
398 | add_wildcard(alias); | ||
399 | buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"%s\");\n", alias); | ||
400 | } | ||
401 | |||
402 | static void do_of_table(void *symval, unsigned long size, | ||
403 | struct module *mod) | ||
404 | { | ||
405 | unsigned int i; | ||
406 | const unsigned long id_size = SIZE_of_device_id; | ||
407 | |||
408 | device_id_check(mod->name, "of", size, id_size, symval); | ||
409 | |||
410 | /* Leave last one: it's the terminator. */ | ||
411 | size -= id_size; | ||
412 | |||
413 | for (i = 0; i < size; i += id_size) | ||
414 | do_of_entry_multi(symval + i, mod); | ||
415 | } | ||
416 | |||
374 | /* Looks like: hid:bNvNpN */ | 417 | /* Looks like: hid:bNvNpN */ |
375 | static int do_hid_entry(const char *filename, | 418 | static int do_hid_entry(const char *filename, |
376 | void *symval, char *alias) | 419 | void *symval, char *alias) |
@@ -684,30 +727,6 @@ static int do_pcmcia_entry(const char *filename, | |||
684 | } | 727 | } |
685 | ADD_TO_DEVTABLE("pcmcia", pcmcia_device_id, do_pcmcia_entry); | 728 | ADD_TO_DEVTABLE("pcmcia", pcmcia_device_id, do_pcmcia_entry); |
686 | 729 | ||
687 | static int do_of_entry (const char *filename, void *symval, char *alias) | ||
688 | { | ||
689 | int len; | ||
690 | char *tmp; | ||
691 | DEF_FIELD_ADDR(symval, of_device_id, name); | ||
692 | DEF_FIELD_ADDR(symval, of_device_id, type); | ||
693 | DEF_FIELD_ADDR(symval, of_device_id, compatible); | ||
694 | |||
695 | len = sprintf(alias, "of:N%sT%s", (*name)[0] ? *name : "*", | ||
696 | (*type)[0] ? *type : "*"); | ||
697 | |||
698 | if (compatible[0]) | ||
699 | sprintf(&alias[len], "%sC%s", (*type)[0] ? "*" : "", | ||
700 | *compatible); | ||
701 | |||
702 | /* Replace all whitespace with underscores */ | ||
703 | for (tmp = alias; tmp && *tmp; tmp++) | ||
704 | if (isspace (*tmp)) | ||
705 | *tmp = '_'; | ||
706 | |||
707 | return 1; | ||
708 | } | ||
709 | ADD_TO_DEVTABLE("of", of_device_id, do_of_entry); | ||
710 | |||
711 | static int do_vio_entry(const char *filename, void *symval, | 730 | static int do_vio_entry(const char *filename, void *symval, |
712 | char *alias) | 731 | char *alias) |
713 | { | 732 | { |
@@ -1348,6 +1367,8 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
1348 | /* First handle the "special" cases */ | 1367 | /* First handle the "special" cases */ |
1349 | if (sym_is(name, namelen, "usb")) | 1368 | if (sym_is(name, namelen, "usb")) |
1350 | do_usb_table(symval, sym->st_size, mod); | 1369 | do_usb_table(symval, sym->st_size, mod); |
1370 | if (sym_is(name, namelen, "of")) | ||
1371 | do_of_table(symval, sym->st_size, mod); | ||
1351 | else if (sym_is(name, namelen, "pnp")) | 1372 | else if (sym_is(name, namelen, "pnp")) |
1352 | do_pnp_device_entry(symval, sym->st_size, mod); | 1373 | do_pnp_device_entry(symval, sym->st_size, mod); |
1353 | else if (sym_is(name, namelen, "pnp_card")) | 1374 | else if (sym_is(name, namelen, "pnp_card")) |
diff --git a/scripts/package/Makefile b/scripts/package/Makefile index c2c7389bfbab..71b4a8af9d4d 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile | |||
@@ -52,7 +52,7 @@ rpm-pkg rpm: FORCE | |||
52 | $(call cmd,src_tar,$(KERNELPATH),kernel.spec) | 52 | $(call cmd,src_tar,$(KERNELPATH),kernel.spec) |
53 | $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version | 53 | $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version |
54 | mv -f $(objtree)/.tmp_version $(objtree)/.version | 54 | mv -f $(objtree)/.tmp_version $(objtree)/.version |
55 | rpmbuild --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz | 55 | rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz |
56 | rm $(KERNELPATH).tar.gz kernel.spec | 56 | rm $(KERNELPATH).tar.gz kernel.spec |
57 | 57 | ||
58 | # binrpm-pkg | 58 | # binrpm-pkg |
@@ -63,7 +63,7 @@ binrpm-pkg: FORCE | |||
63 | $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version | 63 | $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version |
64 | mv -f $(objtree)/.tmp_version $(objtree)/.version | 64 | mv -f $(objtree)/.tmp_version $(objtree)/.version |
65 | 65 | ||
66 | rpmbuild --define "_builddir $(objtree)" --target \ | 66 | rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ |
67 | $(UTS_MACHINE) -bb $(objtree)/binkernel.spec | 67 | $(UTS_MACHINE) -bb $(objtree)/binkernel.spec |
68 | rm binkernel.spec | 68 | rm binkernel.spec |
69 | 69 | ||
diff --git a/scripts/package/builddeb b/scripts/package/builddeb index 6c3b038ef40d..86e56fef7473 100755 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb | |||
@@ -322,7 +322,10 @@ fi | |||
322 | 322 | ||
323 | # Build kernel header package | 323 | # Build kernel header package |
324 | (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl) > "$objtree/debian/hdrsrcfiles" | 324 | (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl) > "$objtree/debian/hdrsrcfiles" |
325 | (cd $srctree; find arch/$SRCARCH/include include scripts -type f) >> "$objtree/debian/hdrsrcfiles" | 325 | if grep -q '^CONFIG_STACK_VALIDATION=y' $KCONFIG_CONFIG ; then |
326 | (cd $srctree; find tools/objtool -type f -executable) >> "$objtree/debian/hdrsrcfiles" | ||
327 | fi | ||
328 | (cd $srctree; find arch/*/include include scripts -type f) >> "$objtree/debian/hdrsrcfiles" | ||
326 | (cd $srctree; find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform) >> "$objtree/debian/hdrsrcfiles" | 329 | (cd $srctree; find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform) >> "$objtree/debian/hdrsrcfiles" |
327 | (cd $srctree; find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f) >> "$objtree/debian/hdrsrcfiles" | 330 | (cd $srctree; find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f) >> "$objtree/debian/hdrsrcfiles" |
328 | (cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f) >> "$objtree/debian/hdrobjfiles" | 331 | (cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f) >> "$objtree/debian/hdrobjfiles" |
diff --git a/scripts/package/mkspec b/scripts/package/mkspec index b6de63cb3f23..57673bae5597 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec | |||
@@ -143,6 +143,11 @@ echo "if [ -x /sbin/new-kernel-pkg ]; then" | |||
143 | echo "new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img" | 143 | echo "new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img" |
144 | echo "fi" | 144 | echo "fi" |
145 | echo "" | 145 | echo "" |
146 | echo "%postun" | ||
147 | echo "if [ -x /sbin/update-bootloader ]; then" | ||
148 | echo "/sbin/update-bootloader --remove $KERNELRELEASE" | ||
149 | echo "fi" | ||
150 | echo "" | ||
146 | echo "%files" | 151 | echo "%files" |
147 | echo '%defattr (-, root, root)' | 152 | echo '%defattr (-, root, root)' |
148 | echo "/lib/modules/$KERNELRELEASE" | 153 | echo "/lib/modules/$KERNELRELEASE" |
diff --git a/scripts/spelling.txt b/scripts/spelling.txt index 946caf3bd694..fa79c6d2a5b8 100644 --- a/scripts/spelling.txt +++ b/scripts/spelling.txt | |||
@@ -428,6 +428,7 @@ feautures||features | |||
428 | fetaure||feature | 428 | fetaure||feature |
429 | fetaures||features | 429 | fetaures||features |
430 | fileystem||filesystem | 430 | fileystem||filesystem |
431 | fimware||firmware | ||
431 | finanize||finalize | 432 | finanize||finalize |
432 | findn||find | 433 | findn||find |
433 | finilizes||finalizes | 434 | finilizes||finalizes |