aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2017-11-28 10:06:34 -0500
committerTony Lindgren <tony@atomide.com>2017-11-28 10:06:34 -0500
commit2db57789e6612ce0cf2fcbb577a1c8307b708566 (patch)
treedd9f9e3dffabbf5cb932fcf5055ab329ca940fa0 /scripts
parentf0c96c6d40312b1a76cd36709dc3eb5948c1b97f (diff)
parente9a9bb4e4779ca74cb52a6e2f8acbc0881d3bb18 (diff)
Merge branch 'soc-fixes' into omap-for-v4.15/fixes
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Kbuild.include106
-rwxr-xr-xscripts/Lindent1
-rw-r--r--scripts/Makefile1
-rw-r--r--scripts/Makefile.asm-generic4
-rw-r--r--scripts/Makefile.build41
-rw-r--r--scripts/Makefile.clean1
-rw-r--r--scripts/Makefile.dtbinst7
-rw-r--r--scripts/Makefile.extrawarn1
-rw-r--r--scripts/Makefile.gcc-plugins1
-rw-r--r--scripts/Makefile.headersinst11
-rw-r--r--scripts/Makefile.help3
-rw-r--r--scripts/Makefile.host13
-rw-r--r--scripts/Makefile.kasan1
-rw-r--r--scripts/Makefile.kcov7
-rw-r--r--scripts/Makefile.lib42
-rw-r--r--scripts/Makefile.modbuiltin1
-rw-r--r--scripts/Makefile.modinst1
-rw-r--r--scripts/Makefile.modpost5
-rw-r--r--scripts/Makefile.modsign1
-rw-r--r--scripts/Makefile.ubsan1
-rwxr-xr-xscripts/bloat-o-meter89
-rwxr-xr-xscripts/check_00index.sh1
-rwxr-xr-xscripts/check_extable.sh1
-rwxr-xr-xscripts/checkincludes.pl1
-rwxr-xr-xscripts/checkpatch.pl45
-rwxr-xr-xscripts/checkstack.pl1
-rwxr-xr-xscripts/checksyscalls.sh1
-rwxr-xr-xscripts/checkversion.pl1
-rwxr-xr-xscripts/cleanfile1
-rwxr-xr-xscripts/cleanpatch1
-rwxr-xr-xscripts/coccicheck42
-rw-r--r--scripts/coccinelle/api/check_bq27xxx_data.cocci161
-rw-r--r--scripts/coccinelle/api/d_find_alias.cocci1
-rw-r--r--scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci1
-rw-r--r--scripts/coccinelle/api/drm-get-put.cocci6
-rw-r--r--scripts/coccinelle/api/setup_timer.cocci199
-rw-r--r--scripts/coccinelle/api/simple_open.cocci1
-rw-r--r--scripts/coccinelle/api/vma_pages.cocci1
-rw-r--r--scripts/coccinelle/iterators/list_entry_update.cocci2
-rw-r--r--scripts/coccinelle/misc/boolreturn.cocci1
-rw-r--r--scripts/coccinelle/misc/ifcol.cocci8
-rw-r--r--scripts/coccinelle/misc/irqf_oneshot.cocci1
-rw-r--r--scripts/coccinelle/misc/of_table.cocci1
-rw-r--r--scripts/coccinelle/misc/orplus.cocci43
-rw-r--r--scripts/coccinelle/null/badzero.cocci2
-rwxr-xr-xscripts/config1
-rwxr-xr-xscripts/decode_stacktrace.sh1
-rwxr-xr-xscripts/decodecode1
-rwxr-xr-xscripts/depmod.sh1
-rwxr-xr-xscripts/diffconfig1
-rwxr-xr-xscripts/documentation-file-ref-check15
-rw-r--r--scripts/dtc/Makefile1
-rw-r--r--scripts/dtc/checks.c291
-rw-r--r--scripts/dtc/dtc-lexer.lex.c_shipped10
-rw-r--r--scripts/dtc/dtc-parser.tab.c_shipped430
-rw-r--r--scripts/dtc/dtc-parser.y20
-rw-r--r--scripts/dtc/dtc.c2
-rw-r--r--scripts/dtc/dtc.h3
-rwxr-xr-xscripts/dtc/dtx_diff22
-rw-r--r--scripts/dtc/fdtdump.c1
-rw-r--r--scripts/dtc/libfdt/fdt_addresses.c96
-rw-r--r--scripts/dtc/libfdt/fdt_empty_tree.c1
-rw-r--r--scripts/dtc/libfdt/fdt_overlay.c861
-rw-r--r--scripts/dtc/libfdt/fdt_ro.c4
-rw-r--r--scripts/dtc/libfdt/fdt_rw.c24
-rw-r--r--scripts/dtc/libfdt/fdt_sw.c16
-rw-r--r--scripts/dtc/libfdt/fdt_wip.c4
-rw-r--r--scripts/dtc/libfdt/libfdt.h47
-rw-r--r--scripts/dtc/livetree.c31
-rwxr-xr-xscripts/dtc/update-dtc-source.sh5
-rw-r--r--scripts/dtc/version_gen.h2
-rwxr-xr-xscripts/extract-module-sig.pl1
-rwxr-xr-xscripts/extract-sys-certs.pl1
-rwxr-xr-xscripts/faddr2line6
-rwxr-xr-xscripts/find-unused-docs.sh62
-rwxr-xr-xscripts/gcc-goto.sh1
-rwxr-xr-xscripts/gcc-ld1
-rwxr-xr-xscripts/gcc-plugin.sh1
-rw-r--r--scripts/gcc-plugins/Makefile1
-rw-r--r--scripts/gcc-plugins/gcc-common.h1
-rw-r--r--scripts/gcc-plugins/gcc-generate-gimple-pass.h1
-rw-r--r--scripts/gcc-plugins/gcc-generate-ipa-pass.h1
-rw-r--r--scripts/gcc-plugins/gcc-generate-rtl-pass.h1
-rw-r--r--scripts/gcc-plugins/gcc-generate-simple_ipa-pass.h1
-rw-r--r--scripts/gcc-plugins/gen-random-seed.sh1
-rwxr-xr-xscripts/gcc-version.sh1
-rwxr-xr-xscripts/gcc-x86_32-has-stack-protector.sh1
-rwxr-xr-xscripts/gcc-x86_64-has-stack-protector.sh1
-rw-r--r--scripts/gdb/linux/Makefile1
-rw-r--r--scripts/genksyms/Makefile1
-rwxr-xr-xscripts/get_maintainer.pl211
-rwxr-xr-xscripts/headerdep.pl1
-rwxr-xr-xscripts/headers.sh1
-rwxr-xr-xscripts/headers_check.pl1
-rwxr-xr-xscripts/headers_install.sh3
-rw-r--r--scripts/kallsyms.c2
-rw-r--r--scripts/kconfig/Makefile1
-rwxr-xr-xscripts/kconfig/check.sh1
-rw-r--r--scripts/kconfig/list.h1
-rw-r--r--scripts/kconfig/lkc_proto.h1
-rwxr-xr-xscripts/kconfig/lxdialog/check-lxdialog.sh1
-rw-r--r--scripts/kconfig/symbol.c2
-rwxr-xr-xscripts/kernel-doc44
-rwxr-xr-xscripts/ld-version.sh1
-rwxr-xr-xscripts/leaking_addresses.pl501
-rwxr-xr-xscripts/link-vmlinux.sh16
-rwxr-xr-xscripts/makelst1
-rwxr-xr-xscripts/mkcompile_h8
-rwxr-xr-xscripts/mkmakefile1
-rwxr-xr-xscripts/mkuboot.sh1
-rw-r--r--scripts/mkversion6
-rw-r--r--scripts/mod/Makefile1
-rw-r--r--scripts/mod/devicetable-offsets.c8
-rw-r--r--scripts/mod/file2alias.c25
-rw-r--r--scripts/mod/mk_elfconfig.c1
-rw-r--r--scripts/mod/modpost.c2
-rw-r--r--scripts/mod/modpost.h1
-rw-r--r--scripts/package/Makefile21
-rwxr-xr-xscripts/package/builddeb26
-rwxr-xr-xscripts/package/buildtar1
-rwxr-xr-xscripts/package/mkspec275
-rw-r--r--scripts/parse-maintainers.pl53
-rwxr-xr-xscripts/patch-kernel1
-rwxr-xr-xscripts/profile2linkerlist.pl1
-rwxr-xr-xscripts/prune-kernel1
-rw-r--r--scripts/selinux/Makefile1
-rw-r--r--scripts/selinux/genheaders/Makefile1
-rw-r--r--scripts/selinux/genheaders/genheaders.c1
-rwxr-xr-xscripts/selinux/install_policy.sh1
-rw-r--r--scripts/selinux/mdp/Makefile1
-rwxr-xr-xscripts/setlocalversion1
-rw-r--r--scripts/spelling.txt37
-rwxr-xr-xscripts/stackdelta1
-rwxr-xr-xscripts/stackusage1
-rwxr-xr-xscripts/tracing/ftrace-bisect.sh1
-rwxr-xr-xscripts/ver_linux1
-rw-r--r--scripts/xen-hypercalls.sh1
137 files changed, 3236 insertions, 871 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 9ffd3dda3889..065324a8046f 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -8,6 +8,8 @@ squote := '
8empty := 8empty :=
9space := $(empty) $(empty) 9space := $(empty) $(empty)
10space_escape := _-_SPACE_-_ 10space_escape := _-_SPACE_-_
11right_paren := )
12left_paren := (
11 13
12### 14###
13# Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o 15# Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
@@ -80,6 +82,71 @@ cc-cross-prefix = \
80 echo $(c); \ 82 echo $(c); \
81 fi))) 83 fi)))
82 84
85# Tools for caching Makefile variables that are "expensive" to compute.
86#
87# Here we want to help deal with variables that take a long time to compute
88# by making it easy to store these variables in a cache.
89#
90# The canonical example here is testing for compiler flags. On a simple system
91# each call to the compiler takes 10 ms, but on a system with a compiler that's
92# called through various wrappers it can take upwards of 100 ms. If we have
93# 100 calls to the compiler this can take 1 second (on a simple system) or 10
94# seconds (on a complicated system).
95#
96# The "cache" will be in Makefile syntax and can be directly included.
97# Any time we try to reference a variable that's not in the cache we'll
98# calculate it and store it in the cache for next time.
99
100# Include values from last time
101make-cache := $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/,$(if $(obj),$(obj)/)).cache.mk
102$(make-cache): ;
103-include $(make-cache)
104
105cached-data := $(filter __cached_%, $(.VARIABLES))
106
107# If cache exceeds 1000 lines, shrink it down to 500.
108ifneq ($(word 1000,$(cached-data)),)
109$(shell tail -n 500 $(make-cache) > $(make-cache).tmp; \
110 mv $(make-cache).tmp $(make-cache))
111endif
112
113create-cache-dir := $(if $(KBUILD_SRC),$(if $(cache-data),,1))
114
115# Usage: $(call __sanitize-opt,Hello=Hola$(comma)Goodbye Adios)
116#
117# Convert all '$', ')', '(', '\', '=', ' ', ',', ':' to '_'
118__sanitize-opt = $(subst $$,_,$(subst $(right_paren),_,$(subst $(left_paren),_,$(subst \,_,$(subst =,_,$(subst $(space),_,$(subst $(comma),_,$(subst :,_,$(1)))))))))
119
120# Usage: $(call shell-cached,shell_command)
121# Example: $(call shell-cached,md5sum /usr/bin/gcc)
122#
123# If we've already seen a call to this exact shell command (even in a
124# previous invocation of make!) we'll return the value. If not, we'll
125# compute it and store the result for future runs.
126#
127# This is a bit of voodoo, but basic explanation is that if the variable
128# was undefined then we'll evaluate the shell command and store the result
129# into the variable. We'll then store that value in the cache and finally
130# output the value.
131#
132# NOTE: The $$(2) here isn't actually a parameter to __run-and-store. We
133# happen to know that the caller will have their shell command in $(2) so the
134# result of "call"ing this will produce a reference to that $(2). The reason
135# for this strangeness is to avoid an extra level of eval (and escaping) of
136# $(2).
137define __run-and-store
138ifeq ($(origin $(1)),undefined)
139 $$(eval $(1) := $$(shell $$(2)))
140ifeq ($(create-cache-dir),1)
141 $$(shell mkdir -p $(dir $(make-cache)))
142 $$(eval create-cache-dir :=)
143endif
144 $$(shell echo '$(1) := $$($(1))' >> $(make-cache))
145endif
146endef
147__shell-cached = $(eval $(call __run-and-store,$(1)))$($(1))
148shell-cached = $(call __shell-cached,__cached_$(call __sanitize-opt,$(1)),$(1))
149
83# output directory for tests below 150# output directory for tests below
84TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) 151TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
85 152
@@ -87,30 +154,36 @@ TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
87# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) 154# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
88# Exit code chooses option. "$$TMP" serves as a temporary file and is 155# Exit code chooses option. "$$TMP" serves as a temporary file and is
89# automatically cleaned up. 156# automatically cleaned up.
90try-run = $(shell set -e; \ 157__try-run = set -e; \
91 TMP="$(TMPOUT).$$$$.tmp"; \ 158 TMP="$(TMPOUT).$$$$.tmp"; \
92 TMPO="$(TMPOUT).$$$$.o"; \ 159 TMPO="$(TMPOUT).$$$$.o"; \
93 if ($(1)) >/dev/null 2>&1; \ 160 if ($(1)) >/dev/null 2>&1; \
94 then echo "$(2)"; \ 161 then echo "$(2)"; \
95 else echo "$(3)"; \ 162 else echo "$(3)"; \
96 fi; \ 163 fi; \
97 rm -f "$$TMP" "$$TMPO") 164 rm -f "$$TMP" "$$TMPO"
165
166try-run = $(shell $(__try-run))
167
168# try-run-cached
169# This works like try-run, but the result is cached.
170try-run-cached = $(call shell-cached,$(__try-run))
98 171
99# as-option 172# as-option
100# Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,) 173# Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
101 174
102as-option = $(call try-run,\ 175as-option = $(call try-run-cached,\
103 $(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2)) 176 $(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2))
104 177
105# as-instr 178# as-instr
106# Usage: cflags-y += $(call as-instr,instr,option1,option2) 179# Usage: cflags-y += $(call as-instr,instr,option1,option2)
107 180
108as-instr = $(call try-run,\ 181as-instr = $(call try-run-cached,\
109 printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3)) 182 printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
110 183
111# __cc-option 184# __cc-option
112# Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586) 185# Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
113__cc-option = $(call try-run,\ 186__cc-option = $(call try-run-cached,\
114 $(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4)) 187 $(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4))
115 188
116# Do not attempt to build with gcc plugins during cc-option tests. 189# Do not attempt to build with gcc plugins during cc-option tests.
@@ -130,23 +203,23 @@ hostcc-option = $(call __cc-option, $(HOSTCC),\
130 203
131# cc-option-yn 204# cc-option-yn
132# Usage: flag := $(call cc-option-yn,-march=winchip-c6) 205# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
133cc-option-yn = $(call try-run,\ 206cc-option-yn = $(call try-run-cached,\
134 $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) 207 $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
135 208
136# cc-disable-warning 209# cc-disable-warning
137# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) 210# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
138cc-disable-warning = $(call try-run,\ 211cc-disable-warning = $(call try-run-cached,\
139 $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) 212 $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
140 213
141# cc-name 214# cc-name
142# Expands to either gcc or clang 215# Expands to either gcc or clang
143cc-name = $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc) 216cc-name = $(call shell-cached,$(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc)
144 217
145# cc-version 218# cc-version
146cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) 219cc-version = $(call shell-cached,$(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC))
147 220
148# cc-fullversion 221# cc-fullversion
149cc-fullversion = $(shell $(CONFIG_SHELL) \ 222cc-fullversion = $(call shell-cached,$(CONFIG_SHELL) \
150 $(srctree)/scripts/gcc-version.sh -p $(CC)) 223 $(srctree)/scripts/gcc-version.sh -p $(CC))
151 224
152# cc-ifversion 225# cc-ifversion
@@ -159,22 +232,23 @@ cc-if-fullversion = $(shell [ $(cc-fullversion) $(1) $(2) ] && echo $(3) || echo
159 232
160# cc-ldoption 233# cc-ldoption
161# Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) 234# Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)
162cc-ldoption = $(call try-run,\ 235cc-ldoption = $(call try-run-cached,\
163 $(CC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) 236 $(CC) $(1) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
164 237
165# ld-option 238# ld-option
166# Usage: LDFLAGS += $(call ld-option, -X) 239# Usage: LDFLAGS += $(call ld-option, -X)
167ld-option = $(call try-run,\ 240ld-option = $(call try-run-cached,\
168 $(CC) -x c /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) 241 $(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -x c /dev/null -c -o "$$TMPO"; \
242 $(LD) $(LDFLAGS) $(1) "$$TMPO" -o "$$TMP",$(1),$(2))
169 243
170# ar-option 244# ar-option
171# Usage: KBUILD_ARFLAGS := $(call ar-option,D) 245# Usage: KBUILD_ARFLAGS := $(call ar-option,D)
172# Important: no spaces around options 246# Important: no spaces around options
173ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) 247ar-option = $(call try-run-cached, $(AR) rc$(1) "$$TMP",$(1),$(2))
174 248
175# ld-version 249# ld-version
176# Note this is mainly for HJ Lu's 3 number binutil versions 250# Note this is mainly for HJ Lu's 3 number binutil versions
177ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh) 251ld-version = $(call shell-cached,$(LD) --version | $(srctree)/scripts/ld-version.sh)
178 252
179# ld-ifversion 253# ld-ifversion
180# Usage: $(call ld-ifversion, -ge, 22252, y) 254# Usage: $(call ld-ifversion, -ge, 22252, y)
diff --git a/scripts/Lindent b/scripts/Lindent
index 57b564c24d61..1688c44c2df6 100755
--- a/scripts/Lindent
+++ b/scripts/Lindent
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2 3
3PARAM="-npro -kr -i8 -ts8 -sob -l80 -ss -ncs -cp1" 4PARAM="-npro -kr -i8 -ts8 -sob -l80 -ss -ncs -cp1"
4 5
diff --git a/scripts/Makefile b/scripts/Makefile
index c06f4997d700..25ab143cbe14 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1### 2###
2# scripts contains sources for various helper programs used throughout 3# scripts contains sources for various helper programs used throughout
3# the kernel for the build process. 4# the kernel for the build process.
diff --git a/scripts/Makefile.asm-generic b/scripts/Makefile.asm-generic
index a6c8c1780855..32ad8e93fbe1 100644
--- a/scripts/Makefile.asm-generic
+++ b/scripts/Makefile.asm-generic
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# include/asm-generic contains a lot of files that are used 2# include/asm-generic contains a lot of files that are used
2# verbatim by several architectures. 3# verbatim by several architectures.
3# 4#
@@ -5,6 +6,9 @@
5# and for each file listed in this file with generic-y creates 6# and for each file listed in this file with generic-y creates
6# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/$(src)) 7# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/$(src))
7 8
9PHONY := all
10all:
11
8kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild 12kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild
9-include $(kbuild-file) 13-include $(kbuild-file)
10 14
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 2e3a10e79ca9..cb8997ed0149 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# ========================================================================== 2# ==========================================================================
2# Building 3# Building
3# ========================================================================== 4# ==========================================================================
@@ -64,15 +65,6 @@ ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(h
64include scripts/Makefile.host 65include scripts/Makefile.host
65endif 66endif
66 67
67ifneq ($(KBUILD_SRC),)
68# Create output directory if not already present
69_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
70
71# Create directories for object files if directory does not exist
72# Needed when obj-y := dir/file.o syntax is used
73_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
74endif
75
76ifndef obj 68ifndef obj
77$(warning kbuild: Makefile.build is included improperly) 69$(warning kbuild: Makefile.build is included improperly)
78endif 70endif
@@ -84,7 +76,7 @@ lib-target := $(obj)/lib.a
84obj-y += $(obj)/lib-ksyms.o 76obj-y += $(obj)/lib-ksyms.o
85endif 77endif
86 78
87ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),) 79ifneq ($(strip $(obj-y) $(need-builtin)),)
88builtin-target := $(obj)/built-in.o 80builtin-target := $(obj)/built-in.o
89endif 81endif
90 82
@@ -108,6 +100,10 @@ ifneq ($(KBUILD_CHECKSRC),0)
108 endif 100 endif
109endif 101endif
110 102
103ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),)
104 cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< ;
105endif
106
111# Do section mismatch analysis for each module/built-in.o 107# Do section mismatch analysis for each module/built-in.o
112ifdef CONFIG_DEBUG_SECTION_MISMATCH 108ifdef CONFIG_DEBUG_SECTION_MISMATCH
113 cmd_secanalysis = ; scripts/mod/modpost $@ 109 cmd_secanalysis = ; scripts/mod/modpost $@
@@ -258,13 +254,15 @@ ifneq ($(SKIP_STACK_VALIDATION),1)
258 254
259__objtool_obj := $(objtree)/tools/objtool/objtool 255__objtool_obj := $(objtree)/tools/objtool/objtool
260 256
261objtool_args = $(if $(CONFIG_ORC_UNWINDER),orc generate,check) 257objtool_args = $(if $(CONFIG_UNWINDER_ORC),orc generate,check)
262 258
263ifndef CONFIG_FRAME_POINTER 259ifndef CONFIG_FRAME_POINTER
264objtool_args += --no-fp 260objtool_args += --no-fp
265endif 261endif
266ifdef CONFIG_GCOV_KERNEL 262ifdef CONFIG_GCOV_KERNEL
267objtool_args += --no-unreachable 263objtool_args += --no-unreachable
264else
265objtool_args += $(call cc-ifversion, -lt, 0405, --no-unreachable)
268endif 266endif
269 267
270# 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory 268# 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
@@ -289,6 +287,7 @@ define rule_cc_o_c
289 $(call echo-cmd,checksrc) $(cmd_checksrc) \ 287 $(call echo-cmd,checksrc) $(cmd_checksrc) \
290 $(call cmd_and_fixdep,cc_o_c) \ 288 $(call cmd_and_fixdep,cc_o_c) \
291 $(cmd_modversions_c) \ 289 $(cmd_modversions_c) \
290 $(cmd_checkdoc) \
292 $(call echo-cmd,objtool) $(cmd_objtool) \ 291 $(call echo-cmd,objtool) $(cmd_objtool) \
293 $(call echo-cmd,record_mcount) $(cmd_record_mcount) 292 $(call echo-cmd,record_mcount) $(cmd_record_mcount)
294endef 293endef
@@ -417,7 +416,7 @@ targets += $(extra-y) $(MAKECMDGOALS) $(always)
417# Linker scripts preprocessor (.lds.S -> .lds) 416# Linker scripts preprocessor (.lds.S -> .lds)
418# --------------------------------------------------------------------------- 417# ---------------------------------------------------------------------------
419quiet_cmd_cpp_lds_S = LDS $@ 418quiet_cmd_cpp_lds_S = LDS $@
420 cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -C -U$(ARCH) \ 419 cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -U$(ARCH) \
421 -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $< 420 -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<
422 421
423$(obj)/%.lds: $(src)/%.lds.S FORCE 422$(obj)/%.lds: $(src)/%.lds.S FORCE
@@ -560,14 +559,14 @@ $(multi-used-m): FORCE
560$(call multi_depend, $(multi-used-m), .o, -objs -y -m) 559$(call multi_depend, $(multi-used-m), .o, -objs -y -m)
561 560
562targets += $(multi-used-y) $(multi-used-m) 561targets += $(multi-used-y) $(multi-used-m)
563 562targets := $(filter-out $(PHONY), $(targets))
564 563
565# Descending 564# Descending
566# --------------------------------------------------------------------------- 565# ---------------------------------------------------------------------------
567 566
568PHONY += $(subdir-ym) 567PHONY += $(subdir-ym)
569$(subdir-ym): 568$(subdir-ym):
570 $(Q)$(MAKE) $(build)=$@ 569 $(Q)$(MAKE) $(build)=$@ need-builtin=$(if $(findstring $@,$(subdir-obj-y)),1)
571 570
572# Add FORCE to the prequisites of a target to force it to be always rebuilt. 571# Add FORCE to the prequisites of a target to force it to be always rebuilt.
573# --------------------------------------------------------------------------- 572# ---------------------------------------------------------------------------
@@ -581,13 +580,23 @@ FORCE:
581# optimization, we don't need to read them if the target does not 580# optimization, we don't need to read them if the target does not
582# exist, we will rebuild anyway in that case. 581# exist, we will rebuild anyway in that case.
583 582
584targets := $(wildcard $(sort $(targets))) 583cmd_files := $(wildcard $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd))
585cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
586 584
587ifneq ($(cmd_files),) 585ifneq ($(cmd_files),)
588 include $(cmd_files) 586 include $(cmd_files)
589endif 587endif
590 588
589ifneq ($(KBUILD_SRC),)
590# Create directories for object files if they do not exist
591obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets))))
592# If cmd_files exist, their directories apparently exist. Skip mkdir.
593exist-dirs := $(sort $(patsubst %/,%, $(dir $(cmd_files))))
594obj-dirs := $(strip $(filter-out $(exist-dirs), $(obj-dirs)))
595ifneq ($(obj-dirs),)
596$(shell mkdir -p $(obj-dirs))
597endif
598endif
599
591# Declare the contents of the .PHONY variable as phony. We keep that 600# Declare the contents of the .PHONY variable as phony. We keep that
592# information in a variable se we can use it in if_changed and friends. 601# information in a variable se we can use it in if_changed and friends.
593 602
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index 50616ea25131..808d09f27ad4 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# ========================================================================== 2# ==========================================================================
2# Cleaning up 3# Cleaning up
3# ========================================================================== 4# ==========================================================================
diff --git a/scripts/Makefile.dtbinst b/scripts/Makefile.dtbinst
index 993fb85982df..7301ab5e2e06 100644
--- a/scripts/Makefile.dtbinst
+++ b/scripts/Makefile.dtbinst
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# ========================================================================== 2# ==========================================================================
2# Installing dtb files 3# Installing dtb files
3# 4#
@@ -5,8 +6,6 @@
5# INSTALL_DTBS_PATH directory or the default location: 6# INSTALL_DTBS_PATH directory or the default location:
6# 7#
7# $INSTALL_PATH/dtbs/$KERNELRELEASE 8# $INSTALL_PATH/dtbs/$KERNELRELEASE
8#
9# Traverse through subdirectories listed in $(dts-dirs).
10# ========================================================================== 9# ==========================================================================
11 10
12src := $(obj) 11src := $(obj)
@@ -20,8 +19,8 @@ include include/config/auto.conf
20include scripts/Kbuild.include 19include scripts/Kbuild.include
21include $(src)/Makefile 20include $(src)/Makefile
22 21
23dtbinst-files := $(dtb-y) 22dtbinst-files := $(sort $(dtb-y) $(if $(CONFIG_OF_ALL_DTBS), $(dtb-)))
24dtbinst-dirs := $(dts-dirs) 23dtbinst-dirs := $(subdir-y) $(subdir-m)
25 24
26# Helper targets for Installing DTBs into the boot directory 25# Helper targets for Installing DTBs into the boot directory
27quiet_cmd_dtb_install = INSTALL $< 26quiet_cmd_dtb_install = INSTALL $<
diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index ae8a1357d01d..c6ebf4239e64 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# ========================================================================== 2# ==========================================================================
2# 3#
3# make W=... settings 4# make W=... settings
diff --git a/scripts/Makefile.gcc-plugins b/scripts/Makefile.gcc-plugins
index d1f7b0d6be66..b2a95af7df18 100644
--- a/scripts/Makefile.gcc-plugins
+++ b/scripts/Makefile.gcc-plugins
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1ifdef CONFIG_GCC_PLUGINS 2ifdef CONFIG_GCC_PLUGINS
2 __PLUGINCC := $(call cc-ifversion, -ge, 0408, $(HOSTCXX), $(HOSTCC)) 3 __PLUGINCC := $(call cc-ifversion, -ge, 0408, $(HOSTCXX), $(HOSTCC))
3 PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)") 4 PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)")
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index 343d586e566e..d5e131471131 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# ========================================================================== 2# ==========================================================================
2# Installing headers 3# Installing headers
3# 4#
@@ -26,11 +27,11 @@ subdirs := $(patsubst $(srcdir)/%/,%,\
26# Recursion 27# Recursion
27__headers: $(subdirs) 28__headers: $(subdirs)
28 29
29.PHONY: $(subdirs) 30PHONY += $(subdirs)
30$(subdirs): 31$(subdirs):
31 $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(dst)/$@ 32 $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(dst)/$@
32 33
33# Skip header install/check for include/uapi and arch/$(hdr-arch)/include/uapi. 34# Skip header install/check for include/uapi and arch/$(SRCARCH)/include/uapi.
34# We have only sub-directories there. 35# We have only sub-directories there.
35skip-inst := $(if $(filter %/uapi,$(obj)),1) 36skip-inst := $(if $(filter %/uapi,$(obj)),1)
36 37
@@ -114,9 +115,8 @@ $(check-file): scripts/headers_check.pl $(output-files) FORCE
114 115
115endif 116endif
116 117
117targets := $(wildcard $(sort $(targets)))
118cmd_files := $(wildcard \ 118cmd_files := $(wildcard \
119 $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) 119 $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd))
120 120
121ifneq ($(cmd_files),) 121ifneq ($(cmd_files),)
122 include $(cmd_files) 122 include $(cmd_files)
@@ -124,6 +124,7 @@ endif
124 124
125endif # skip-inst 125endif # skip-inst
126 126
127.PHONY: $(PHONY)
128PHONY += FORCE 127PHONY += FORCE
129FORCE: ; 128FORCE: ;
129
130.PHONY: $(PHONY)
diff --git a/scripts/Makefile.help b/scripts/Makefile.help
deleted file mode 100644
index d03608f5db04..000000000000
--- a/scripts/Makefile.help
+++ /dev/null
@@ -1,3 +0,0 @@
1
2checker-help:
3 @echo ' coccicheck - Check with Coccinelle.'
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 9cfd5c84d76f..e6dc6ae2d7c4 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# ========================================================================== 2# ==========================================================================
2# Building binaries on the host system 3# Building binaries on the host system
3# Binaries are used during the compilation of the kernel, for example 4# Binaries are used during the compilation of the kernel, for example
@@ -48,15 +49,6 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
48host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs)))) 49host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
49host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs)))) 50host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
50 51
51# output directory for programs/.o files
52# hostprogs-y := tools/build may have been specified.
53# Retrieve also directory of .o files from prog-objs or prog-cxxobjs notation
54host-objdirs := $(dir $(__hostprogs) $(host-cobjs) $(host-cxxobjs))
55
56host-objdirs := $(strip $(sort $(filter-out ./,$(host-objdirs))))
57
58
59__hostprogs := $(addprefix $(obj)/,$(__hostprogs))
60host-csingle := $(addprefix $(obj)/,$(host-csingle)) 52host-csingle := $(addprefix $(obj)/,$(host-csingle))
61host-cmulti := $(addprefix $(obj)/,$(host-cmulti)) 53host-cmulti := $(addprefix $(obj)/,$(host-cmulti))
62host-cobjs := $(addprefix $(obj)/,$(host-cobjs)) 54host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
@@ -66,9 +58,6 @@ host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
66host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib)) 58host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
67host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs)) 59host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
68host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs)) 60host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
69host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
70
71obj-dirs += $(host-objdirs)
72 61
73##### 62#####
74# Handle options to gcc. Support building with separate output directory 63# Handle options to gcc. Support building with separate output directory
diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan
index 9576775a86f6..1ce7115aa499 100644
--- a/scripts/Makefile.kasan
+++ b/scripts/Makefile.kasan
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1ifdef CONFIG_KASAN 2ifdef CONFIG_KASAN
2ifdef CONFIG_KASAN_INLINE 3ifdef CONFIG_KASAN_INLINE
3 call_threshold := 10000 4 call_threshold := 10000
diff --git a/scripts/Makefile.kcov b/scripts/Makefile.kcov
new file mode 100644
index 000000000000..5cc72037e423
--- /dev/null
+++ b/scripts/Makefile.kcov
@@ -0,0 +1,7 @@
1ifdef CONFIG_KCOV
2CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,)
3ifeq ($(CONFIG_KCOV_ENABLE_COMPARISONS),y)
4CFLAGS_KCOV += $(call cc-option,-fsanitize-coverage=trace-cmp,)
5endif
6
7endif
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 5e975fee0f5b..1ca4dcd2d500 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -1,27 +1,29 @@
1# SPDX-License-Identifier: GPL-2.0
1# Backward compatibility 2# Backward compatibility
2asflags-y += $(EXTRA_AFLAGS) 3asflags-y += $(EXTRA_AFLAGS)
3ccflags-y += $(EXTRA_CFLAGS) 4ccflags-y += $(EXTRA_CFLAGS)
4cppflags-y += $(EXTRA_CPPFLAGS) 5cppflags-y += $(EXTRA_CPPFLAGS)
5ldflags-y += $(EXTRA_LDFLAGS) 6ldflags-y += $(EXTRA_LDFLAGS)
6 7
7# 8# flags that take effect in current and sub directories
8# flags that take effect in sub directories 9KBUILD_AFLAGS += $(subdir-asflags-y)
9export KBUILD_SUBDIR_ASFLAGS := $(KBUILD_SUBDIR_ASFLAGS) $(subdir-asflags-y) 10KBUILD_CFLAGS += $(subdir-ccflags-y)
10export KBUILD_SUBDIR_CCFLAGS := $(KBUILD_SUBDIR_CCFLAGS) $(subdir-ccflags-y)
11 11
12# Figure out what we need to build from the various variables 12# Figure out what we need to build from the various variables
13# =========================================================================== 13# ===========================================================================
14 14
15# When an object is listed to be built compiled-in and modular, 15# When an object is listed to be built compiled-in and modular,
16# only build the compiled-in version 16# only build the compiled-in version
17
18obj-m := $(filter-out $(obj-y),$(obj-m)) 17obj-m := $(filter-out $(obj-y),$(obj-m))
19 18
20# Libraries are always collected in one lib file. 19# Libraries are always collected in one lib file.
21# Filter out objects already built-in 20# Filter out objects already built-in
22
23lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m))) 21lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))
24 22
23# Determine modorder.
24# Unfortunately, we don't have information about ordering between -y
25# and -m subdirs. Just put -y's first.
26modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko))
25 27
26# Handle objects in subdirs 28# Handle objects in subdirs
27# --------------------------------------------------------------------------- 29# ---------------------------------------------------------------------------
@@ -29,12 +31,6 @@ lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))
29# and add the directory to the list of dirs to descend into: $(subdir-y) 31# and add the directory to the list of dirs to descend into: $(subdir-y)
30# o if we encounter foo/ in $(obj-m), remove it from $(obj-m) 32# o if we encounter foo/ in $(obj-m), remove it from $(obj-m)
31# and add the directory to the list of dirs to descend into: $(subdir-m) 33# and add the directory to the list of dirs to descend into: $(subdir-m)
32
33# Determine modorder.
34# Unfortunately, we don't have information about ordering between -y
35# and -m subdirs. Just put -y's first.
36modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko))
37
38__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) 34__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y)))
39subdir-y += $(__subdir-y) 35subdir-y += $(__subdir-y)
40__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) 36__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m)))
@@ -43,10 +39,9 @@ obj-y := $(patsubst %/, %/built-in.o, $(obj-y))
43obj-m := $(filter-out %/, $(obj-m)) 39obj-m := $(filter-out %/, $(obj-m))
44 40
45# Subdirectories we need to descend into 41# Subdirectories we need to descend into
46
47subdir-ym := $(sort $(subdir-y) $(subdir-m)) 42subdir-ym := $(sort $(subdir-y) $(subdir-m))
48 43
49# if $(foo-objs) exists, foo.o is a composite object 44# if $(foo-objs), $(foo-y), or $(foo-m) exists, foo.o is a composite object
50multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) 45multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
51multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))), $(m)))) 46multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))), $(m))))
52multi-used := $(multi-used-y) $(multi-used-m) 47multi-used := $(multi-used-y) $(multi-used-m)
@@ -56,19 +51,20 @@ single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m)))
56# objects depend on those (obviously) 51# objects depend on those (obviously)
57multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y))) 52multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y)))
58multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y))) 53multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y)))
59multi-objs := $(multi-objs-y) $(multi-objs-m)
60 54
61# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to 55# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to
62# tell kbuild to descend 56# tell kbuild to descend
63subdir-obj-y := $(filter %/built-in.o, $(obj-y)) 57subdir-obj-y := $(filter %/built-in.o, $(obj-y))
64 58
65# $(obj-dirs) is a list of directories that contain object files
66obj-dirs := $(dir $(multi-objs) $(obj-y))
67
68# Replace multi-part objects by their individual parts, look at local dir only 59# Replace multi-part objects by their individual parts, look at local dir only
69real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y) 60real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
70real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m))) 61real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m)))
71 62
63# DTB
64# If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built
65extra-y += $(dtb-y)
66extra-$(CONFIG_OF_ALL_DTBS) += $(dtb-)
67
72# Add subdir path 68# Add subdir path
73 69
74extra-y := $(addprefix $(obj)/,$(extra-y)) 70extra-y := $(addprefix $(obj)/,$(extra-y))
@@ -87,11 +83,9 @@ multi-used-m := $(addprefix $(obj)/,$(multi-used-m))
87multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y)) 83multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y))
88multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m)) 84multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m))
89subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) 85subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
90obj-dirs := $(addprefix $(obj)/,$(obj-dirs))
91 86
92# These flags are needed for modversions and compiling, so we define them here 87# These flags are needed for modversions and compiling, so we define them here
93# already 88# $(modname_flags) defines KBUILD_MODNAME as the name of the module it will
94# $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will
95# end up in (or would, if it gets compiled in) 89# end up in (or would, if it gets compiled in)
96# Note: Files that end up in two or more modules are compiled without the 90# 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 91# KBUILD_MODNAME definition. The reason is that any made-up name would
@@ -101,10 +95,10 @@ basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
101modname_flags = $(if $(filter 1,$(words $(modname))),\ 95modname_flags = $(if $(filter 1,$(words $(modname))),\
102 -DKBUILD_MODNAME=$(call name-fix,$(modname))) 96 -DKBUILD_MODNAME=$(call name-fix,$(modname)))
103 97
104orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \ 98orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \
105 $(ccflags-y) $(CFLAGS_$(basetarget).o) 99 $(ccflags-y) $(CFLAGS_$(basetarget).o)
106_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags)) 100_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
107orig_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(KBUILD_SUBDIR_ASFLAGS) \ 101orig_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) \
108 $(asflags-y) $(AFLAGS_$(basetarget).o) 102 $(asflags-y) $(AFLAGS_$(basetarget).o)
109_a_flags = $(filter-out $(AFLAGS_REMOVE_$(basetarget).o), $(orig_a_flags)) 103_a_flags = $(filter-out $(AFLAGS_REMOVE_$(basetarget).o), $(orig_a_flags))
110_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F)) 104_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F))
diff --git a/scripts/Makefile.modbuiltin b/scripts/Makefile.modbuiltin
index 1adb974e6950..a763b4775d06 100644
--- a/scripts/Makefile.modbuiltin
+++ b/scripts/Makefile.modbuiltin
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# ========================================================================== 2# ==========================================================================
2# Generating modules.builtin 3# Generating modules.builtin
3# ========================================================================== 4# ==========================================================================
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
index 07650eeaaf06..51ca0244fc8a 100644
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# ========================================================================== 2# ==========================================================================
2# Installing modules 3# Installing modules
3# ========================================================================== 4# ==========================================================================
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 16923ba4b5b1..df4174405feb 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# =========================================================================== 2# ===========================================================================
2# Module versions 3# Module versions
3# =========================================================================== 4# ===========================================================================
@@ -97,7 +98,6 @@ vmlinux.o: FORCE
97 $(call cmd,kernel-mod) 98 $(call cmd,kernel-mod)
98 99
99# Declare generated files as targets for modpost 100# Declare generated files as targets for modpost
100$(symverfile): __modpost ;
101$(modules:.ko=.mod.c): __modpost ; 101$(modules:.ko=.mod.c): __modpost ;
102 102
103 103
@@ -143,8 +143,7 @@ FORCE:
143# optimization, we don't need to read them if the target does not 143# optimization, we don't need to read them if the target does not
144# exist, we will rebuild anyway in that case. 144# exist, we will rebuild anyway in that case.
145 145
146targets := $(wildcard $(sort $(targets))) 146cmd_files := $(wildcard $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd))
147cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
148 147
149ifneq ($(cmd_files),) 148ifneq ($(cmd_files),)
150 include $(cmd_files) 149 include $(cmd_files)
diff --git a/scripts/Makefile.modsign b/scripts/Makefile.modsign
index b6ac7084da79..171483bc0538 100644
--- a/scripts/Makefile.modsign
+++ b/scripts/Makefile.modsign
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# ========================================================================== 2# ==========================================================================
2# Signing modules 3# Signing modules
3# ========================================================================== 4# ==========================================================================
diff --git a/scripts/Makefile.ubsan b/scripts/Makefile.ubsan
index 3b1b13818d59..8fd4d44fbcd1 100644
--- a/scripts/Makefile.ubsan
+++ b/scripts/Makefile.ubsan
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1ifdef CONFIG_UBSAN 2ifdef CONFIG_UBSAN
2 CFLAGS_UBSAN += $(call cc-option, -fsanitize=shift) 3 CFLAGS_UBSAN += $(call cc-option, -fsanitize=shift)
3 CFLAGS_UBSAN += $(call cc-option, -fsanitize=integer-divide-by-zero) 4 CFLAGS_UBSAN += $(call cc-option, -fsanitize=integer-divide-by-zero)
diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter
index a27677146410..6f099f915dcf 100755
--- a/scripts/bloat-o-meter
+++ b/scripts/bloat-o-meter
@@ -12,18 +12,22 @@ from signal import signal, SIGPIPE, SIG_DFL
12 12
13signal(SIGPIPE, SIG_DFL) 13signal(SIGPIPE, SIG_DFL)
14 14
15if len(sys.argv) != 3: 15if len(sys.argv) < 3:
16 sys.stderr.write("usage: %s file1 file2\n" % sys.argv[0]) 16 sys.stderr.write("usage: %s [option] file1 file2\n" % sys.argv[0])
17 sys.stderr.write("The options are:\n")
18 sys.stderr.write("-c cateogrize output based on symbole type\n")
19 sys.stderr.write("-d Show delta of Data Section\n")
20 sys.stderr.write("-t Show delta of text Section\n")
17 sys.exit(-1) 21 sys.exit(-1)
18 22
19re_NUMBER = re.compile(r'\.[0-9]+') 23re_NUMBER = re.compile(r'\.[0-9]+')
20 24
21def getsizes(file): 25def getsizes(file, format):
22 sym = {} 26 sym = {}
23 with os.popen("nm --size-sort " + file) as f: 27 with os.popen("nm --size-sort " + file) as f:
24 for line in f: 28 for line in f:
25 size, type, name = line.split() 29 size, type, name = line.split()
26 if type in "tTdDbBrR": 30 if type in format:
27 # strip generated symbols 31 # strip generated symbols
28 if name.startswith("__mod_"): continue 32 if name.startswith("__mod_"): continue
29 if name.startswith("SyS_"): continue 33 if name.startswith("SyS_"): continue
@@ -34,44 +38,61 @@ def getsizes(file):
34 sym[name] = sym.get(name, 0) + int(size, 16) 38 sym[name] = sym.get(name, 0) + int(size, 16)
35 return sym 39 return sym
36 40
37old = getsizes(sys.argv[1]) 41def calc(oldfile, newfile, format):
38new = getsizes(sys.argv[2]) 42 old = getsizes(oldfile, format)
39grow, shrink, add, remove, up, down = 0, 0, 0, 0, 0, 0 43 new = getsizes(newfile, format)
40delta, common = [], {} 44 grow, shrink, add, remove, up, down = 0, 0, 0, 0, 0, 0
41otot, ntot = 0, 0 45 delta, common = [], {}
46 otot, ntot = 0, 0
42 47
43for a in old: 48 for a in old:
44 if a in new: 49 if a in new:
45 common[a] = 1 50 common[a] = 1
46 51
47for name in old: 52 for name in old:
48 otot += old[name] 53 otot += old[name]
49 if name not in common: 54 if name not in common:
50 remove += 1 55 remove += 1
51 down += old[name] 56 down += old[name]
52 delta.append((-old[name], name)) 57 delta.append((-old[name], name))
53 58
54for name in new: 59 for name in new:
55 ntot += new[name] 60 ntot += new[name]
56 if name not in common: 61 if name not in common:
57 add += 1 62 add += 1
58 up += new[name] 63 up += new[name]
59 delta.append((new[name], name)) 64 delta.append((new[name], name))
60 65
61for name in common: 66 for name in common:
62 d = new.get(name, 0) - old.get(name, 0) 67 d = new.get(name, 0) - old.get(name, 0)
63 if d>0: grow, up = grow+1, up+d 68 if d>0: grow, up = grow+1, up+d
64 if d<0: shrink, down = shrink+1, down-d 69 if d<0: shrink, down = shrink+1, down-d
65 delta.append((d, name)) 70 delta.append((d, name))
66 71
67delta.sort() 72 delta.sort()
68delta.reverse() 73 delta.reverse()
74 return grow, shrink, add, remove, up, down, delta, old, new, otot, ntot
69 75
70print("add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \ 76def print_result(symboltype, symbolformat, argc):
71 (add, remove, grow, shrink, up, -down, up-down)) 77 grow, shrink, add, remove, up, down, delta, old, new, otot, ntot = \
72print("%-40s %7s %7s %+7s" % ("function", "old", "new", "delta")) 78 calc(sys.argv[argc - 1], sys.argv[argc], symbolformat)
73for d, n in delta:
74 if d: print("%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d))
75 79
76print("Total: Before=%d, After=%d, chg %+.2f%%" % \ 80 print("add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \
77 (otot, ntot, (ntot - otot)*100.0/otot)) 81 (add, remove, grow, shrink, up, -down, up-down))
82 print("%-40s %7s %7s %+7s" % (symboltype, "old", "new", "delta"))
83 for d, n in delta:
84 if d: print("%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d))
85
86 print("Total: Before=%d, After=%d, chg %+.2f%%" % \
87 (otot, ntot, (ntot - otot)*100.0/otot))
88
89if sys.argv[1] == "-c":
90 print_result("Function", "tT", 3)
91 print_result("Data", "dDbB", 3)
92 print_result("RO Data", "rR", 3)
93elif sys.argv[1] == "-d":
94 print_result("Data", "dDbBrR", 3)
95elif sys.argv[1] == "-t":
96 print_result("Function", "tT", 3)
97else:
98 print_result("Function", "tTdDbBrR", 2)
diff --git a/scripts/check_00index.sh b/scripts/check_00index.sh
index 6ac9527aeddb..aa47f5926c80 100755
--- a/scripts/check_00index.sh
+++ b/scripts/check_00index.sh
@@ -1,4 +1,5 @@
1#!/bin/bash 1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
2 3
3cd Documentation/ 4cd Documentation/
4 5
diff --git a/scripts/check_extable.sh b/scripts/check_extable.sh
index 0fb6b1c97c27..93af93c7b346 100755
--- a/scripts/check_extable.sh
+++ b/scripts/check_extable.sh
@@ -1,4 +1,5 @@
1#! /bin/bash 1#! /bin/bash
2# SPDX-License-Identifier: GPL-2.0
2# (c) 2015, Quentin Casasnovas <quentin.casasnovas@oracle.com> 3# (c) 2015, Quentin Casasnovas <quentin.casasnovas@oracle.com>
3 4
4obj=$1 5obj=$1
diff --git a/scripts/checkincludes.pl b/scripts/checkincludes.pl
index ce9edefd6e0b..b514a956d550 100755
--- a/scripts/checkincludes.pl
+++ b/scripts/checkincludes.pl
@@ -1,4 +1,5 @@
1#!/usr/bin/env perl 1#!/usr/bin/env perl
2# SPDX-License-Identifier: GPL-2.0
2# 3#
3# checkincludes: find/remove files included more than once 4# checkincludes: find/remove files included more than once
4# 5#
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index dd2c262aebbf..95cda3ecc66b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -454,6 +454,7 @@ our $zero_initializer = qr{(?:(?:0[xX])?0+$Int_type?|NULL|false)\b};
454our $logFunctions = qr{(?x: 454our $logFunctions = qr{(?x:
455 printk(?:_ratelimited|_once|_deferred_once|_deferred|)| 455 printk(?:_ratelimited|_once|_deferred_once|_deferred|)|
456 (?:[a-z0-9]+_){1,2}(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)| 456 (?:[a-z0-9]+_){1,2}(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)|
457 TP_printk|
457 WARN(?:_RATELIMIT|_ONCE|)| 458 WARN(?:_RATELIMIT|_ONCE|)|
458 panic| 459 panic|
459 MODULE_[A-Z_]+| 460 MODULE_[A-Z_]+|
@@ -2900,8 +2901,9 @@ sub process {
2900 $line =~ /^\+\s*#\s*define\s+\w+\s+$String$/) { 2901 $line =~ /^\+\s*#\s*define\s+\w+\s+$String$/) {
2901 $msg_type = ""; 2902 $msg_type = "";
2902 2903
2903 # EFI_GUID is another special case 2904 # More special cases
2904 } elsif ($line =~ /^\+.*\bEFI_GUID\s*\(/) { 2905 } elsif ($line =~ /^\+.*\bEFI_GUID\s*\(/ ||
2906 $line =~ /^\+\s*(?:\w+)?\s*DEFINE_PER_CPU/) {
2905 $msg_type = ""; 2907 $msg_type = "";
2906 2908
2907 # Otherwise set the alternate message types 2909 # Otherwise set the alternate message types
@@ -3103,6 +3105,7 @@ sub process {
3103 $line =~ /^\+[a-z_]*init/ || 3105 $line =~ /^\+[a-z_]*init/ ||
3104 $line =~ /^\+\s*(?:static\s+)?[A-Z_]*ATTR/ || 3106 $line =~ /^\+\s*(?:static\s+)?[A-Z_]*ATTR/ ||
3105 $line =~ /^\+\s*DECLARE/ || 3107 $line =~ /^\+\s*DECLARE/ ||
3108 $line =~ /^\+\s*builtin_[\w_]*driver/ ||
3106 $line =~ /^\+\s*__setup/)) { 3109 $line =~ /^\+\s*__setup/)) {
3107 if (CHK("LINE_SPACING", 3110 if (CHK("LINE_SPACING",
3108 "Please use a blank line after function/struct/union/enum declarations\n" . $hereprev) && 3111 "Please use a blank line after function/struct/union/enum declarations\n" . $hereprev) &&
@@ -3182,6 +3185,12 @@ sub process {
3182# check we are in a valid C source file if not then ignore this hunk 3185# check we are in a valid C source file if not then ignore this hunk
3183 next if ($realfile !~ /\.(h|c)$/); 3186 next if ($realfile !~ /\.(h|c)$/);
3184 3187
3188# check for unusual line ending [ or (
3189 if ($line =~ /^\+.*([\[\(])\s*$/) {
3190 CHK("OPEN_ENDED_LINE",
3191 "Lines should not end with a '$1'\n" . $herecurr);
3192 }
3193
3185# check if this appears to be the start function declaration, save the name 3194# check if this appears to be the start function declaration, save the name
3186 if ($sline =~ /^\+\{\s*$/ && 3195 if ($sline =~ /^\+\{\s*$/ &&
3187 $prevline =~ /^\+(?:(?:(?:$Storage|$Inline)\s*)*\s*$Type\s*)?($Ident)\(/) { 3196 $prevline =~ /^\+(?:(?:(?:$Storage|$Inline)\s*)*\s*$Type\s*)?($Ident)\(/) {
@@ -3829,28 +3838,10 @@ sub process {
3829 "Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr); 3838 "Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr);
3830 } 3839 }
3831 3840
3832# printk should use KERN_* levels. Note that follow on printk's on the 3841# printk should use KERN_* levels
3833# same line do not need a level, so we use the current block context 3842 if ($line =~ /\bprintk\s*\(\s*(?!KERN_[A-Z]+\b)/) {
3834# to try and find and validate the current printk. In summary the current 3843 WARN("PRINTK_WITHOUT_KERN_LEVEL",
3835# printk includes all preceding printk's which have no newline on the end. 3844 "printk() should include KERN_<LEVEL> facility level\n" . $herecurr);
3836# we assume the first bad printk is the one to report.
3837 if ($line =~ /\bprintk\((?!KERN_)\s*"/) {
3838 my $ok = 0;
3839 for (my $ln = $linenr - 1; $ln >= $first_line; $ln--) {
3840 #print "CHECK<$lines[$ln - 1]\n";
3841 # we have a preceding printk if it ends
3842 # with "\n" ignore it, else it is to blame
3843 if ($lines[$ln - 1] =~ m{\bprintk\(}) {
3844 if ($rawlines[$ln - 1] !~ m{\\n"}) {
3845 $ok = 1;
3846 }
3847 last;
3848 }
3849 }
3850 if ($ok == 0) {
3851 WARN("PRINTK_WITHOUT_KERN_LEVEL",
3852 "printk() should include KERN_ facility level\n" . $herecurr);
3853 }
3854 } 3845 }
3855 3846
3856 if ($line =~ /\bprintk\s*\(\s*KERN_([A-Z]+)/) { 3847 if ($line =~ /\bprintk\s*\(\s*KERN_([A-Z]+)/) {
@@ -5957,7 +5948,7 @@ sub process {
5957 5948
5958# check for function declarations that have arguments without identifier names 5949# check for function declarations that have arguments without identifier names
5959 if (defined $stat && 5950 if (defined $stat &&
5960 $stat =~ /^.\s*(?:extern\s+)?$Type\s*$Ident\s*\(\s*([^{]+)\s*\)\s*;/s && 5951 $stat =~ /^.\s*(?:extern\s+)?$Type\s*(?:$Ident|\(\s*\*\s*$Ident\s*\))\s*\(\s*([^{]+)\s*\)\s*;/s &&
5961 $1 ne "void") { 5952 $1 ne "void") {
5962 my $args = trim($1); 5953 my $args = trim($1);
5963 while ($args =~ m/\s*($Type\s*(?:$Ident|\(\s*\*\s*$Ident?\s*\)\s*$balanced_parens)?)/g) { 5954 while ($args =~ m/\s*($Type\s*(?:$Ident|\(\s*\*\s*$Ident?\s*\)\s*$balanced_parens)?)/g) {
@@ -6109,7 +6100,7 @@ sub process {
6109 next if ($fline =~ /^.[\s$;]*$/); 6100 next if ($fline =~ /^.[\s$;]*$/);
6110 $has_statement = 1; 6101 $has_statement = 1;
6111 $count++; 6102 $count++;
6112 $has_break = 1 if ($fline =~ /\bswitch\b|\b(?:break\s*;[\s$;]*$|return\b|goto\b|continue\b)/); 6103 $has_break = 1 if ($fline =~ /\bswitch\b|\b(?:break\s*;[\s$;]*$|exit\s*\(\b|return\b|goto\b|continue\b)/);
6113 } 6104 }
6114 if (!$has_break && $has_statement) { 6105 if (!$has_break && $has_statement) {
6115 WARN("MISSING_BREAK", 6106 WARN("MISSING_BREAK",
@@ -6390,7 +6381,7 @@ sub process {
6390 exit(0); 6381 exit(0);
6391 } 6382 }
6392 6383
6393 if (!$is_patch && $file !~ /cover-letter\.patch$/) { 6384 if (!$is_patch && $filename !~ /cover-letter\.patch$/) {
6394 ERROR("NOT_UNIFIED_DIFF", 6385 ERROR("NOT_UNIFIED_DIFF",
6395 "Does not appear to be a unified-diff format patch\n"); 6386 "Does not appear to be a unified-diff format patch\n");
6396 } 6387 }
diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
index 7f4c41717e26..cb993801e4b2 100755
--- a/scripts/checkstack.pl
+++ b/scripts/checkstack.pl
@@ -1,4 +1,5 @@
1#!/usr/bin/env perl 1#!/usr/bin/env perl
2# SPDX-License-Identifier: GPL-2.0
2 3
3# Check the stack usage of functions 4# Check the stack usage of functions
4# 5#
diff --git a/scripts/checksyscalls.sh b/scripts/checksyscalls.sh
index 5a387a264201..ee3dfb5be6cd 100755
--- a/scripts/checksyscalls.sh
+++ b/scripts/checksyscalls.sh
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2# 3#
3# Check if current architecture are missing any function calls compared 4# Check if current architecture are missing any function calls compared
4# to i386. 5# to i386.
diff --git a/scripts/checkversion.pl b/scripts/checkversion.pl
index 8b4f205234b5..f67b125c5269 100755
--- a/scripts/checkversion.pl
+++ b/scripts/checkversion.pl
@@ -1,4 +1,5 @@
1#! /usr/bin/env perl 1#! /usr/bin/env perl
2# SPDX-License-Identifier: GPL-2.0
2# 3#
3# checkversion find uses of LINUX_VERSION_CODE or KERNEL_VERSION 4# checkversion find uses of LINUX_VERSION_CODE or KERNEL_VERSION
4# without including <linux/version.h>, or cases of 5# without including <linux/version.h>, or cases of
diff --git a/scripts/cleanfile b/scripts/cleanfile
index 72e3755327ae..c00c69b9171a 100755
--- a/scripts/cleanfile
+++ b/scripts/cleanfile
@@ -1,4 +1,5 @@
1#!/usr/bin/env perl 1#!/usr/bin/env perl
2# SPDX-License-Identifier: GPL-2.0
2# 3#
3# Clean a text file -- or directory of text files -- of stealth whitespace. 4# Clean a text file -- or directory of text files -- of stealth whitespace.
4# WARNING: this can be a highly destructive operation. Use with caution. 5# WARNING: this can be a highly destructive operation. Use with caution.
diff --git a/scripts/cleanpatch b/scripts/cleanpatch
index 3e5a2303dc0e..9f1755271516 100755
--- a/scripts/cleanpatch
+++ b/scripts/cleanpatch
@@ -1,4 +1,5 @@
1#!/usr/bin/env perl 1#!/usr/bin/env perl
2# SPDX-License-Identifier: GPL-2.0
2# 3#
3# Clean a patch file -- or directory of patch files -- of stealth whitespace. 4# Clean a patch file -- or directory of patch files -- of stealth whitespace.
4# WARNING: this can be a highly destructive operation. Use with caution. 5# WARNING: this can be a highly destructive operation. Use with caution.
diff --git a/scripts/coccicheck b/scripts/coccicheck
index ec487b8e7051..ecfac64b39fe 100755
--- a/scripts/coccicheck
+++ b/scripts/coccicheck
@@ -1,4 +1,5 @@
1#!/bin/bash 1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
2# Linux kernel coccicheck 3# Linux kernel coccicheck
3# 4#
4# Read Documentation/dev-tools/coccinelle.rst 5# Read Documentation/dev-tools/coccinelle.rst
@@ -29,12 +30,6 @@ else
29 VERBOSE=0 30 VERBOSE=0
30fi 31fi
31 32
32if [ -z "$J" ]; then
33 NPROC=$(getconf _NPROCESSORS_ONLN)
34else
35 NPROC="$J"
36fi
37
38FLAGS="--very-quiet" 33FLAGS="--very-quiet"
39 34
40# You can use SPFLAGS to append extra arguments to coccicheck or override any 35# You can use SPFLAGS to append extra arguments to coccicheck or override any
@@ -69,6 +64,9 @@ if [ "$C" = "1" -o "$C" = "2" ]; then
69 # Take only the last argument, which is the C file to test 64 # Take only the last argument, which is the C file to test
70 shift $(( $# - 1 )) 65 shift $(( $# - 1 ))
71 OPTIONS="$COCCIINCLUDE $1" 66 OPTIONS="$COCCIINCLUDE $1"
67
68 # No need to parallelize Coccinelle since this mode takes one input file.
69 NPROC=1
72else 70else
73 ONLINE=0 71 ONLINE=0
74 if [ "$KBUILD_EXTMOD" = "" ] ; then 72 if [ "$KBUILD_EXTMOD" = "" ] ; then
@@ -76,6 +74,12 @@ else
76 else 74 else
77 OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE" 75 OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
78 fi 76 fi
77
78 if [ -z "$J" ]; then
79 NPROC=$(getconf _NPROCESSORS_ONLN)
80 else
81 NPROC="$J"
82 fi
79fi 83fi
80 84
81if [ "$KBUILD_EXTMOD" != "" ] ; then 85if [ "$KBUILD_EXTMOD" != "" ] ; then
@@ -122,15 +126,8 @@ run_cmd_parmap() {
122 if [ $VERBOSE -ne 0 ] ; then 126 if [ $VERBOSE -ne 0 ] ; then
123 echo "Running ($NPROC in parallel): $@" 127 echo "Running ($NPROC in parallel): $@"
124 fi 128 fi
125 if [ "$DEBUG_FILE" != "/dev/null" -a "$DEBUG_FILE" != "" ]; then 129 echo $@ >>$DEBUG_FILE
126 if [ -f $DEBUG_FILE ]; then 130 $@ 2>>$DEBUG_FILE
127 echo "Debug file $DEBUG_FILE exists, bailing"
128 exit
129 fi
130 else
131 DEBUG_FILE="/dev/null"
132 fi
133 $@ 2>$DEBUG_FILE
134 if [[ $? -ne 0 ]]; then 131 if [[ $? -ne 0 ]]; then
135 echo "coccicheck failed" 132 echo "coccicheck failed"
136 exit $? 133 exit $?
@@ -175,8 +172,8 @@ OPTIONS="$OPTIONS $SPFLAGS"
175coccinelle () { 172coccinelle () {
176 COCCI="$1" 173 COCCI="$1"
177 174
178 OPT=`grep "Option" $COCCI | cut -d':' -f2` 175 OPT=`grep "Options:" $COCCI | cut -d':' -f2`
179 REQ=`grep "Requires" $COCCI | cut -d':' -f2 | sed "s| ||"` 176 REQ=`grep "Requires:" $COCCI | cut -d':' -f2 | sed "s| ||"`
180 REQ_NUM=$(echo $REQ | ${DIR}/scripts/ld-version.sh) 177 REQ_NUM=$(echo $REQ | ${DIR}/scripts/ld-version.sh)
181 if [ "$REQ_NUM" != "0" ] ; then 178 if [ "$REQ_NUM" != "0" ] ; then
182 if [ "$SPATCH_VERSION_NUM" -lt "$REQ_NUM" ] ; then 179 if [ "$SPATCH_VERSION_NUM" -lt "$REQ_NUM" ] ; then
@@ -193,7 +190,7 @@ coccinelle () {
193 190
194 if [ $VERBOSE -ne 0 -a $ONLINE -eq 0 ] ; then 191 if [ $VERBOSE -ne 0 -a $ONLINE -eq 0 ] ; then
195 192
196 FILE=`echo $COCCI | sed "s|$srctree/||"` 193 FILE=${COCCI#$srctree/}
197 194
198 echo "Processing `basename $COCCI`" 195 echo "Processing `basename $COCCI`"
199 echo "with option(s) \"$OPT\"" 196 echo "with option(s) \"$OPT\""
@@ -246,6 +243,15 @@ coccinelle () {
246 243
247} 244}
248 245
246if [ "$DEBUG_FILE" != "/dev/null" -a "$DEBUG_FILE" != "" ]; then
247 if [ -f $DEBUG_FILE ]; then
248 echo "Debug file $DEBUG_FILE exists, bailing"
249 exit
250 fi
251else
252 DEBUG_FILE="/dev/null"
253fi
254
249if [ "$COCCI" = "" ] ; then 255if [ "$COCCI" = "" ] ; then
250 for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do 256 for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do
251 coccinelle $f 257 coccinelle $f
diff --git a/scripts/coccinelle/api/check_bq27xxx_data.cocci b/scripts/coccinelle/api/check_bq27xxx_data.cocci
new file mode 100644
index 000000000000..9212b85169d2
--- /dev/null
+++ b/scripts/coccinelle/api/check_bq27xxx_data.cocci
@@ -0,0 +1,161 @@
1/// Detect BQ27XXX_DATA structures with identical registers, dm registers or
2/// properties.
3//# Doesn't unfold macros used in register or property fields.
4//# Requires OCaml scripting
5///
6// Confidence: High
7// Copyright: (C) 2017 Julia Lawall, Inria/LIP6, GPLv2.
8// URL: http://coccinelle.lip6.fr/
9// Requires: 1.0.7
10// Keywords: BQ27XXX_DATA
11
12virtual report
13
14@initialize:ocaml@
15@@
16
17let print_report p msg =
18 let p = List.hd p in
19 Printf.printf "%s:%d:%d-%d: %s" p.file p.line p.col p.col_end msg
20
21@str depends on report@
22type t;
23identifier i,i1,i2;
24expression e1,e2;
25@@
26
27t i[] = {
28 ...,
29 [e1] = BQ27XXX_DATA(i1,...),
30 ...,
31 [e2] = BQ27XXX_DATA(i2,...),
32 ...,
33};
34
35@script:ocaml tocheck@
36i1 << str.i1;
37i2 << str.i2;
38i1regs; i2regs;
39i1dmregs; i2dmregs;
40i1props; i2props;
41@@
42
43if not(i1 = i2)
44then
45 begin
46 i1regs := make_ident (i1 ^ "_regs");
47 i2regs := make_ident (i2 ^ "_regs");
48 i1dmregs := make_ident (i1 ^ "_dm_regs");
49 i2dmregs := make_ident (i2 ^ "_dm_regs");
50 i1props := make_ident (i1 ^ "_props");
51 i2props := make_ident (i2 ^ "_props")
52 end
53
54(* ---------------------------------------------------------------- *)
55
56@getregs1@
57typedef u8;
58identifier tocheck.i1regs;
59initializer list i1regs_vals;
60position p1;
61@@
62
63u8 i1regs@p1[...] = { i1regs_vals, };
64
65@getregs2@
66identifier tocheck.i2regs;
67initializer list i2regs_vals;
68position p2;
69@@
70
71u8 i2regs@p2[...] = { i2regs_vals, };
72
73@script:ocaml@
74(_,i1regs_vals) << getregs1.i1regs_vals;
75(_,i2regs_vals) << getregs2.i2regs_vals;
76i1regs << tocheck.i1regs;
77i2regs << tocheck.i2regs;
78p1 << getregs1.p1;
79p2 << getregs2.p2;
80@@
81
82if i1regs < i2regs &&
83 List.sort compare i1regs_vals = List.sort compare i2regs_vals
84then
85 let msg =
86 Printf.sprintf
87 "WARNING %s and %s (line %d) are identical\n"
88 i1regs i2regs (List.hd p2).line in
89 print_report p1 msg
90
91(* ---------------------------------------------------------------- *)
92
93@getdmregs1@
94identifier tocheck.i1dmregs;
95initializer list i1dmregs_vals;
96position p1;
97@@
98
99struct bq27xxx_dm_reg i1dmregs@p1[] = { i1dmregs_vals, };
100
101@getdmregs2@
102identifier tocheck.i2dmregs;
103initializer list i2dmregs_vals;
104position p2;
105@@
106
107struct bq27xxx_dm_reg i2dmregs@p2[] = { i2dmregs_vals, };
108
109@script:ocaml@
110(_,i1dmregs_vals) << getdmregs1.i1dmregs_vals;
111(_,i2dmregs_vals) << getdmregs2.i2dmregs_vals;
112i1dmregs << tocheck.i1dmregs;
113i2dmregs << tocheck.i2dmregs;
114p1 << getdmregs1.p1;
115p2 << getdmregs2.p2;
116@@
117
118if i1dmregs < i2dmregs &&
119 List.sort compare i1dmregs_vals = List.sort compare i2dmregs_vals
120then
121 let msg =
122 Printf.sprintf
123 "WARNING %s and %s (line %d) are identical\n"
124 i1dmregs i2dmregs (List.hd p2).line in
125 print_report p1 msg
126
127(* ---------------------------------------------------------------- *)
128
129@getprops1@
130identifier tocheck.i1props;
131initializer list[n1] i1props_vals;
132position p1;
133@@
134
135enum power_supply_property i1props@p1[] = { i1props_vals, };
136
137@getprops2@
138identifier tocheck.i2props;
139initializer list[n2] i2props_vals;
140position p2;
141@@
142
143enum power_supply_property i2props@p2[] = { i2props_vals, };
144
145@script:ocaml@
146(_,i1props_vals) << getprops1.i1props_vals;
147(_,i2props_vals) << getprops2.i2props_vals;
148i1props << tocheck.i1props;
149i2props << tocheck.i2props;
150p1 << getprops1.p1;
151p2 << getprops2.p2;
152@@
153
154if i1props < i2props &&
155 List.sort compare i1props_vals = List.sort compare i2props_vals
156then
157 let msg =
158 Printf.sprintf
159 "WARNING %s and %s (line %d) are identical\n"
160 i1props i2props (List.hd p2).line in
161 print_report p1 msg
diff --git a/scripts/coccinelle/api/d_find_alias.cocci b/scripts/coccinelle/api/d_find_alias.cocci
index 9594c9f7eb8d..47e050166f20 100644
--- a/scripts/coccinelle/api/d_find_alias.cocci
+++ b/scripts/coccinelle/api/d_find_alias.cocci
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/// Make sure calls to d_find_alias() have a corresponding call to dput(). 2/// Make sure calls to d_find_alias() have a corresponding call to dput().
2// 3//
3// Keywords: d_find_alias, dput 4// Keywords: d_find_alias, dput
diff --git a/scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci b/scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci
index 85cf5408d378..7c312310547c 100644
--- a/scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci
+++ b/scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/// Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE 2/// Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE
2/// for debugfs files. 3/// for debugfs files.
3/// 4///
diff --git a/scripts/coccinelle/api/drm-get-put.cocci b/scripts/coccinelle/api/drm-get-put.cocci
index 0c7a9265c07e..91fceb8f1fa2 100644
--- a/scripts/coccinelle/api/drm-get-put.cocci
+++ b/scripts/coccinelle/api/drm-get-put.cocci
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/// 2///
2/// Use drm_*_get() and drm_*_put() helpers instead of drm_*_reference() and 3/// Use drm_*_get() and drm_*_put() helpers instead of drm_*_reference() and
3/// drm_*_unreference() helpers. 4/// drm_*_unreference() helpers.
@@ -50,6 +51,9 @@ expression object;
50| 51|
51- drm_property_unreference_blob(object) 52- drm_property_unreference_blob(object)
52+ drm_property_blob_put(object) 53+ drm_property_blob_put(object)
54|
55- drm_dev_unref(object)
56+ drm_dev_put(object)
53) 57)
54 58
55@r depends on report@ 59@r depends on report@
@@ -81,6 +85,8 @@ drm_gem_object_unreference_unlocked(object)
81drm_property_unreference_blob@p(object) 85drm_property_unreference_blob@p(object)
82| 86|
83drm_property_reference_blob@p(object) 87drm_property_reference_blob@p(object)
88|
89drm_dev_unref@p(object)
84) 90)
85 91
86@script:python depends on report@ 92@script:python depends on report@
diff --git a/scripts/coccinelle/api/setup_timer.cocci b/scripts/coccinelle/api/setup_timer.cocci
deleted file mode 100644
index eb6bd9e4ab1a..000000000000
--- a/scripts/coccinelle/api/setup_timer.cocci
+++ /dev/null
@@ -1,199 +0,0 @@
1/// Use setup_timer function instead of initializing timer with the function
2/// and data fields
3// Confidence: High
4// Copyright: (C) 2016 Vaishali Thakkar, Oracle. GPLv2
5// Options: --no-includes --include-headers
6// Keywords: init_timer, setup_timer
7
8virtual patch
9virtual context
10virtual org
11virtual report
12
13@match_immediate_function_data_after_init_timer
14depends on patch && !context && !org && !report@
15expression e, func, da;
16@@
17
18-init_timer (&e);
19+setup_timer (&e, func, da);
20
21(
22-e.function = func;
23-e.data = da;
24|
25-e.data = da;
26-e.function = func;
27)
28
29@match_function_and_data_after_init_timer
30depends on patch && !context && !org && !report@
31expression e1, e2, e3, e4, e5, a, b;
32@@
33
34-init_timer (&e1);
35+setup_timer (&e1, a, b);
36
37... when != a = e2
38 when != b = e3
39(
40-e1.function = a;
41... when != b = e4
42-e1.data = b;
43|
44-e1.data = b;
45... when != a = e5
46-e1.function = a;
47)
48
49@r1 exists@
50identifier f;
51position p;
52@@
53
54f(...) { ... when any
55 init_timer@p(...)
56 ... when any
57}
58
59@r2 exists@
60identifier g != r1.f;
61struct timer_list t;
62expression e8;
63@@
64
65g(...) { ... when any
66 t.data = e8
67 ... when any
68}
69
70// It is dangerous to use setup_timer if data field is initialized
71// in another function.
72
73@script:python depends on r2@
74p << r1.p;
75@@
76
77cocci.include_match(False)
78
79@r3 depends on patch && !context && !org && !report@
80expression e6, e7, c;
81position r1.p;
82@@
83
84-init_timer@p (&e6);
85+setup_timer (&e6, c, 0UL);
86... when != c = e7
87-e6.function = c;
88
89// ----------------------------------------------------------------------------
90
91@match_immediate_function_data_after_init_timer_context
92depends on !patch && (context || org || report)@
93expression da, e, func;
94position j0, j1, j2;
95@@
96
97* init_timer@j0 (&e);
98(
99* e@j1.function = func;
100* e@j2.data = da;
101|
102* e@j1.data = da;
103* e@j2.function = func;
104)
105
106@match_function_and_data_after_init_timer_context
107depends on !patch &&
108!match_immediate_function_data_after_init_timer_context &&
109 (context || org || report)@
110expression a, b, e1, e2, e3, e4, e5;
111position j0, j1, j2;
112@@
113
114* init_timer@j0 (&e1);
115... when != a = e2
116 when != b = e3
117(
118* e1@j1.function = a;
119... when != b = e4
120* e1@j2.data = b;
121|
122* e1@j1.data = b;
123... when != a = e5
124* e1@j2.function = a;
125)
126
127@r3_context depends on !patch &&
128!match_immediate_function_data_after_init_timer_context &&
129!match_function_and_data_after_init_timer_context &&
130 (context || org || report)@
131expression c, e6, e7;
132position r1.p;
133position j0, j1;
134@@
135
136* init_timer@j0@p (&e6);
137... when != c = e7
138* e6@j1.function = c;
139
140// ----------------------------------------------------------------------------
141
142@script:python match_immediate_function_data_after_init_timer_org
143depends on org@
144j0 << match_immediate_function_data_after_init_timer_context.j0;
145j1 << match_immediate_function_data_after_init_timer_context.j1;
146j2 << match_immediate_function_data_after_init_timer_context.j2;
147@@
148
149msg = "Use setup_timer function."
150coccilib.org.print_todo(j0[0], msg)
151coccilib.org.print_link(j1[0], "")
152coccilib.org.print_link(j2[0], "")
153
154@script:python match_function_and_data_after_init_timer_org depends on org@
155j0 << match_function_and_data_after_init_timer_context.j0;
156j1 << match_function_and_data_after_init_timer_context.j1;
157j2 << match_function_and_data_after_init_timer_context.j2;
158@@
159
160msg = "Use setup_timer function."
161coccilib.org.print_todo(j0[0], msg)
162coccilib.org.print_link(j1[0], "")
163coccilib.org.print_link(j2[0], "")
164
165@script:python r3_org depends on org@
166j0 << r3_context.j0;
167j1 << r3_context.j1;
168@@
169
170msg = "Use setup_timer function."
171coccilib.org.print_todo(j0[0], msg)
172coccilib.org.print_link(j1[0], "")
173
174// ----------------------------------------------------------------------------
175
176@script:python match_immediate_function_data_after_init_timer_report
177depends on report@
178j0 << match_immediate_function_data_after_init_timer_context.j0;
179j1 << match_immediate_function_data_after_init_timer_context.j1;
180@@
181
182msg = "Use setup_timer function for function on line %s." % (j1[0].line)
183coccilib.report.print_report(j0[0], msg)
184
185@script:python match_function_and_data_after_init_timer_report depends on report@
186j0 << match_function_and_data_after_init_timer_context.j0;
187j1 << match_function_and_data_after_init_timer_context.j1;
188@@
189
190msg = "Use setup_timer function for function on line %s." % (j1[0].line)
191coccilib.report.print_report(j0[0], msg)
192
193@script:python r3_report depends on report@
194j0 << r3_context.j0;
195j1 << r3_context.j1;
196@@
197
198msg = "Use setup_timer function for function on line %s." % (j1[0].line)
199coccilib.report.print_report(j0[0], msg)
diff --git a/scripts/coccinelle/api/simple_open.cocci b/scripts/coccinelle/api/simple_open.cocci
index bd1a2a4ee106..c121876d54ec 100644
--- a/scripts/coccinelle/api/simple_open.cocci
+++ b/scripts/coccinelle/api/simple_open.cocci
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/// Remove an open coded simple_open() function 2/// Remove an open coded simple_open() function
2/// and replace file operations references to the function 3/// and replace file operations references to the function
3/// with simple_open() instead. 4/// with simple_open() instead.
diff --git a/scripts/coccinelle/api/vma_pages.cocci b/scripts/coccinelle/api/vma_pages.cocci
index 3e52e11ea1dc..10511b9bf35e 100644
--- a/scripts/coccinelle/api/vma_pages.cocci
+++ b/scripts/coccinelle/api/vma_pages.cocci
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/// 2///
2/// Use vma_pages function on vma object instead of explicit computation. 3/// Use vma_pages function on vma object instead of explicit computation.
3/// 4///
diff --git a/scripts/coccinelle/iterators/list_entry_update.cocci b/scripts/coccinelle/iterators/list_entry_update.cocci
index 873f444e7137..be6f9f1abb34 100644
--- a/scripts/coccinelle/iterators/list_entry_update.cocci
+++ b/scripts/coccinelle/iterators/list_entry_update.cocci
@@ -15,7 +15,7 @@ virtual context
15virtual org 15virtual org
16virtual report 16virtual report
17 17
18@r@ 18@r exists@
19iterator name list_for_each_entry; 19iterator name list_for_each_entry;
20expression x,E; 20expression x,E;
21position p1,p2; 21position p1,p2;
diff --git a/scripts/coccinelle/misc/boolreturn.cocci b/scripts/coccinelle/misc/boolreturn.cocci
index a43c7b0c36ef..29d2bf41e95d 100644
--- a/scripts/coccinelle/misc/boolreturn.cocci
+++ b/scripts/coccinelle/misc/boolreturn.cocci
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/// Return statements in functions returning bool should use 2/// Return statements in functions returning bool should use
2/// true/false instead of 1/0. 3/// true/false instead of 1/0.
3// 4//
diff --git a/scripts/coccinelle/misc/ifcol.cocci b/scripts/coccinelle/misc/ifcol.cocci
index d0d00ef1f12a..ffe75407c5d2 100644
--- a/scripts/coccinelle/misc/ifcol.cocci
+++ b/scripts/coccinelle/misc/ifcol.cocci
@@ -3,10 +3,10 @@
3/// Sometimes, code after an if that is indented is actually intended to be 3/// Sometimes, code after an if that is indented is actually intended to be
4/// part of the if branch. 4/// part of the if branch.
5/// 5///
6/// This has a high rate of false positives, because Coccinelle's column 6//# This has a high rate of false positives, because Coccinelle's column
7/// calculation does not distinguish between spaces and tabs, so code that 7//# calculation does not distinguish between spaces and tabs, so code that
8/// is not visually aligned may be considered to be in the same column. 8//# is not visually aligned may be considered to be in the same column.
9/// 9//
10// Confidence: Low 10// Confidence: Low
11// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. 11// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
12// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. 12// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
diff --git a/scripts/coccinelle/misc/irqf_oneshot.cocci b/scripts/coccinelle/misc/irqf_oneshot.cocci
index f698d6d0f5d7..7b48287b3dc1 100644
--- a/scripts/coccinelle/misc/irqf_oneshot.cocci
+++ b/scripts/coccinelle/misc/irqf_oneshot.cocci
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/// Since commit 1c6c69525b40 ("genirq: Reject bogus threaded irq requests") 2/// Since commit 1c6c69525b40 ("genirq: Reject bogus threaded irq requests")
2/// threaded IRQs without a primary handler need to be requested with 3/// threaded IRQs without a primary handler need to be requested with
3/// IRQF_ONESHOT, otherwise the request will fail. 4/// IRQF_ONESHOT, otherwise the request will fail.
diff --git a/scripts/coccinelle/misc/of_table.cocci b/scripts/coccinelle/misc/of_table.cocci
index 2294915a19bc..4693ea744753 100644
--- a/scripts/coccinelle/misc/of_table.cocci
+++ b/scripts/coccinelle/misc/of_table.cocci
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/// Make sure (of/i2c/platform)_device_id tables are NULL terminated 2/// Make sure (of/i2c/platform)_device_id tables are NULL terminated
2// 3//
3// Keywords: of_table i2c_table platform_table 4// Keywords: of_table i2c_table platform_table
diff --git a/scripts/coccinelle/misc/orplus.cocci b/scripts/coccinelle/misc/orplus.cocci
index 81fabf379390..08de5be73693 100644
--- a/scripts/coccinelle/misc/orplus.cocci
+++ b/scripts/coccinelle/misc/orplus.cocci
@@ -14,7 +14,19 @@ virtual report
14virtual context 14virtual context
15 15
16@r@ 16@r@
17constant c; 17constant c,c1;
18identifier i,i1;
19position p;
20@@
21
22(
23 c1 + c - 1
24|
25 c1@i1 +@p c@i
26)
27
28@s@
29constant r.c, r.c1;
18identifier i; 30identifier i;
19expression e; 31expression e;
20@@ 32@@
@@ -27,28 +39,31 @@ e & c@i
27e |= c@i 39e |= c@i
28| 40|
29e &= c@i 41e &= c@i
42|
43e | c1@i
44|
45e & c1@i
46|
47e |= c1@i
48|
49e &= c1@i
30) 50)
31 51
32@s@ 52@depends on s@
33constant r.c,c1; 53position r.p;
34identifier i1; 54constant c1,c2;
35position p;
36@@ 55@@
37 56
38( 57* c1 +@p c2
39 c1 + c - 1
40|
41*c1@i1 +@p c
42)
43 58
44@script:python depends on org@ 59@script:python depends on s && org@
45p << s.p; 60p << r.p;
46@@ 61@@
47 62
48cocci.print_main("sum of probable bitmasks, consider |",p) 63cocci.print_main("sum of probable bitmasks, consider |",p)
49 64
50@script:python depends on report@ 65@script:python depends on s && report@
51p << s.p; 66p << r.p;
52@@ 67@@
53 68
54msg = "WARNING: sum of probable bitmasks, consider |" 69msg = "WARNING: sum of probable bitmasks, consider |"
diff --git a/scripts/coccinelle/null/badzero.cocci b/scripts/coccinelle/null/badzero.cocci
index 5551da2b4fe3..f597c8007b76 100644
--- a/scripts/coccinelle/null/badzero.cocci
+++ b/scripts/coccinelle/null/badzero.cocci
@@ -10,7 +10,7 @@
10// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. 10// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2.
11// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. 11// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2.
12// URL: http://coccinelle.lip6.fr/ 12// URL: http://coccinelle.lip6.fr/
13// Comments: Requires Coccinelle version 1.0.0-rc20 or later 13// Requires: 1.0.0
14// Options: 14// Options:
15 15
16virtual patch 16virtual patch
diff --git a/scripts/config b/scripts/config
index 026aeb4f32ee..e0e39826dae9 100755
--- a/scripts/config
+++ b/scripts/config
@@ -1,4 +1,5 @@
1#!/bin/bash 1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
2# Manipulate options in a .config file from the command line 3# Manipulate options in a .config file from the command line
3 4
4myname=${0##*/} 5myname=${0##*/}
diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh
index 5206d99ddeb8..64220e36ce3b 100755
--- a/scripts/decode_stacktrace.sh
+++ b/scripts/decode_stacktrace.sh
@@ -1,4 +1,5 @@
1#!/bin/bash 1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
2# (c) 2014, Sasha Levin <sasha.levin@oracle.com> 3# (c) 2014, Sasha Levin <sasha.levin@oracle.com>
3#set -x 4#set -x
4 5
diff --git a/scripts/decodecode b/scripts/decodecode
index d8824f37acce..438120da1361 100755
--- a/scripts/decodecode
+++ b/scripts/decodecode
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2# Disassemble the Code: line in Linux oopses 3# Disassemble the Code: line in Linux oopses
3# usage: decodecode < oops.file 4# usage: decodecode < oops.file
4# 5#
diff --git a/scripts/depmod.sh b/scripts/depmod.sh
index 122599b1c13b..9831cca31240 100755
--- a/scripts/depmod.sh
+++ b/scripts/depmod.sh
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2# 3#
3# A depmod wrapper used by the toplevel Makefile 4# A depmod wrapper used by the toplevel Makefile
4 5
diff --git a/scripts/diffconfig b/scripts/diffconfig
index 0db267d0adc9..89abf777f197 100755
--- a/scripts/diffconfig
+++ b/scripts/diffconfig
@@ -1,4 +1,5 @@
1#!/usr/bin/python 1#!/usr/bin/python
2# SPDX-License-Identifier: GPL-2.0
2# 3#
3# diffconfig - a tool to compare .config files. 4# diffconfig - a tool to compare .config files.
4# 5#
diff --git a/scripts/documentation-file-ref-check b/scripts/documentation-file-ref-check
new file mode 100755
index 000000000000..bc1659900e89
--- /dev/null
+++ b/scripts/documentation-file-ref-check
@@ -0,0 +1,15 @@
1#!/bin/sh
2# Treewide grep for references to files under Documentation, and report
3# non-existing files in stderr.
4
5for f in $(git ls-files); do
6 for ref in $(grep -ho "Documentation/[A-Za-z0-9_.,~/*+-]*" "$f"); do
7 # presume trailing . and , are not part of the name
8 ref=${ref%%[.,]}
9
10 # use ls to handle wildcards
11 if ! ls $ref >/dev/null 2>&1; then
12 echo "$f: $ref" >&2
13 fi
14 done
15done
diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile
index 2a48022c41e7..0dc922bb7aea 100644
--- a/scripts/dtc/Makefile
+++ b/scripts/dtc/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# scripts/dtc makefile 2# scripts/dtc makefile
2 3
3hostprogs-y := dtc 4hostprogs-y := dtc
diff --git a/scripts/dtc/checks.c b/scripts/dtc/checks.c
index 62ea8f83d4a0..e66138449886 100644
--- a/scripts/dtc/checks.c
+++ b/scripts/dtc/checks.c
@@ -873,7 +873,7 @@ static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct no
873 while (size--) 873 while (size--)
874 reg = (reg << 32) | fdt32_to_cpu(*(cells++)); 874 reg = (reg << 32) | fdt32_to_cpu(*(cells++));
875 875
876 snprintf(unit_addr, sizeof(unit_addr), "%llx", (unsigned long long)reg); 876 snprintf(unit_addr, sizeof(unit_addr), "%"PRIx64, reg);
877 if (!streq(unitname, unit_addr)) 877 if (!streq(unitname, unit_addr))
878 FAIL(c, dti, "Node %s simple-bus unit address format error, expected \"%s\"", 878 FAIL(c, dti, "Node %s simple-bus unit address format error, expected \"%s\"",
879 node->fullpath, unit_addr); 879 node->fullpath, unit_addr);
@@ -956,6 +956,274 @@ static void check_obsolete_chosen_interrupt_controller(struct check *c,
956WARNING(obsolete_chosen_interrupt_controller, 956WARNING(obsolete_chosen_interrupt_controller,
957 check_obsolete_chosen_interrupt_controller, NULL); 957 check_obsolete_chosen_interrupt_controller, NULL);
958 958
959struct provider {
960 const char *prop_name;
961 const char *cell_name;
962 bool optional;
963};
964
965static void check_property_phandle_args(struct check *c,
966 struct dt_info *dti,
967 struct node *node,
968 struct property *prop,
969 const struct provider *provider)
970{
971 struct node *root = dti->dt;
972 int cell, cellsize = 0;
973
974 if (prop->val.len % sizeof(cell_t)) {
975 FAIL(c, dti, "property '%s' size (%d) is invalid, expected multiple of %zu in node %s",
976 prop->name, prop->val.len, sizeof(cell_t), node->fullpath);
977 return;
978 }
979
980 for (cell = 0; cell < prop->val.len / sizeof(cell_t); cell += cellsize + 1) {
981 struct node *provider_node;
982 struct property *cellprop;
983 int phandle;
984
985 phandle = propval_cell_n(prop, cell);
986 /*
987 * Some bindings use a cell value 0 or -1 to skip over optional
988 * entries when each index position has a specific definition.
989 */
990 if (phandle == 0 || phandle == -1) {
991 /* Give up if this is an overlay with external references */
992 if (dti->dtsflags & DTSF_PLUGIN)
993 break;
994
995 cellsize = 0;
996 continue;
997 }
998
999 /* If we have markers, verify the current cell is a phandle */
1000 if (prop->val.markers) {
1001 struct marker *m = prop->val.markers;
1002 for_each_marker_of_type(m, REF_PHANDLE) {
1003 if (m->offset == (cell * sizeof(cell_t)))
1004 break;
1005 }
1006 if (!m)
1007 FAIL(c, dti, "Property '%s', cell %d is not a phandle reference in %s",
1008 prop->name, cell, node->fullpath);
1009 }
1010
1011 provider_node = get_node_by_phandle(root, phandle);
1012 if (!provider_node) {
1013 FAIL(c, dti, "Could not get phandle node for %s:%s(cell %d)",
1014 node->fullpath, prop->name, cell);
1015 break;
1016 }
1017
1018 cellprop = get_property(provider_node, provider->cell_name);
1019 if (cellprop) {
1020 cellsize = propval_cell(cellprop);
1021 } else if (provider->optional) {
1022 cellsize = 0;
1023 } else {
1024 FAIL(c, dti, "Missing property '%s' in node %s or bad phandle (referred from %s:%s[%d])",
1025 provider->cell_name,
1026 provider_node->fullpath,
1027 node->fullpath, prop->name, cell);
1028 break;
1029 }
1030
1031 if (prop->val.len < ((cell + cellsize + 1) * sizeof(cell_t))) {
1032 FAIL(c, dti, "%s property size (%d) too small for cell size %d in %s",
1033 prop->name, prop->val.len, cellsize, node->fullpath);
1034 }
1035 }
1036}
1037
1038static void check_provider_cells_property(struct check *c,
1039 struct dt_info *dti,
1040 struct node *node)
1041{
1042 struct provider *provider = c->data;
1043 struct property *prop;
1044
1045 prop = get_property(node, provider->prop_name);
1046 if (!prop)
1047 return;
1048
1049 check_property_phandle_args(c, dti, node, prop, provider);
1050}
1051#define WARNING_PROPERTY_PHANDLE_CELLS(nm, propname, cells_name, ...) \
1052 static struct provider nm##_provider = { (propname), (cells_name), __VA_ARGS__ }; \
1053 WARNING(nm##_property, check_provider_cells_property, &nm##_provider, &phandle_references);
1054
1055WARNING_PROPERTY_PHANDLE_CELLS(clocks, "clocks", "#clock-cells");
1056WARNING_PROPERTY_PHANDLE_CELLS(cooling_device, "cooling-device", "#cooling-cells");
1057WARNING_PROPERTY_PHANDLE_CELLS(dmas, "dmas", "#dma-cells");
1058WARNING_PROPERTY_PHANDLE_CELLS(hwlocks, "hwlocks", "#hwlock-cells");
1059WARNING_PROPERTY_PHANDLE_CELLS(interrupts_extended, "interrupts-extended", "#interrupt-cells");
1060WARNING_PROPERTY_PHANDLE_CELLS(io_channels, "io-channels", "#io-channel-cells");
1061WARNING_PROPERTY_PHANDLE_CELLS(iommus, "iommus", "#iommu-cells");
1062WARNING_PROPERTY_PHANDLE_CELLS(mboxes, "mboxes", "#mbox-cells");
1063WARNING_PROPERTY_PHANDLE_CELLS(msi_parent, "msi-parent", "#msi-cells", true);
1064WARNING_PROPERTY_PHANDLE_CELLS(mux_controls, "mux-controls", "#mux-control-cells");
1065WARNING_PROPERTY_PHANDLE_CELLS(phys, "phys", "#phy-cells");
1066WARNING_PROPERTY_PHANDLE_CELLS(power_domains, "power-domains", "#power-domain-cells");
1067WARNING_PROPERTY_PHANDLE_CELLS(pwms, "pwms", "#pwm-cells");
1068WARNING_PROPERTY_PHANDLE_CELLS(resets, "resets", "#reset-cells");
1069WARNING_PROPERTY_PHANDLE_CELLS(sound_dais, "sound-dais", "#sound-dai-cells");
1070WARNING_PROPERTY_PHANDLE_CELLS(thermal_sensors, "thermal-sensors", "#thermal-sensor-cells");
1071
1072static bool prop_is_gpio(struct property *prop)
1073{
1074 char *str;
1075
1076 /*
1077 * *-gpios and *-gpio can appear in property names,
1078 * so skip over any false matches (only one known ATM)
1079 */
1080 if (strstr(prop->name, "nr-gpio"))
1081 return false;
1082
1083 str = strrchr(prop->name, '-');
1084 if (str)
1085 str++;
1086 else
1087 str = prop->name;
1088 if (!(streq(str, "gpios") || streq(str, "gpio")))
1089 return false;
1090
1091 return true;
1092}
1093
1094static void check_gpios_property(struct check *c,
1095 struct dt_info *dti,
1096 struct node *node)
1097{
1098 struct property *prop;
1099
1100 /* Skip GPIO hog nodes which have 'gpios' property */
1101 if (get_property(node, "gpio-hog"))
1102 return;
1103
1104 for_each_property(node, prop) {
1105 struct provider provider;
1106
1107 if (!prop_is_gpio(prop))
1108 continue;
1109
1110 provider.prop_name = prop->name;
1111 provider.cell_name = "#gpio-cells";
1112 provider.optional = false;
1113 check_property_phandle_args(c, dti, node, prop, &provider);
1114 }
1115
1116}
1117WARNING(gpios_property, check_gpios_property, NULL, &phandle_references);
1118
1119static void check_deprecated_gpio_property(struct check *c,
1120 struct dt_info *dti,
1121 struct node *node)
1122{
1123 struct property *prop;
1124
1125 for_each_property(node, prop) {
1126 char *str;
1127
1128 if (!prop_is_gpio(prop))
1129 continue;
1130
1131 str = strstr(prop->name, "gpio");
1132 if (!streq(str, "gpio"))
1133 continue;
1134
1135 FAIL(c, dti, "'[*-]gpio' is deprecated, use '[*-]gpios' instead for %s:%s",
1136 node->fullpath, prop->name);
1137 }
1138
1139}
1140CHECK(deprecated_gpio_property, check_deprecated_gpio_property, NULL);
1141
1142static bool node_is_interrupt_provider(struct node *node)
1143{
1144 struct property *prop;
1145
1146 prop = get_property(node, "interrupt-controller");
1147 if (prop)
1148 return true;
1149
1150 prop = get_property(node, "interrupt-map");
1151 if (prop)
1152 return true;
1153
1154 return false;
1155}
1156static void check_interrupts_property(struct check *c,
1157 struct dt_info *dti,
1158 struct node *node)
1159{
1160 struct node *root = dti->dt;
1161 struct node *irq_node = NULL, *parent = node;
1162 struct property *irq_prop, *prop = NULL;
1163 int irq_cells, phandle;
1164
1165 irq_prop = get_property(node, "interrupts");
1166 if (!irq_prop)
1167 return;
1168
1169 if (irq_prop->val.len % sizeof(cell_t))
1170 FAIL(c, dti, "property '%s' size (%d) is invalid, expected multiple of %zu in node %s",
1171 irq_prop->name, irq_prop->val.len, sizeof(cell_t),
1172 node->fullpath);
1173
1174 while (parent && !prop) {
1175 if (parent != node && node_is_interrupt_provider(parent)) {
1176 irq_node = parent;
1177 break;
1178 }
1179
1180 prop = get_property(parent, "interrupt-parent");
1181 if (prop) {
1182 phandle = propval_cell(prop);
1183 /* Give up if this is an overlay with external references */
1184 if ((phandle == 0 || phandle == -1) &&
1185 (dti->dtsflags & DTSF_PLUGIN))
1186 return;
1187
1188 irq_node = get_node_by_phandle(root, phandle);
1189 if (!irq_node) {
1190 FAIL(c, dti, "Bad interrupt-parent phandle for %s",
1191 node->fullpath);
1192 return;
1193 }
1194 if (!node_is_interrupt_provider(irq_node))
1195 FAIL(c, dti,
1196 "Missing interrupt-controller or interrupt-map property in %s",
1197 irq_node->fullpath);
1198
1199 break;
1200 }
1201
1202 parent = parent->parent;
1203 }
1204
1205 if (!irq_node) {
1206 FAIL(c, dti, "Missing interrupt-parent for %s", node->fullpath);
1207 return;
1208 }
1209
1210 prop = get_property(irq_node, "#interrupt-cells");
1211 if (!prop) {
1212 FAIL(c, dti, "Missing #interrupt-cells in interrupt-parent %s",
1213 irq_node->fullpath);
1214 return;
1215 }
1216
1217 irq_cells = propval_cell(prop);
1218 if (irq_prop->val.len % (irq_cells * sizeof(cell_t))) {
1219 FAIL(c, dti,
1220 "interrupts size is (%d), expected multiple of %d in %s",
1221 irq_prop->val.len, (int)(irq_cells * sizeof(cell_t)),
1222 node->fullpath);
1223 }
1224}
1225WARNING(interrupts_property, check_interrupts_property, &phandle_references);
1226
959static struct check *check_table[] = { 1227static struct check *check_table[] = {
960 &duplicate_node_names, &duplicate_property_names, 1228 &duplicate_node_names, &duplicate_property_names,
961 &node_name_chars, &node_name_format, &property_name_chars, 1229 &node_name_chars, &node_name_format, &property_name_chars,
@@ -987,6 +1255,27 @@ static struct check *check_table[] = {
987 &avoid_default_addr_size, 1255 &avoid_default_addr_size,
988 &obsolete_chosen_interrupt_controller, 1256 &obsolete_chosen_interrupt_controller,
989 1257
1258 &clocks_property,
1259 &cooling_device_property,
1260 &dmas_property,
1261 &hwlocks_property,
1262 &interrupts_extended_property,
1263 &io_channels_property,
1264 &iommus_property,
1265 &mboxes_property,
1266 &msi_parent_property,
1267 &mux_controls_property,
1268 &phys_property,
1269 &power_domains_property,
1270 &pwms_property,
1271 &resets_property,
1272 &sound_dais_property,
1273 &thermal_sensors_property,
1274
1275 &deprecated_gpio_property,
1276 &gpios_property,
1277 &interrupts_property,
1278
990 &always_fail, 1279 &always_fail,
991}; 1280};
992 1281
diff --git a/scripts/dtc/dtc-lexer.lex.c_shipped b/scripts/dtc/dtc-lexer.lex.c_shipped
index 64c243772398..011bb9632ff2 100644
--- a/scripts/dtc/dtc-lexer.lex.c_shipped
+++ b/scripts/dtc/dtc-lexer.lex.c_shipped
@@ -1397,7 +1397,7 @@ static int yy_get_next_buffer (void)
1397{ 1397{
1398 char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; 1398 char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1399 char *source = (yytext_ptr); 1399 char *source = (yytext_ptr);
1400 yy_size_t number_to_move, i; 1400 int number_to_move, i;
1401 int ret_val; 1401 int ret_val;
1402 1402
1403 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) 1403 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
@@ -1426,7 +1426,7 @@ static int yy_get_next_buffer (void)
1426 /* Try to read more data. */ 1426 /* Try to read more data. */
1427 1427
1428 /* First move last chars to start of buffer. */ 1428 /* First move last chars to start of buffer. */
1429 number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1; 1429 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1);
1430 1430
1431 for ( i = 0; i < number_to_move; ++i ) 1431 for ( i = 0; i < number_to_move; ++i )
1432 *(dest++) = *(source++); 1432 *(dest++) = *(source++);
@@ -1508,7 +1508,7 @@ static int yy_get_next_buffer (void)
1508 else 1508 else
1509 ret_val = EOB_ACT_CONTINUE_SCAN; 1509 ret_val = EOB_ACT_CONTINUE_SCAN;
1510 1510
1511 if ((int) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { 1511 if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1512 /* Extend the array by 50%, plus the number we really need. */ 1512 /* Extend the array by 50%, plus the number we really need. */
1513 int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); 1513 int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1514 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); 1514 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
@@ -1987,10 +1987,10 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
1987 YY_BUFFER_STATE b; 1987 YY_BUFFER_STATE b;
1988 char *buf; 1988 char *buf;
1989 yy_size_t n; 1989 yy_size_t n;
1990 yy_size_t i; 1990 int i;
1991 1991
1992 /* Get memory for full buffer, including space for trailing EOB's. */ 1992 /* Get memory for full buffer, including space for trailing EOB's. */
1993 n = (yy_size_t) _yybytes_len + 2; 1993 n = (yy_size_t) (_yybytes_len + 2);
1994 buf = (char *) yyalloc(n ); 1994 buf = (char *) yyalloc(n );
1995 if ( ! buf ) 1995 if ( ! buf )
1996 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); 1996 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
diff --git a/scripts/dtc/dtc-parser.tab.c_shipped b/scripts/dtc/dtc-parser.tab.c_shipped
index 0a7a5ed86f04..aea514fa6928 100644
--- a/scripts/dtc/dtc-parser.tab.c_shipped
+++ b/scripts/dtc/dtc-parser.tab.c_shipped
@@ -448,7 +448,7 @@ union yyalloc
448/* YYNNTS -- Number of nonterminals. */ 448/* YYNNTS -- Number of nonterminals. */
449#define YYNNTS 30 449#define YYNNTS 30
450/* YYNRULES -- Number of rules. */ 450/* YYNRULES -- Number of rules. */
451#define YYNRULES 84 451#define YYNRULES 85
452/* YYNSTATES -- Number of states. */ 452/* YYNSTATES -- Number of states. */
453#define YYNSTATES 149 453#define YYNSTATES 149
454 454
@@ -499,14 +499,14 @@ static const yytype_uint8 yytranslate[] =
499static const yytype_uint16 yyrline[] = 499static const yytype_uint16 yyrline[] =
500{ 500{
501 0, 109, 109, 117, 121, 128, 129, 139, 142, 149, 501 0, 109, 109, 117, 121, 128, 129, 139, 142, 149,
502 153, 161, 165, 170, 181, 191, 206, 214, 217, 224, 502 153, 161, 165, 170, 181, 200, 213, 220, 228, 231,
503 228, 232, 236, 244, 248, 252, 256, 260, 276, 286, 503 238, 242, 246, 250, 258, 262, 266, 270, 274, 290,
504 294, 297, 301, 308, 324, 329, 348, 362, 369, 370, 504 300, 308, 311, 315, 322, 338, 343, 362, 376, 383,
505 371, 378, 382, 383, 387, 388, 392, 393, 397, 398, 505 384, 385, 392, 396, 397, 401, 402, 406, 407, 411,
506 402, 403, 407, 408, 412, 413, 414, 418, 419, 420, 506 412, 416, 417, 421, 422, 426, 427, 428, 432, 433,
507 421, 422, 426, 427, 428, 432, 433, 434, 438, 439, 507 434, 435, 436, 440, 441, 442, 446, 447, 448, 452,
508 448, 457, 461, 462, 463, 464, 469, 472, 476, 484, 508 453, 462, 471, 475, 476, 477, 478, 483, 486, 490,
509 487, 491, 499, 503, 507 509 498, 501, 505, 513, 517, 521
510}; 510};
511#endif 511#endif
512 512
@@ -582,20 +582,20 @@ static const yytype_int8 yypact[] =
582static const yytype_uint8 yydefact[] = 582static const yytype_uint8 yydefact[] =
583{ 583{
584 0, 0, 0, 5, 7, 3, 1, 6, 0, 0, 584 0, 0, 0, 5, 7, 3, 1, 6, 0, 0,
585 0, 7, 0, 38, 39, 0, 0, 10, 0, 2, 585 16, 7, 0, 39, 40, 0, 0, 10, 0, 2,
586 8, 4, 0, 0, 0, 72, 0, 41, 42, 44, 586 8, 4, 0, 0, 0, 73, 0, 42, 43, 45,
587 46, 48, 50, 52, 54, 57, 64, 67, 71, 0, 587 47, 49, 51, 53, 55, 58, 65, 68, 72, 0,
588 17, 11, 0, 0, 0, 0, 73, 74, 75, 40, 588 18, 11, 0, 0, 0, 0, 74, 75, 76, 41,
589 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 589 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
590 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 590 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,
591 79, 0, 0, 14, 12, 45, 0, 47, 49, 51, 591 80, 0, 0, 14, 12, 46, 0, 48, 50, 52,
592 53, 55, 56, 60, 61, 59, 58, 62, 63, 65, 592 54, 56, 57, 61, 62, 60, 59, 63, 64, 66,
593 66, 69, 68, 70, 0, 0, 0, 0, 18, 0, 593 67, 70, 69, 71, 0, 0, 0, 0, 19, 0,
594 79, 15, 13, 0, 0, 0, 20, 30, 82, 22, 594 80, 15, 13, 0, 0, 0, 21, 31, 83, 23,
595 84, 0, 81, 80, 43, 21, 83, 0, 0, 16, 595 85, 0, 82, 81, 44, 22, 84, 0, 0, 17,
596 29, 19, 31, 0, 23, 32, 26, 0, 76, 34, 596 30, 20, 32, 0, 24, 33, 27, 0, 77, 35,
597 0, 0, 0, 0, 37, 36, 24, 35, 33, 0, 597 0, 0, 0, 0, 38, 37, 25, 36, 34, 0,
598 77, 78, 25, 0, 28, 0, 0, 0, 27 598 78, 79, 26, 0, 29, 0, 0, 0, 28
599}; 599};
600 600
601 /* YYPGOTO[NTERM-NUM]. */ 601 /* YYPGOTO[NTERM-NUM]. */
@@ -678,28 +678,28 @@ static const yytype_uint8 yystos[] =
678static const yytype_uint8 yyr1[] = 678static const yytype_uint8 yyr1[] =
679{ 679{
680 0, 48, 49, 50, 50, 51, 51, 52, 52, 53, 680 0, 48, 49, 50, 50, 51, 51, 52, 52, 53,
681 53, 54, 54, 54, 54, 54, 55, 56, 56, 57, 681 53, 54, 54, 54, 54, 54, 54, 55, 56, 56,
682 57, 57, 57, 58, 58, 58, 58, 58, 58, 58, 682 57, 57, 57, 57, 58, 58, 58, 58, 58, 58,
683 59, 59, 59, 60, 60, 60, 60, 60, 61, 61, 683 58, 59, 59, 59, 60, 60, 60, 60, 60, 61,
684 61, 62, 63, 63, 64, 64, 65, 65, 66, 66, 684 61, 61, 62, 63, 63, 64, 64, 65, 65, 66,
685 67, 67, 68, 68, 69, 69, 69, 70, 70, 70, 685 66, 67, 67, 68, 68, 69, 69, 69, 70, 70,
686 70, 70, 71, 71, 71, 72, 72, 72, 73, 73, 686 70, 70, 70, 71, 71, 71, 72, 72, 72, 73,
687 73, 73, 74, 74, 74, 74, 75, 75, 75, 76, 687 73, 73, 73, 74, 74, 74, 74, 75, 75, 75,
688 76, 76, 77, 77, 77 688 76, 76, 76, 77, 77, 77
689}; 689};
690 690
691 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ 691 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
692static const yytype_uint8 yyr2[] = 692static const yytype_uint8 yyr2[] =
693{ 693{
694 0, 2, 3, 2, 4, 1, 2, 0, 2, 4, 694 0, 2, 3, 2, 4, 1, 2, 0, 2, 4,
695 2, 2, 3, 4, 3, 4, 5, 0, 2, 4, 695 2, 2, 3, 4, 3, 4, 0, 5, 0, 2,
696 2, 3, 2, 2, 3, 4, 2, 9, 5, 2, 696 4, 2, 3, 2, 2, 3, 4, 2, 9, 5,
697 0, 2, 2, 3, 1, 2, 2, 2, 1, 1, 697 2, 0, 2, 2, 3, 1, 2, 2, 2, 1,
698 3, 1, 1, 5, 1, 3, 1, 3, 1, 3, 698 1, 3, 1, 1, 5, 1, 3, 1, 3, 1,
699 1, 3, 1, 3, 1, 3, 3, 1, 3, 3, 699 3, 1, 3, 1, 3, 1, 3, 3, 1, 3,
700 3, 3, 3, 3, 1, 3, 3, 1, 3, 3, 700 3, 3, 3, 3, 3, 1, 3, 3, 1, 3,
701 3, 1, 1, 2, 2, 2, 0, 2, 2, 0, 701 3, 3, 1, 1, 2, 2, 2, 0, 2, 2,
702 2, 2, 2, 3, 2 702 0, 2, 2, 2, 3, 2
703}; 703};
704 704
705 705
@@ -1572,17 +1572,26 @@ yyreduce:
1572 { 1572 {
1573 struct node *target = get_node_by_ref((yyvsp[-2].node), (yyvsp[-1].labelref)); 1573 struct node *target = get_node_by_ref((yyvsp[-2].node), (yyvsp[-1].labelref));
1574 1574
1575 if (target) 1575 if (target) {
1576 merge_nodes(target, (yyvsp[0].node)); 1576 merge_nodes(target, (yyvsp[0].node));
1577 else 1577 } else {
1578 ERROR(&(yylsp[-1]), "Label or path %s not found", (yyvsp[-1].labelref)); 1578 /*
1579 * We rely on the rule being always:
1580 * versioninfo plugindecl memreserves devicetree
1581 * so $-1 is what we want (plugindecl)
1582 */
1583 if ((yyvsp[(-1) - (3)].flags) & DTSF_PLUGIN)
1584 add_orphan_node((yyvsp[-2].node), (yyvsp[0].node), (yyvsp[-1].labelref));
1585 else
1586 ERROR(&(yylsp[-1]), "Label or path %s not found", (yyvsp[-1].labelref));
1587 }
1579 (yyval.node) = (yyvsp[-2].node); 1588 (yyval.node) = (yyvsp[-2].node);
1580 } 1589 }
1581#line 1582 "dtc-parser.tab.c" /* yacc.c:1646 */ 1590#line 1591 "dtc-parser.tab.c" /* yacc.c:1646 */
1582 break; 1591 break;
1583 1592
1584 case 15: 1593 case 15:
1585#line 192 "dtc-parser.y" /* yacc.c:1646 */ 1594#line 201 "dtc-parser.y" /* yacc.c:1646 */
1586 { 1595 {
1587 struct node *target = get_node_by_ref((yyvsp[-3].node), (yyvsp[-1].labelref)); 1596 struct node *target = get_node_by_ref((yyvsp[-3].node), (yyvsp[-1].labelref));
1588 1597
@@ -1594,100 +1603,109 @@ yyreduce:
1594 1603
1595 (yyval.node) = (yyvsp[-3].node); 1604 (yyval.node) = (yyvsp[-3].node);
1596 } 1605 }
1597#line 1598 "dtc-parser.tab.c" /* yacc.c:1646 */ 1606#line 1607 "dtc-parser.tab.c" /* yacc.c:1646 */
1598 break; 1607 break;
1599 1608
1600 case 16: 1609 case 16:
1601#line 207 "dtc-parser.y" /* yacc.c:1646 */ 1610#line 213 "dtc-parser.y" /* yacc.c:1646 */
1602 { 1611 {
1603 (yyval.node) = build_node((yyvsp[-3].proplist), (yyvsp[-2].nodelist)); 1612 /* build empty node */
1613 (yyval.node) = name_node(build_node(NULL, NULL), "");
1604 } 1614 }
1605#line 1606 "dtc-parser.tab.c" /* yacc.c:1646 */ 1615#line 1616 "dtc-parser.tab.c" /* yacc.c:1646 */
1606 break; 1616 break;
1607 1617
1608 case 17: 1618 case 17:
1609#line 214 "dtc-parser.y" /* yacc.c:1646 */ 1619#line 221 "dtc-parser.y" /* yacc.c:1646 */
1610 { 1620 {
1611 (yyval.proplist) = NULL; 1621 (yyval.node) = build_node((yyvsp[-3].proplist), (yyvsp[-2].nodelist));
1612 } 1622 }
1613#line 1614 "dtc-parser.tab.c" /* yacc.c:1646 */ 1623#line 1624 "dtc-parser.tab.c" /* yacc.c:1646 */
1614 break; 1624 break;
1615 1625
1616 case 18: 1626 case 18:
1617#line 218 "dtc-parser.y" /* yacc.c:1646 */ 1627#line 228 "dtc-parser.y" /* yacc.c:1646 */
1618 { 1628 {
1619 (yyval.proplist) = chain_property((yyvsp[0].prop), (yyvsp[-1].proplist)); 1629 (yyval.proplist) = NULL;
1620 } 1630 }
1621#line 1622 "dtc-parser.tab.c" /* yacc.c:1646 */ 1631#line 1632 "dtc-parser.tab.c" /* yacc.c:1646 */
1622 break; 1632 break;
1623 1633
1624 case 19: 1634 case 19:
1625#line 225 "dtc-parser.y" /* yacc.c:1646 */ 1635#line 232 "dtc-parser.y" /* yacc.c:1646 */
1626 { 1636 {
1627 (yyval.prop) = build_property((yyvsp[-3].propnodename), (yyvsp[-1].data)); 1637 (yyval.proplist) = chain_property((yyvsp[0].prop), (yyvsp[-1].proplist));
1628 } 1638 }
1629#line 1630 "dtc-parser.tab.c" /* yacc.c:1646 */ 1639#line 1640 "dtc-parser.tab.c" /* yacc.c:1646 */
1630 break; 1640 break;
1631 1641
1632 case 20: 1642 case 20:
1633#line 229 "dtc-parser.y" /* yacc.c:1646 */ 1643#line 239 "dtc-parser.y" /* yacc.c:1646 */
1634 { 1644 {
1635 (yyval.prop) = build_property((yyvsp[-1].propnodename), empty_data); 1645 (yyval.prop) = build_property((yyvsp[-3].propnodename), (yyvsp[-1].data));
1636 } 1646 }
1637#line 1638 "dtc-parser.tab.c" /* yacc.c:1646 */ 1647#line 1648 "dtc-parser.tab.c" /* yacc.c:1646 */
1638 break; 1648 break;
1639 1649
1640 case 21: 1650 case 21:
1641#line 233 "dtc-parser.y" /* yacc.c:1646 */ 1651#line 243 "dtc-parser.y" /* yacc.c:1646 */
1642 { 1652 {
1643 (yyval.prop) = build_property_delete((yyvsp[-1].propnodename)); 1653 (yyval.prop) = build_property((yyvsp[-1].propnodename), empty_data);
1644 } 1654 }
1645#line 1646 "dtc-parser.tab.c" /* yacc.c:1646 */ 1655#line 1656 "dtc-parser.tab.c" /* yacc.c:1646 */
1646 break; 1656 break;
1647 1657
1648 case 22: 1658 case 22:
1649#line 237 "dtc-parser.y" /* yacc.c:1646 */ 1659#line 247 "dtc-parser.y" /* yacc.c:1646 */
1660 {
1661 (yyval.prop) = build_property_delete((yyvsp[-1].propnodename));
1662 }
1663#line 1664 "dtc-parser.tab.c" /* yacc.c:1646 */
1664 break;
1665
1666 case 23:
1667#line 251 "dtc-parser.y" /* yacc.c:1646 */
1650 { 1668 {
1651 add_label(&(yyvsp[0].prop)->labels, (yyvsp[-1].labelref)); 1669 add_label(&(yyvsp[0].prop)->labels, (yyvsp[-1].labelref));
1652 (yyval.prop) = (yyvsp[0].prop); 1670 (yyval.prop) = (yyvsp[0].prop);
1653 } 1671 }
1654#line 1655 "dtc-parser.tab.c" /* yacc.c:1646 */ 1672#line 1673 "dtc-parser.tab.c" /* yacc.c:1646 */
1655 break; 1673 break;
1656 1674
1657 case 23: 1675 case 24:
1658#line 245 "dtc-parser.y" /* yacc.c:1646 */ 1676#line 259 "dtc-parser.y" /* yacc.c:1646 */
1659 { 1677 {
1660 (yyval.data) = data_merge((yyvsp[-1].data), (yyvsp[0].data)); 1678 (yyval.data) = data_merge((yyvsp[-1].data), (yyvsp[0].data));
1661 } 1679 }
1662#line 1663 "dtc-parser.tab.c" /* yacc.c:1646 */ 1680#line 1681 "dtc-parser.tab.c" /* yacc.c:1646 */
1663 break; 1681 break;
1664 1682
1665 case 24: 1683 case 25:
1666#line 249 "dtc-parser.y" /* yacc.c:1646 */ 1684#line 263 "dtc-parser.y" /* yacc.c:1646 */
1667 { 1685 {
1668 (yyval.data) = data_merge((yyvsp[-2].data), (yyvsp[-1].array).data); 1686 (yyval.data) = data_merge((yyvsp[-2].data), (yyvsp[-1].array).data);
1669 } 1687 }
1670#line 1671 "dtc-parser.tab.c" /* yacc.c:1646 */ 1688#line 1689 "dtc-parser.tab.c" /* yacc.c:1646 */
1671 break; 1689 break;
1672 1690
1673 case 25: 1691 case 26:
1674#line 253 "dtc-parser.y" /* yacc.c:1646 */ 1692#line 267 "dtc-parser.y" /* yacc.c:1646 */
1675 { 1693 {
1676 (yyval.data) = data_merge((yyvsp[-3].data), (yyvsp[-1].data)); 1694 (yyval.data) = data_merge((yyvsp[-3].data), (yyvsp[-1].data));
1677 } 1695 }
1678#line 1679 "dtc-parser.tab.c" /* yacc.c:1646 */ 1696#line 1697 "dtc-parser.tab.c" /* yacc.c:1646 */
1679 break; 1697 break;
1680 1698
1681 case 26: 1699 case 27:
1682#line 257 "dtc-parser.y" /* yacc.c:1646 */ 1700#line 271 "dtc-parser.y" /* yacc.c:1646 */
1683 { 1701 {
1684 (yyval.data) = data_add_marker((yyvsp[-1].data), REF_PATH, (yyvsp[0].labelref)); 1702 (yyval.data) = data_add_marker((yyvsp[-1].data), REF_PATH, (yyvsp[0].labelref));
1685 } 1703 }
1686#line 1687 "dtc-parser.tab.c" /* yacc.c:1646 */ 1704#line 1705 "dtc-parser.tab.c" /* yacc.c:1646 */
1687 break; 1705 break;
1688 1706
1689 case 27: 1707 case 28:
1690#line 261 "dtc-parser.y" /* yacc.c:1646 */ 1708#line 275 "dtc-parser.y" /* yacc.c:1646 */
1691 { 1709 {
1692 FILE *f = srcfile_relative_open((yyvsp[-5].data).val, NULL); 1710 FILE *f = srcfile_relative_open((yyvsp[-5].data).val, NULL);
1693 struct data d; 1711 struct data d;
@@ -1703,11 +1721,11 @@ yyreduce:
1703 (yyval.data) = data_merge((yyvsp[-8].data), d); 1721 (yyval.data) = data_merge((yyvsp[-8].data), d);
1704 fclose(f); 1722 fclose(f);
1705 } 1723 }
1706#line 1707 "dtc-parser.tab.c" /* yacc.c:1646 */ 1724#line 1725 "dtc-parser.tab.c" /* yacc.c:1646 */
1707 break; 1725 break;
1708 1726
1709 case 28: 1727 case 29:
1710#line 277 "dtc-parser.y" /* yacc.c:1646 */ 1728#line 291 "dtc-parser.y" /* yacc.c:1646 */
1711 { 1729 {
1712 FILE *f = srcfile_relative_open((yyvsp[-1].data).val, NULL); 1730 FILE *f = srcfile_relative_open((yyvsp[-1].data).val, NULL);
1713 struct data d = empty_data; 1731 struct data d = empty_data;
@@ -1717,43 +1735,43 @@ yyreduce:
1717 (yyval.data) = data_merge((yyvsp[-4].data), d); 1735 (yyval.data) = data_merge((yyvsp[-4].data), d);
1718 fclose(f); 1736 fclose(f);
1719 } 1737 }
1720#line 1721 "dtc-parser.tab.c" /* yacc.c:1646 */ 1738#line 1739 "dtc-parser.tab.c" /* yacc.c:1646 */
1721 break; 1739 break;
1722 1740
1723 case 29: 1741 case 30:
1724#line 287 "dtc-parser.y" /* yacc.c:1646 */ 1742#line 301 "dtc-parser.y" /* yacc.c:1646 */
1725 { 1743 {
1726 (yyval.data) = data_add_marker((yyvsp[-1].data), LABEL, (yyvsp[0].labelref)); 1744 (yyval.data) = data_add_marker((yyvsp[-1].data), LABEL, (yyvsp[0].labelref));
1727 } 1745 }
1728#line 1729 "dtc-parser.tab.c" /* yacc.c:1646 */ 1746#line 1747 "dtc-parser.tab.c" /* yacc.c:1646 */
1729 break; 1747 break;
1730 1748
1731 case 30: 1749 case 31:
1732#line 294 "dtc-parser.y" /* yacc.c:1646 */ 1750#line 308 "dtc-parser.y" /* yacc.c:1646 */
1733 { 1751 {
1734 (yyval.data) = empty_data; 1752 (yyval.data) = empty_data;
1735 } 1753 }
1736#line 1737 "dtc-parser.tab.c" /* yacc.c:1646 */ 1754#line 1755 "dtc-parser.tab.c" /* yacc.c:1646 */
1737 break; 1755 break;
1738 1756
1739 case 31: 1757 case 32:
1740#line 298 "dtc-parser.y" /* yacc.c:1646 */ 1758#line 312 "dtc-parser.y" /* yacc.c:1646 */
1741 { 1759 {
1742 (yyval.data) = (yyvsp[-1].data); 1760 (yyval.data) = (yyvsp[-1].data);
1743 } 1761 }
1744#line 1745 "dtc-parser.tab.c" /* yacc.c:1646 */ 1762#line 1763 "dtc-parser.tab.c" /* yacc.c:1646 */
1745 break; 1763 break;
1746 1764
1747 case 32: 1765 case 33:
1748#line 302 "dtc-parser.y" /* yacc.c:1646 */ 1766#line 316 "dtc-parser.y" /* yacc.c:1646 */
1749 { 1767 {
1750 (yyval.data) = data_add_marker((yyvsp[-1].data), LABEL, (yyvsp[0].labelref)); 1768 (yyval.data) = data_add_marker((yyvsp[-1].data), LABEL, (yyvsp[0].labelref));
1751 } 1769 }
1752#line 1753 "dtc-parser.tab.c" /* yacc.c:1646 */ 1770#line 1771 "dtc-parser.tab.c" /* yacc.c:1646 */
1753 break; 1771 break;
1754 1772
1755 case 33: 1773 case 34:
1756#line 309 "dtc-parser.y" /* yacc.c:1646 */ 1774#line 323 "dtc-parser.y" /* yacc.c:1646 */
1757 { 1775 {
1758 unsigned long long bits; 1776 unsigned long long bits;
1759 1777
@@ -1769,20 +1787,20 @@ yyreduce:
1769 (yyval.array).data = empty_data; 1787 (yyval.array).data = empty_data;
1770 (yyval.array).bits = bits; 1788 (yyval.array).bits = bits;
1771 } 1789 }
1772#line 1773 "dtc-parser.tab.c" /* yacc.c:1646 */ 1790#line 1791 "dtc-parser.tab.c" /* yacc.c:1646 */
1773 break; 1791 break;
1774 1792
1775 case 34: 1793 case 35:
1776#line 325 "dtc-parser.y" /* yacc.c:1646 */ 1794#line 339 "dtc-parser.y" /* yacc.c:1646 */
1777 { 1795 {
1778 (yyval.array).data = empty_data; 1796 (yyval.array).data = empty_data;
1779 (yyval.array).bits = 32; 1797 (yyval.array).bits = 32;
1780 } 1798 }
1781#line 1782 "dtc-parser.tab.c" /* yacc.c:1646 */ 1799#line 1800 "dtc-parser.tab.c" /* yacc.c:1646 */
1782 break; 1800 break;
1783 1801
1784 case 35: 1802 case 36:
1785#line 330 "dtc-parser.y" /* yacc.c:1646 */ 1803#line 344 "dtc-parser.y" /* yacc.c:1646 */
1786 { 1804 {
1787 if ((yyvsp[-1].array).bits < 64) { 1805 if ((yyvsp[-1].array).bits < 64) {
1788 uint64_t mask = (1ULL << (yyvsp[-1].array).bits) - 1; 1806 uint64_t mask = (1ULL << (yyvsp[-1].array).bits) - 1;
@@ -1801,11 +1819,11 @@ yyreduce:
1801 1819
1802 (yyval.array).data = data_append_integer((yyvsp[-1].array).data, (yyvsp[0].integer), (yyvsp[-1].array).bits); 1820 (yyval.array).data = data_append_integer((yyvsp[-1].array).data, (yyvsp[0].integer), (yyvsp[-1].array).bits);
1803 } 1821 }
1804#line 1805 "dtc-parser.tab.c" /* yacc.c:1646 */ 1822#line 1823 "dtc-parser.tab.c" /* yacc.c:1646 */
1805 break; 1823 break;
1806 1824
1807 case 36: 1825 case 37:
1808#line 349 "dtc-parser.y" /* yacc.c:1646 */ 1826#line 363 "dtc-parser.y" /* yacc.c:1646 */
1809 { 1827 {
1810 uint64_t val = ~0ULL >> (64 - (yyvsp[-1].array).bits); 1828 uint64_t val = ~0ULL >> (64 - (yyvsp[-1].array).bits);
1811 1829
@@ -1819,129 +1837,129 @@ yyreduce:
1819 1837
1820 (yyval.array).data = data_append_integer((yyvsp[-1].array).data, val, (yyvsp[-1].array).bits); 1838 (yyval.array).data = data_append_integer((yyvsp[-1].array).data, val, (yyvsp[-1].array).bits);
1821 } 1839 }
1822#line 1823 "dtc-parser.tab.c" /* yacc.c:1646 */ 1840#line 1841 "dtc-parser.tab.c" /* yacc.c:1646 */
1823 break; 1841 break;
1824 1842
1825 case 37: 1843 case 38:
1826#line 363 "dtc-parser.y" /* yacc.c:1646 */ 1844#line 377 "dtc-parser.y" /* yacc.c:1646 */
1827 { 1845 {
1828 (yyval.array).data = data_add_marker((yyvsp[-1].array).data, LABEL, (yyvsp[0].labelref)); 1846 (yyval.array).data = data_add_marker((yyvsp[-1].array).data, LABEL, (yyvsp[0].labelref));
1829 } 1847 }
1830#line 1831 "dtc-parser.tab.c" /* yacc.c:1646 */ 1848#line 1849 "dtc-parser.tab.c" /* yacc.c:1646 */
1831 break; 1849 break;
1832 1850
1833 case 40: 1851 case 41:
1834#line 372 "dtc-parser.y" /* yacc.c:1646 */ 1852#line 386 "dtc-parser.y" /* yacc.c:1646 */
1835 { 1853 {
1836 (yyval.integer) = (yyvsp[-1].integer); 1854 (yyval.integer) = (yyvsp[-1].integer);
1837 } 1855 }
1838#line 1839 "dtc-parser.tab.c" /* yacc.c:1646 */ 1856#line 1857 "dtc-parser.tab.c" /* yacc.c:1646 */
1839 break; 1857 break;
1840 1858
1841 case 43: 1859 case 44:
1842#line 383 "dtc-parser.y" /* yacc.c:1646 */ 1860#line 397 "dtc-parser.y" /* yacc.c:1646 */
1843 { (yyval.integer) = (yyvsp[-4].integer) ? (yyvsp[-2].integer) : (yyvsp[0].integer); } 1861 { (yyval.integer) = (yyvsp[-4].integer) ? (yyvsp[-2].integer) : (yyvsp[0].integer); }
1844#line 1845 "dtc-parser.tab.c" /* yacc.c:1646 */ 1862#line 1863 "dtc-parser.tab.c" /* yacc.c:1646 */
1845 break; 1863 break;
1846 1864
1847 case 45: 1865 case 46:
1848#line 388 "dtc-parser.y" /* yacc.c:1646 */ 1866#line 402 "dtc-parser.y" /* yacc.c:1646 */
1849 { (yyval.integer) = (yyvsp[-2].integer) || (yyvsp[0].integer); } 1867 { (yyval.integer) = (yyvsp[-2].integer) || (yyvsp[0].integer); }
1850#line 1851 "dtc-parser.tab.c" /* yacc.c:1646 */ 1868#line 1869 "dtc-parser.tab.c" /* yacc.c:1646 */
1851 break; 1869 break;
1852 1870
1853 case 47: 1871 case 48:
1854#line 393 "dtc-parser.y" /* yacc.c:1646 */ 1872#line 407 "dtc-parser.y" /* yacc.c:1646 */
1855 { (yyval.integer) = (yyvsp[-2].integer) && (yyvsp[0].integer); } 1873 { (yyval.integer) = (yyvsp[-2].integer) && (yyvsp[0].integer); }
1856#line 1857 "dtc-parser.tab.c" /* yacc.c:1646 */ 1874#line 1875 "dtc-parser.tab.c" /* yacc.c:1646 */
1857 break; 1875 break;
1858 1876
1859 case 49: 1877 case 50:
1860#line 398 "dtc-parser.y" /* yacc.c:1646 */ 1878#line 412 "dtc-parser.y" /* yacc.c:1646 */
1861 { (yyval.integer) = (yyvsp[-2].integer) | (yyvsp[0].integer); } 1879 { (yyval.integer) = (yyvsp[-2].integer) | (yyvsp[0].integer); }
1862#line 1863 "dtc-parser.tab.c" /* yacc.c:1646 */ 1880#line 1881 "dtc-parser.tab.c" /* yacc.c:1646 */
1863 break; 1881 break;
1864 1882
1865 case 51: 1883 case 52:
1866#line 403 "dtc-parser.y" /* yacc.c:1646 */ 1884#line 417 "dtc-parser.y" /* yacc.c:1646 */
1867 { (yyval.integer) = (yyvsp[-2].integer) ^ (yyvsp[0].integer); } 1885 { (yyval.integer) = (yyvsp[-2].integer) ^ (yyvsp[0].integer); }
1868#line 1869 "dtc-parser.tab.c" /* yacc.c:1646 */ 1886#line 1887 "dtc-parser.tab.c" /* yacc.c:1646 */
1869 break; 1887 break;
1870 1888
1871 case 53: 1889 case 54:
1872#line 408 "dtc-parser.y" /* yacc.c:1646 */ 1890#line 422 "dtc-parser.y" /* yacc.c:1646 */
1873 { (yyval.integer) = (yyvsp[-2].integer) & (yyvsp[0].integer); } 1891 { (yyval.integer) = (yyvsp[-2].integer) & (yyvsp[0].integer); }
1874#line 1875 "dtc-parser.tab.c" /* yacc.c:1646 */ 1892#line 1893 "dtc-parser.tab.c" /* yacc.c:1646 */
1875 break; 1893 break;
1876 1894
1877 case 55: 1895 case 56:
1878#line 413 "dtc-parser.y" /* yacc.c:1646 */ 1896#line 427 "dtc-parser.y" /* yacc.c:1646 */
1879 { (yyval.integer) = (yyvsp[-2].integer) == (yyvsp[0].integer); } 1897 { (yyval.integer) = (yyvsp[-2].integer) == (yyvsp[0].integer); }
1880#line 1881 "dtc-parser.tab.c" /* yacc.c:1646 */ 1898#line 1899 "dtc-parser.tab.c" /* yacc.c:1646 */
1881 break; 1899 break;
1882 1900
1883 case 56: 1901 case 57:
1884#line 414 "dtc-parser.y" /* yacc.c:1646 */ 1902#line 428 "dtc-parser.y" /* yacc.c:1646 */
1885 { (yyval.integer) = (yyvsp[-2].integer) != (yyvsp[0].integer); } 1903 { (yyval.integer) = (yyvsp[-2].integer) != (yyvsp[0].integer); }
1886#line 1887 "dtc-parser.tab.c" /* yacc.c:1646 */ 1904#line 1905 "dtc-parser.tab.c" /* yacc.c:1646 */
1887 break; 1905 break;
1888 1906
1889 case 58: 1907 case 59:
1890#line 419 "dtc-parser.y" /* yacc.c:1646 */ 1908#line 433 "dtc-parser.y" /* yacc.c:1646 */
1891 { (yyval.integer) = (yyvsp[-2].integer) < (yyvsp[0].integer); } 1909 { (yyval.integer) = (yyvsp[-2].integer) < (yyvsp[0].integer); }
1892#line 1893 "dtc-parser.tab.c" /* yacc.c:1646 */ 1910#line 1911 "dtc-parser.tab.c" /* yacc.c:1646 */
1893 break; 1911 break;
1894 1912
1895 case 59: 1913 case 60:
1896#line 420 "dtc-parser.y" /* yacc.c:1646 */ 1914#line 434 "dtc-parser.y" /* yacc.c:1646 */
1897 { (yyval.integer) = (yyvsp[-2].integer) > (yyvsp[0].integer); } 1915 { (yyval.integer) = (yyvsp[-2].integer) > (yyvsp[0].integer); }
1898#line 1899 "dtc-parser.tab.c" /* yacc.c:1646 */ 1916#line 1917 "dtc-parser.tab.c" /* yacc.c:1646 */
1899 break; 1917 break;
1900 1918
1901 case 60: 1919 case 61:
1902#line 421 "dtc-parser.y" /* yacc.c:1646 */ 1920#line 435 "dtc-parser.y" /* yacc.c:1646 */
1903 { (yyval.integer) = (yyvsp[-2].integer) <= (yyvsp[0].integer); } 1921 { (yyval.integer) = (yyvsp[-2].integer) <= (yyvsp[0].integer); }
1904#line 1905 "dtc-parser.tab.c" /* yacc.c:1646 */ 1922#line 1923 "dtc-parser.tab.c" /* yacc.c:1646 */
1905 break; 1923 break;
1906 1924
1907 case 61: 1925 case 62:
1908#line 422 "dtc-parser.y" /* yacc.c:1646 */ 1926#line 436 "dtc-parser.y" /* yacc.c:1646 */
1909 { (yyval.integer) = (yyvsp[-2].integer) >= (yyvsp[0].integer); } 1927 { (yyval.integer) = (yyvsp[-2].integer) >= (yyvsp[0].integer); }
1910#line 1911 "dtc-parser.tab.c" /* yacc.c:1646 */ 1928#line 1929 "dtc-parser.tab.c" /* yacc.c:1646 */
1911 break; 1929 break;
1912 1930
1913 case 62: 1931 case 63:
1914#line 426 "dtc-parser.y" /* yacc.c:1646 */ 1932#line 440 "dtc-parser.y" /* yacc.c:1646 */
1915 { (yyval.integer) = (yyvsp[-2].integer) << (yyvsp[0].integer); } 1933 { (yyval.integer) = (yyvsp[-2].integer) << (yyvsp[0].integer); }
1916#line 1917 "dtc-parser.tab.c" /* yacc.c:1646 */ 1934#line 1935 "dtc-parser.tab.c" /* yacc.c:1646 */
1917 break; 1935 break;
1918 1936
1919 case 63: 1937 case 64:
1920#line 427 "dtc-parser.y" /* yacc.c:1646 */ 1938#line 441 "dtc-parser.y" /* yacc.c:1646 */
1921 { (yyval.integer) = (yyvsp[-2].integer) >> (yyvsp[0].integer); } 1939 { (yyval.integer) = (yyvsp[-2].integer) >> (yyvsp[0].integer); }
1922#line 1923 "dtc-parser.tab.c" /* yacc.c:1646 */ 1940#line 1941 "dtc-parser.tab.c" /* yacc.c:1646 */
1923 break; 1941 break;
1924 1942
1925 case 65: 1943 case 66:
1926#line 432 "dtc-parser.y" /* yacc.c:1646 */ 1944#line 446 "dtc-parser.y" /* yacc.c:1646 */
1927 { (yyval.integer) = (yyvsp[-2].integer) + (yyvsp[0].integer); } 1945 { (yyval.integer) = (yyvsp[-2].integer) + (yyvsp[0].integer); }
1928#line 1929 "dtc-parser.tab.c" /* yacc.c:1646 */ 1946#line 1947 "dtc-parser.tab.c" /* yacc.c:1646 */
1929 break; 1947 break;
1930 1948
1931 case 66: 1949 case 67:
1932#line 433 "dtc-parser.y" /* yacc.c:1646 */ 1950#line 447 "dtc-parser.y" /* yacc.c:1646 */
1933 { (yyval.integer) = (yyvsp[-2].integer) - (yyvsp[0].integer); } 1951 { (yyval.integer) = (yyvsp[-2].integer) - (yyvsp[0].integer); }
1934#line 1935 "dtc-parser.tab.c" /* yacc.c:1646 */ 1952#line 1953 "dtc-parser.tab.c" /* yacc.c:1646 */
1935 break; 1953 break;
1936 1954
1937 case 68: 1955 case 69:
1938#line 438 "dtc-parser.y" /* yacc.c:1646 */ 1956#line 452 "dtc-parser.y" /* yacc.c:1646 */
1939 { (yyval.integer) = (yyvsp[-2].integer) * (yyvsp[0].integer); } 1957 { (yyval.integer) = (yyvsp[-2].integer) * (yyvsp[0].integer); }
1940#line 1941 "dtc-parser.tab.c" /* yacc.c:1646 */ 1958#line 1959 "dtc-parser.tab.c" /* yacc.c:1646 */
1941 break; 1959 break;
1942 1960
1943 case 69: 1961 case 70:
1944#line 440 "dtc-parser.y" /* yacc.c:1646 */ 1962#line 454 "dtc-parser.y" /* yacc.c:1646 */
1945 { 1963 {
1946 if ((yyvsp[0].integer) != 0) { 1964 if ((yyvsp[0].integer) != 0) {
1947 (yyval.integer) = (yyvsp[-2].integer) / (yyvsp[0].integer); 1965 (yyval.integer) = (yyvsp[-2].integer) / (yyvsp[0].integer);
@@ -1950,11 +1968,11 @@ yyreduce:
1950 (yyval.integer) = 0; 1968 (yyval.integer) = 0;
1951 } 1969 }
1952 } 1970 }
1953#line 1954 "dtc-parser.tab.c" /* yacc.c:1646 */ 1971#line 1972 "dtc-parser.tab.c" /* yacc.c:1646 */
1954 break; 1972 break;
1955 1973
1956 case 70: 1974 case 71:
1957#line 449 "dtc-parser.y" /* yacc.c:1646 */ 1975#line 463 "dtc-parser.y" /* yacc.c:1646 */
1958 { 1976 {
1959 if ((yyvsp[0].integer) != 0) { 1977 if ((yyvsp[0].integer) != 0) {
1960 (yyval.integer) = (yyvsp[-2].integer) % (yyvsp[0].integer); 1978 (yyval.integer) = (yyvsp[-2].integer) % (yyvsp[0].integer);
@@ -1963,103 +1981,103 @@ yyreduce:
1963 (yyval.integer) = 0; 1981 (yyval.integer) = 0;
1964 } 1982 }
1965 } 1983 }
1966#line 1967 "dtc-parser.tab.c" /* yacc.c:1646 */ 1984#line 1985 "dtc-parser.tab.c" /* yacc.c:1646 */
1967 break; 1985 break;
1968 1986
1969 case 73: 1987 case 74:
1970#line 462 "dtc-parser.y" /* yacc.c:1646 */ 1988#line 476 "dtc-parser.y" /* yacc.c:1646 */
1971 { (yyval.integer) = -(yyvsp[0].integer); } 1989 { (yyval.integer) = -(yyvsp[0].integer); }
1972#line 1973 "dtc-parser.tab.c" /* yacc.c:1646 */ 1990#line 1991 "dtc-parser.tab.c" /* yacc.c:1646 */
1973 break; 1991 break;
1974 1992
1975 case 74: 1993 case 75:
1976#line 463 "dtc-parser.y" /* yacc.c:1646 */ 1994#line 477 "dtc-parser.y" /* yacc.c:1646 */
1977 { (yyval.integer) = ~(yyvsp[0].integer); } 1995 { (yyval.integer) = ~(yyvsp[0].integer); }
1978#line 1979 "dtc-parser.tab.c" /* yacc.c:1646 */ 1996#line 1997 "dtc-parser.tab.c" /* yacc.c:1646 */
1979 break; 1997 break;
1980 1998
1981 case 75: 1999 case 76:
1982#line 464 "dtc-parser.y" /* yacc.c:1646 */ 2000#line 478 "dtc-parser.y" /* yacc.c:1646 */
1983 { (yyval.integer) = !(yyvsp[0].integer); } 2001 { (yyval.integer) = !(yyvsp[0].integer); }
1984#line 1985 "dtc-parser.tab.c" /* yacc.c:1646 */ 2002#line 2003 "dtc-parser.tab.c" /* yacc.c:1646 */
1985 break; 2003 break;
1986 2004
1987 case 76: 2005 case 77:
1988#line 469 "dtc-parser.y" /* yacc.c:1646 */ 2006#line 483 "dtc-parser.y" /* yacc.c:1646 */
1989 { 2007 {
1990 (yyval.data) = empty_data; 2008 (yyval.data) = empty_data;
1991 } 2009 }
1992#line 1993 "dtc-parser.tab.c" /* yacc.c:1646 */ 2010#line 2011 "dtc-parser.tab.c" /* yacc.c:1646 */
1993 break; 2011 break;
1994 2012
1995 case 77: 2013 case 78:
1996#line 473 "dtc-parser.y" /* yacc.c:1646 */ 2014#line 487 "dtc-parser.y" /* yacc.c:1646 */
1997 { 2015 {
1998 (yyval.data) = data_append_byte((yyvsp[-1].data), (yyvsp[0].byte)); 2016 (yyval.data) = data_append_byte((yyvsp[-1].data), (yyvsp[0].byte));
1999 } 2017 }
2000#line 2001 "dtc-parser.tab.c" /* yacc.c:1646 */ 2018#line 2019 "dtc-parser.tab.c" /* yacc.c:1646 */
2001 break; 2019 break;
2002 2020
2003 case 78: 2021 case 79:
2004#line 477 "dtc-parser.y" /* yacc.c:1646 */ 2022#line 491 "dtc-parser.y" /* yacc.c:1646 */
2005 { 2023 {
2006 (yyval.data) = data_add_marker((yyvsp[-1].data), LABEL, (yyvsp[0].labelref)); 2024 (yyval.data) = data_add_marker((yyvsp[-1].data), LABEL, (yyvsp[0].labelref));
2007 } 2025 }
2008#line 2009 "dtc-parser.tab.c" /* yacc.c:1646 */ 2026#line 2027 "dtc-parser.tab.c" /* yacc.c:1646 */
2009 break; 2027 break;
2010 2028
2011 case 79: 2029 case 80:
2012#line 484 "dtc-parser.y" /* yacc.c:1646 */ 2030#line 498 "dtc-parser.y" /* yacc.c:1646 */
2013 { 2031 {
2014 (yyval.nodelist) = NULL; 2032 (yyval.nodelist) = NULL;
2015 } 2033 }
2016#line 2017 "dtc-parser.tab.c" /* yacc.c:1646 */ 2034#line 2035 "dtc-parser.tab.c" /* yacc.c:1646 */
2017 break; 2035 break;
2018 2036
2019 case 80: 2037 case 81:
2020#line 488 "dtc-parser.y" /* yacc.c:1646 */ 2038#line 502 "dtc-parser.y" /* yacc.c:1646 */
2021 { 2039 {
2022 (yyval.nodelist) = chain_node((yyvsp[-1].node), (yyvsp[0].nodelist)); 2040 (yyval.nodelist) = chain_node((yyvsp[-1].node), (yyvsp[0].nodelist));
2023 } 2041 }
2024#line 2025 "dtc-parser.tab.c" /* yacc.c:1646 */ 2042#line 2043 "dtc-parser.tab.c" /* yacc.c:1646 */
2025 break; 2043 break;
2026 2044
2027 case 81: 2045 case 82:
2028#line 492 "dtc-parser.y" /* yacc.c:1646 */ 2046#line 506 "dtc-parser.y" /* yacc.c:1646 */
2029 { 2047 {
2030 ERROR(&(yylsp[0]), "Properties must precede subnodes"); 2048 ERROR(&(yylsp[0]), "Properties must precede subnodes");
2031 YYERROR; 2049 YYERROR;
2032 } 2050 }
2033#line 2034 "dtc-parser.tab.c" /* yacc.c:1646 */ 2051#line 2052 "dtc-parser.tab.c" /* yacc.c:1646 */
2034 break; 2052 break;
2035 2053
2036 case 82: 2054 case 83:
2037#line 500 "dtc-parser.y" /* yacc.c:1646 */ 2055#line 514 "dtc-parser.y" /* yacc.c:1646 */
2038 { 2056 {
2039 (yyval.node) = name_node((yyvsp[0].node), (yyvsp[-1].propnodename)); 2057 (yyval.node) = name_node((yyvsp[0].node), (yyvsp[-1].propnodename));
2040 } 2058 }
2041#line 2042 "dtc-parser.tab.c" /* yacc.c:1646 */ 2059#line 2060 "dtc-parser.tab.c" /* yacc.c:1646 */
2042 break; 2060 break;
2043 2061
2044 case 83: 2062 case 84:
2045#line 504 "dtc-parser.y" /* yacc.c:1646 */ 2063#line 518 "dtc-parser.y" /* yacc.c:1646 */
2046 { 2064 {
2047 (yyval.node) = name_node(build_node_delete(), (yyvsp[-1].propnodename)); 2065 (yyval.node) = name_node(build_node_delete(), (yyvsp[-1].propnodename));
2048 } 2066 }
2049#line 2050 "dtc-parser.tab.c" /* yacc.c:1646 */ 2067#line 2068 "dtc-parser.tab.c" /* yacc.c:1646 */
2050 break; 2068 break;
2051 2069
2052 case 84: 2070 case 85:
2053#line 508 "dtc-parser.y" /* yacc.c:1646 */ 2071#line 522 "dtc-parser.y" /* yacc.c:1646 */
2054 { 2072 {
2055 add_label(&(yyvsp[0].node)->labels, (yyvsp[-1].labelref)); 2073 add_label(&(yyvsp[0].node)->labels, (yyvsp[-1].labelref));
2056 (yyval.node) = (yyvsp[0].node); 2074 (yyval.node) = (yyvsp[0].node);
2057 } 2075 }
2058#line 2059 "dtc-parser.tab.c" /* yacc.c:1646 */ 2076#line 2077 "dtc-parser.tab.c" /* yacc.c:1646 */
2059 break; 2077 break;
2060 2078
2061 2079
2062#line 2063 "dtc-parser.tab.c" /* yacc.c:1646 */ 2080#line 2081 "dtc-parser.tab.c" /* yacc.c:1646 */
2063 default: break; 2081 default: break;
2064 } 2082 }
2065 /* User semantic actions sometimes alter yychar, and that requires 2083 /* User semantic actions sometimes alter yychar, and that requires
@@ -2294,7 +2312,7 @@ yyreturn:
2294#endif 2312#endif
2295 return yyresult; 2313 return yyresult;
2296} 2314}
2297#line 514 "dtc-parser.y" /* yacc.c:1906 */ 2315#line 528 "dtc-parser.y" /* yacc.c:1906 */
2298 2316
2299 2317
2300void yyerror(char const *s) 2318void yyerror(char const *s)
diff --git a/scripts/dtc/dtc-parser.y b/scripts/dtc/dtc-parser.y
index ca3f5003427c..affc81a8f9ab 100644
--- a/scripts/dtc/dtc-parser.y
+++ b/scripts/dtc/dtc-parser.y
@@ -182,10 +182,19 @@ devicetree:
182 { 182 {
183 struct node *target = get_node_by_ref($1, $2); 183 struct node *target = get_node_by_ref($1, $2);
184 184
185 if (target) 185 if (target) {
186 merge_nodes(target, $3); 186 merge_nodes(target, $3);
187 else 187 } else {
188 ERROR(&@2, "Label or path %s not found", $2); 188 /*
189 * We rely on the rule being always:
190 * versioninfo plugindecl memreserves devicetree
191 * so $-1 is what we want (plugindecl)
192 */
193 if ($<flags>-1 & DTSF_PLUGIN)
194 add_orphan_node($1, $3, $2);
195 else
196 ERROR(&@2, "Label or path %s not found", $2);
197 }
189 $$ = $1; 198 $$ = $1;
190 } 199 }
191 | devicetree DT_DEL_NODE DT_REF ';' 200 | devicetree DT_DEL_NODE DT_REF ';'
@@ -200,6 +209,11 @@ devicetree:
200 209
201 $$ = $1; 210 $$ = $1;
202 } 211 }
212 | /* empty */
213 {
214 /* build empty node */
215 $$ = name_node(build_node(NULL, NULL), "");
216 }
203 ; 217 ;
204 218
205nodedef: 219nodedef:
diff --git a/scripts/dtc/dtc.c b/scripts/dtc/dtc.c
index f5eed9d72c02..5ed873c72ad1 100644
--- a/scripts/dtc/dtc.c
+++ b/scripts/dtc/dtc.c
@@ -31,7 +31,7 @@ int reservenum; /* Number of memory reservation slots */
31int minsize; /* Minimum blob size */ 31int minsize; /* Minimum blob size */
32int padsize; /* Additional padding to blob */ 32int padsize; /* Additional padding to blob */
33int alignsize; /* Additional padding to blob accroding to the alignsize */ 33int alignsize; /* Additional padding to blob accroding to the alignsize */
34int phandle_format = PHANDLE_BOTH; /* Use linux,phandle or phandle properties */ 34int phandle_format = PHANDLE_EPAPR; /* Use linux,phandle or phandle properties */
35int generate_symbols; /* enable symbols & fixup support */ 35int generate_symbols; /* enable symbols & fixup support */
36int generate_fixups; /* suppress generation of fixups on symbol support */ 36int generate_fixups; /* suppress generation of fixups on symbol support */
37int auto_label_aliases; /* auto generate labels -> aliases */ 37int auto_label_aliases; /* auto generate labels -> aliases */
diff --git a/scripts/dtc/dtc.h b/scripts/dtc/dtc.h
index fc24e17510fd..35cf926cc14a 100644
--- a/scripts/dtc/dtc.h
+++ b/scripts/dtc/dtc.h
@@ -31,6 +31,7 @@
31#include <ctype.h> 31#include <ctype.h>
32#include <errno.h> 32#include <errno.h>
33#include <unistd.h> 33#include <unistd.h>
34#include <inttypes.h>
34 35
35#include <libfdt_env.h> 36#include <libfdt_env.h>
36#include <fdt.h> 37#include <fdt.h>
@@ -202,6 +203,7 @@ struct node *build_node_delete(void);
202struct node *name_node(struct node *node, char *name); 203struct node *name_node(struct node *node, char *name);
203struct node *chain_node(struct node *first, struct node *list); 204struct node *chain_node(struct node *first, struct node *list);
204struct node *merge_nodes(struct node *old_node, struct node *new_node); 205struct node *merge_nodes(struct node *old_node, struct node *new_node);
206void add_orphan_node(struct node *old_node, struct node *new_node, char *ref);
205 207
206void add_property(struct node *node, struct property *prop); 208void add_property(struct node *node, struct property *prop);
207void delete_property_by_name(struct node *node, char *name); 209void delete_property_by_name(struct node *node, char *name);
@@ -215,6 +217,7 @@ void append_to_property(struct node *node,
215const char *get_unitname(struct node *node); 217const char *get_unitname(struct node *node);
216struct property *get_property(struct node *node, const char *propname); 218struct property *get_property(struct node *node, const char *propname);
217cell_t propval_cell(struct property *prop); 219cell_t propval_cell(struct property *prop);
220cell_t propval_cell_n(struct property *prop, int n);
218struct property *get_property_by_label(struct node *tree, const char *label, 221struct property *get_property_by_label(struct node *tree, const char *label,
219 struct node **node); 222 struct node **node);
220struct marker *get_marker_label(struct node *tree, const char *label, 223struct marker *get_marker_label(struct node *tree, const char *label,
diff --git a/scripts/dtc/dtx_diff b/scripts/dtc/dtx_diff
index f9a3d8d23c64..8c4fbad2055e 100755
--- a/scripts/dtc/dtx_diff
+++ b/scripts/dtc/dtx_diff
@@ -86,6 +86,7 @@ eod
86compile_to_dts() { 86compile_to_dts() {
87 87
88 dtx="$1" 88 dtx="$1"
89 dtc_include="$2"
89 90
90 if [ -d "${dtx}" ] ; then 91 if [ -d "${dtx}" ] ; then
91 92
@@ -113,7 +114,7 @@ compile_to_dts() {
113 # ----- input is DTS (source) 114 # ----- input is DTS (source)
114 115
115 if ( cpp ${cpp_flags} -x assembler-with-cpp ${dtx} \ 116 if ( cpp ${cpp_flags} -x assembler-with-cpp ${dtx} \
116 | ${DTC} -I dts ) ; then 117 | ${DTC} ${dtc_include} -I dts ) ; then
117 return 118 return
118 fi 119 fi
119 120
@@ -320,18 +321,13 @@ fi
320 321
321cpp_flags="\ 322cpp_flags="\
322 -nostdinc \ 323 -nostdinc \
323 -I${srctree}/arch/${ARCH}/boot/dts \
324 -I${srctree}/scripts/dtc/include-prefixes \ 324 -I${srctree}/scripts/dtc/include-prefixes \
325 -I${srctree}/drivers/of/testcase-data \
326 -undef -D__DTS__" 325 -undef -D__DTS__"
327 326
328dtc_flags="\ 327DTC="\
329 -i ${srctree}/arch/${ARCH}/boot/dts/ \ 328 ${DTC} \
330 -i ${srctree}/kernel/dts \ 329 -i ${srctree}/scripts/dtc/include-prefixes \
331 ${dtx_path_1_dtc_include} \ 330 -O dts -qq -f ${dtc_sort} -o -"
332 ${dtx_path_2_dtc_include}"
333
334DTC="${DTC} ${dtc_flags} -O dts -qq -f ${dtc_sort} -o -"
335 331
336 332
337# ----- do the diff or decompile 333# ----- do the diff or decompile
@@ -339,11 +335,11 @@ DTC="${DTC} ${dtc_flags} -O dts -qq -f ${dtc_sort} -o -"
339if (( ${cmd_diff} )) ; then 335if (( ${cmd_diff} )) ; then
340 336
341 diff ${diff_flags} --label "${dtx_file_1}" --label "${dtx_file_2}" \ 337 diff ${diff_flags} --label "${dtx_file_1}" --label "${dtx_file_2}" \
342 <(compile_to_dts "${dtx_file_1}") \ 338 <(compile_to_dts "${dtx_file_1}" "${dtx_path_1_dtc_include}") \
343 <(compile_to_dts "${dtx_file_2}") 339 <(compile_to_dts "${dtx_file_2}" "${dtx_path_2_dtc_include}")
344 340
345else 341else
346 342
347 compile_to_dts "${dtx_file_1}" 343 compile_to_dts "${dtx_file_1}" "${dtx_path_1_dtc_include}"
348 344
349fi 345fi
diff --git a/scripts/dtc/fdtdump.c b/scripts/dtc/fdtdump.c
index 207a46d64864..7d460a50b513 100644
--- a/scripts/dtc/fdtdump.c
+++ b/scripts/dtc/fdtdump.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * fdtdump.c - Contributed by Pantelis Antoniou <pantelis.antoniou AT gmail.com> 3 * fdtdump.c - Contributed by Pantelis Antoniou <pantelis.antoniou AT gmail.com>
3 */ 4 */
diff --git a/scripts/dtc/libfdt/fdt_addresses.c b/scripts/dtc/libfdt/fdt_addresses.c
new file mode 100644
index 000000000000..eff4dbcc729d
--- /dev/null
+++ b/scripts/dtc/libfdt/fdt_addresses.c
@@ -0,0 +1,96 @@
1/*
2 * libfdt - Flat Device Tree manipulation
3 * Copyright (C) 2014 David Gibson <david@gibson.dropbear.id.au>
4 *
5 * libfdt is dual licensed: you can use it either under the terms of
6 * the GPL, or the BSD license, at your option.
7 *
8 * a) This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this library; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
21 * MA 02110-1301 USA
22 *
23 * Alternatively,
24 *
25 * b) Redistribution and use in source and binary forms, with or
26 * without modification, are permitted provided that the following
27 * conditions are met:
28 *
29 * 1. Redistributions of source code must retain the above
30 * copyright notice, this list of conditions and the following
31 * disclaimer.
32 * 2. Redistributions in binary form must reproduce the above
33 * copyright notice, this list of conditions and the following
34 * disclaimer in the documentation and/or other materials
35 * provided with the distribution.
36 *
37 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
38 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
39 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
40 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
42 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
48 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
49 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50 */
51#include "libfdt_env.h"
52
53#include <fdt.h>
54#include <libfdt.h>
55
56#include "libfdt_internal.h"
57
58int fdt_address_cells(const void *fdt, int nodeoffset)
59{
60 const fdt32_t *ac;
61 int val;
62 int len;
63
64 ac = fdt_getprop(fdt, nodeoffset, "#address-cells", &len);
65 if (!ac)
66 return 2;
67
68 if (len != sizeof(*ac))
69 return -FDT_ERR_BADNCELLS;
70
71 val = fdt32_to_cpu(*ac);
72 if ((val <= 0) || (val > FDT_MAX_NCELLS))
73 return -FDT_ERR_BADNCELLS;
74
75 return val;
76}
77
78int fdt_size_cells(const void *fdt, int nodeoffset)
79{
80 const fdt32_t *sc;
81 int val;
82 int len;
83
84 sc = fdt_getprop(fdt, nodeoffset, "#size-cells", &len);
85 if (!sc)
86 return 2;
87
88 if (len != sizeof(*sc))
89 return -FDT_ERR_BADNCELLS;
90
91 val = fdt32_to_cpu(*sc);
92 if ((val < 0) || (val > FDT_MAX_NCELLS))
93 return -FDT_ERR_BADNCELLS;
94
95 return val;
96}
diff --git a/scripts/dtc/libfdt/fdt_empty_tree.c b/scripts/dtc/libfdt/fdt_empty_tree.c
index f72d13b1d19c..f2ae9b77c285 100644
--- a/scripts/dtc/libfdt/fdt_empty_tree.c
+++ b/scripts/dtc/libfdt/fdt_empty_tree.c
@@ -81,4 +81,3 @@ int fdt_create_empty_tree(void *buf, int bufsize)
81 81
82 return fdt_open_into(buf, buf, bufsize); 82 return fdt_open_into(buf, buf, bufsize);
83} 83}
84
diff --git a/scripts/dtc/libfdt/fdt_overlay.c b/scripts/dtc/libfdt/fdt_overlay.c
new file mode 100644
index 000000000000..bd81241e6658
--- /dev/null
+++ b/scripts/dtc/libfdt/fdt_overlay.c
@@ -0,0 +1,861 @@
1#include "libfdt_env.h"
2
3#include <fdt.h>
4#include <libfdt.h>
5
6#include "libfdt_internal.h"
7
8/**
9 * overlay_get_target_phandle - retrieves the target phandle of a fragment
10 * @fdto: pointer to the device tree overlay blob
11 * @fragment: node offset of the fragment in the overlay
12 *
13 * overlay_get_target_phandle() retrieves the target phandle of an
14 * overlay fragment when that fragment uses a phandle (target
15 * property) instead of a path (target-path property).
16 *
17 * returns:
18 * the phandle pointed by the target property
19 * 0, if the phandle was not found
20 * -1, if the phandle was malformed
21 */
22static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)
23{
24 const fdt32_t *val;
25 int len;
26
27 val = fdt_getprop(fdto, fragment, "target", &len);
28 if (!val)
29 return 0;
30
31 if ((len != sizeof(*val)) || (fdt32_to_cpu(*val) == (uint32_t)-1))
32 return (uint32_t)-1;
33
34 return fdt32_to_cpu(*val);
35}
36
37/**
38 * overlay_get_target - retrieves the offset of a fragment's target
39 * @fdt: Base device tree blob
40 * @fdto: Device tree overlay blob
41 * @fragment: node offset of the fragment in the overlay
42 * @pathp: pointer which receives the path of the target (or NULL)
43 *
44 * overlay_get_target() retrieves the target offset in the base
45 * device tree of a fragment, no matter how the actual targetting is
46 * done (through a phandle or a path)
47 *
48 * returns:
49 * the targetted node offset in the base device tree
50 * Negative error code on error
51 */
52static int overlay_get_target(const void *fdt, const void *fdto,
53 int fragment, char const **pathp)
54{
55 uint32_t phandle;
56 const char *path = NULL;
57 int path_len = 0, ret;
58
59 /* Try first to do a phandle based lookup */
60 phandle = overlay_get_target_phandle(fdto, fragment);
61 if (phandle == (uint32_t)-1)
62 return -FDT_ERR_BADPHANDLE;
63
64 /* no phandle, try path */
65 if (!phandle) {
66 /* And then a path based lookup */
67 path = fdt_getprop(fdto, fragment, "target-path", &path_len);
68 if (path)
69 ret = fdt_path_offset(fdt, path);
70 else
71 ret = path_len;
72 } else
73 ret = fdt_node_offset_by_phandle(fdt, phandle);
74
75 /*
76 * If we haven't found either a target or a
77 * target-path property in a node that contains a
78 * __overlay__ subnode (we wouldn't be called
79 * otherwise), consider it a improperly written
80 * overlay
81 */
82 if (ret < 0 && path_len == -FDT_ERR_NOTFOUND)
83 ret = -FDT_ERR_BADOVERLAY;
84
85 /* return on error */
86 if (ret < 0)
87 return ret;
88
89 /* return pointer to path (if available) */
90 if (pathp)
91 *pathp = path ? path : NULL;
92
93 return ret;
94}
95
96/**
97 * overlay_phandle_add_offset - Increases a phandle by an offset
98 * @fdt: Base device tree blob
99 * @node: Device tree overlay blob
100 * @name: Name of the property to modify (phandle or linux,phandle)
101 * @delta: offset to apply
102 *
103 * overlay_phandle_add_offset() increments a node phandle by a given
104 * offset.
105 *
106 * returns:
107 * 0 on success.
108 * Negative error code on error
109 */
110static int overlay_phandle_add_offset(void *fdt, int node,
111 const char *name, uint32_t delta)
112{
113 const fdt32_t *val;
114 uint32_t adj_val;
115 int len;
116
117 val = fdt_getprop(fdt, node, name, &len);
118 if (!val)
119 return len;
120
121 if (len != sizeof(*val))
122 return -FDT_ERR_BADPHANDLE;
123
124 adj_val = fdt32_to_cpu(*val);
125 if ((adj_val + delta) < adj_val)
126 return -FDT_ERR_NOPHANDLES;
127
128 adj_val += delta;
129 if (adj_val == (uint32_t)-1)
130 return -FDT_ERR_NOPHANDLES;
131
132 return fdt_setprop_inplace_u32(fdt, node, name, adj_val);
133}
134
135/**
136 * overlay_adjust_node_phandles - Offsets the phandles of a node
137 * @fdto: Device tree overlay blob
138 * @node: Offset of the node we want to adjust
139 * @delta: Offset to shift the phandles of
140 *
141 * overlay_adjust_node_phandles() adds a constant to all the phandles
142 * of a given node. This is mainly use as part of the overlay
143 * application process, when we want to update all the overlay
144 * phandles to not conflict with the overlays of the base device tree.
145 *
146 * returns:
147 * 0 on success
148 * Negative error code on failure
149 */
150static int overlay_adjust_node_phandles(void *fdto, int node,
151 uint32_t delta)
152{
153 int child;
154 int ret;
155
156 ret = overlay_phandle_add_offset(fdto, node, "phandle", delta);
157 if (ret && ret != -FDT_ERR_NOTFOUND)
158 return ret;
159
160 ret = overlay_phandle_add_offset(fdto, node, "linux,phandle", delta);
161 if (ret && ret != -FDT_ERR_NOTFOUND)
162 return ret;
163
164 fdt_for_each_subnode(child, fdto, node) {
165 ret = overlay_adjust_node_phandles(fdto, child, delta);
166 if (ret)
167 return ret;
168 }
169
170 return 0;
171}
172
173/**
174 * overlay_adjust_local_phandles - Adjust the phandles of a whole overlay
175 * @fdto: Device tree overlay blob
176 * @delta: Offset to shift the phandles of
177 *
178 * overlay_adjust_local_phandles() adds a constant to all the
179 * phandles of an overlay. This is mainly use as part of the overlay
180 * application process, when we want to update all the overlay
181 * phandles to not conflict with the overlays of the base device tree.
182 *
183 * returns:
184 * 0 on success
185 * Negative error code on failure
186 */
187static int overlay_adjust_local_phandles(void *fdto, uint32_t delta)
188{
189 /*
190 * Start adjusting the phandles from the overlay root
191 */
192 return overlay_adjust_node_phandles(fdto, 0, delta);
193}
194
195/**
196 * overlay_update_local_node_references - Adjust the overlay references
197 * @fdto: Device tree overlay blob
198 * @tree_node: Node offset of the node to operate on
199 * @fixup_node: Node offset of the matching local fixups node
200 * @delta: Offset to shift the phandles of
201 *
202 * overlay_update_local_nodes_references() update the phandles
203 * pointing to a node within the device tree overlay by adding a
204 * constant delta.
205 *
206 * This is mainly used as part of a device tree application process,
207 * where you want the device tree overlays phandles to not conflict
208 * with the ones from the base device tree before merging them.
209 *
210 * returns:
211 * 0 on success
212 * Negative error code on failure
213 */
214static int overlay_update_local_node_references(void *fdto,
215 int tree_node,
216 int fixup_node,
217 uint32_t delta)
218{
219 int fixup_prop;
220 int fixup_child;
221 int ret;
222
223 fdt_for_each_property_offset(fixup_prop, fdto, fixup_node) {
224 const fdt32_t *fixup_val;
225 const char *tree_val;
226 const char *name;
227 int fixup_len;
228 int tree_len;
229 int i;
230
231 fixup_val = fdt_getprop_by_offset(fdto, fixup_prop,
232 &name, &fixup_len);
233 if (!fixup_val)
234 return fixup_len;
235
236 if (fixup_len % sizeof(uint32_t))
237 return -FDT_ERR_BADOVERLAY;
238
239 tree_val = fdt_getprop(fdto, tree_node, name, &tree_len);
240 if (!tree_val) {
241 if (tree_len == -FDT_ERR_NOTFOUND)
242 return -FDT_ERR_BADOVERLAY;
243
244 return tree_len;
245 }
246
247 for (i = 0; i < (fixup_len / sizeof(uint32_t)); i++) {
248 fdt32_t adj_val;
249 uint32_t poffset;
250
251 poffset = fdt32_to_cpu(fixup_val[i]);
252
253 /*
254 * phandles to fixup can be unaligned.
255 *
256 * Use a memcpy for the architectures that do
257 * not support unaligned accesses.
258 */
259 memcpy(&adj_val, tree_val + poffset, sizeof(adj_val));
260
261 adj_val = cpu_to_fdt32(fdt32_to_cpu(adj_val) + delta);
262
263 ret = fdt_setprop_inplace_namelen_partial(fdto,
264 tree_node,
265 name,
266 strlen(name),
267 poffset,
268 &adj_val,
269 sizeof(adj_val));
270 if (ret == -FDT_ERR_NOSPACE)
271 return -FDT_ERR_BADOVERLAY;
272
273 if (ret)
274 return ret;
275 }
276 }
277
278 fdt_for_each_subnode(fixup_child, fdto, fixup_node) {
279 const char *fixup_child_name = fdt_get_name(fdto, fixup_child,
280 NULL);
281 int tree_child;
282
283 tree_child = fdt_subnode_offset(fdto, tree_node,
284 fixup_child_name);
285 if (tree_child == -FDT_ERR_NOTFOUND)
286 return -FDT_ERR_BADOVERLAY;
287 if (tree_child < 0)
288 return tree_child;
289
290 ret = overlay_update_local_node_references(fdto,
291 tree_child,
292 fixup_child,
293 delta);
294 if (ret)
295 return ret;
296 }
297
298 return 0;
299}
300
301/**
302 * overlay_update_local_references - Adjust the overlay references
303 * @fdto: Device tree overlay blob
304 * @delta: Offset to shift the phandles of
305 *
306 * overlay_update_local_references() update all the phandles pointing
307 * to a node within the device tree overlay by adding a constant
308 * delta to not conflict with the base overlay.
309 *
310 * This is mainly used as part of a device tree application process,
311 * where you want the device tree overlays phandles to not conflict
312 * with the ones from the base device tree before merging them.
313 *
314 * returns:
315 * 0 on success
316 * Negative error code on failure
317 */
318static int overlay_update_local_references(void *fdto, uint32_t delta)
319{
320 int fixups;
321
322 fixups = fdt_path_offset(fdto, "/__local_fixups__");
323 if (fixups < 0) {
324 /* There's no local phandles to adjust, bail out */
325 if (fixups == -FDT_ERR_NOTFOUND)
326 return 0;
327
328 return fixups;
329 }
330
331 /*
332 * Update our local references from the root of the tree
333 */
334 return overlay_update_local_node_references(fdto, 0, fixups,
335 delta);
336}
337
338/**
339 * overlay_fixup_one_phandle - Set an overlay phandle to the base one
340 * @fdt: Base Device Tree blob
341 * @fdto: Device tree overlay blob
342 * @symbols_off: Node offset of the symbols node in the base device tree
343 * @path: Path to a node holding a phandle in the overlay
344 * @path_len: number of path characters to consider
345 * @name: Name of the property holding the phandle reference in the overlay
346 * @name_len: number of name characters to consider
347 * @poffset: Offset within the overlay property where the phandle is stored
348 * @label: Label of the node referenced by the phandle
349 *
350 * overlay_fixup_one_phandle() resolves an overlay phandle pointing to
351 * a node in the base device tree.
352 *
353 * This is part of the device tree overlay application process, when
354 * you want all the phandles in the overlay to point to the actual
355 * base dt nodes.
356 *
357 * returns:
358 * 0 on success
359 * Negative error code on failure
360 */
361static int overlay_fixup_one_phandle(void *fdt, void *fdto,
362 int symbols_off,
363 const char *path, uint32_t path_len,
364 const char *name, uint32_t name_len,
365 int poffset, const char *label)
366{
367 const char *symbol_path;
368 uint32_t phandle;
369 fdt32_t phandle_prop;
370 int symbol_off, fixup_off;
371 int prop_len;
372
373 if (symbols_off < 0)
374 return symbols_off;
375
376 symbol_path = fdt_getprop(fdt, symbols_off, label,
377 &prop_len);
378 if (!symbol_path)
379 return prop_len;
380
381 symbol_off = fdt_path_offset(fdt, symbol_path);
382 if (symbol_off < 0)
383 return symbol_off;
384
385 phandle = fdt_get_phandle(fdt, symbol_off);
386 if (!phandle)
387 return -FDT_ERR_NOTFOUND;
388
389 fixup_off = fdt_path_offset_namelen(fdto, path, path_len);
390 if (fixup_off == -FDT_ERR_NOTFOUND)
391 return -FDT_ERR_BADOVERLAY;
392 if (fixup_off < 0)
393 return fixup_off;
394
395 phandle_prop = cpu_to_fdt32(phandle);
396 return fdt_setprop_inplace_namelen_partial(fdto, fixup_off,
397 name, name_len, poffset,
398 &phandle_prop,
399 sizeof(phandle_prop));
400};
401
402/**
403 * overlay_fixup_phandle - Set an overlay phandle to the base one
404 * @fdt: Base Device Tree blob
405 * @fdto: Device tree overlay blob
406 * @symbols_off: Node offset of the symbols node in the base device tree
407 * @property: Property offset in the overlay holding the list of fixups
408 *
409 * overlay_fixup_phandle() resolves all the overlay phandles pointed
410 * to in a __fixups__ property, and updates them to match the phandles
411 * in use in the base device tree.
412 *
413 * This is part of the device tree overlay application process, when
414 * you want all the phandles in the overlay to point to the actual
415 * base dt nodes.
416 *
417 * returns:
418 * 0 on success
419 * Negative error code on failure
420 */
421static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
422 int property)
423{
424 const char *value;
425 const char *label;
426 int len;
427
428 value = fdt_getprop_by_offset(fdto, property,
429 &label, &len);
430 if (!value) {
431 if (len == -FDT_ERR_NOTFOUND)
432 return -FDT_ERR_INTERNAL;
433
434 return len;
435 }
436
437 do {
438 const char *path, *name, *fixup_end;
439 const char *fixup_str = value;
440 uint32_t path_len, name_len;
441 uint32_t fixup_len;
442 char *sep, *endptr;
443 int poffset, ret;
444
445 fixup_end = memchr(value, '\0', len);
446 if (!fixup_end)
447 return -FDT_ERR_BADOVERLAY;
448 fixup_len = fixup_end - fixup_str;
449
450 len -= fixup_len + 1;
451 value += fixup_len + 1;
452
453 path = fixup_str;
454 sep = memchr(fixup_str, ':', fixup_len);
455 if (!sep || *sep != ':')
456 return -FDT_ERR_BADOVERLAY;
457
458 path_len = sep - path;
459 if (path_len == (fixup_len - 1))
460 return -FDT_ERR_BADOVERLAY;
461
462 fixup_len -= path_len + 1;
463 name = sep + 1;
464 sep = memchr(name, ':', fixup_len);
465 if (!sep || *sep != ':')
466 return -FDT_ERR_BADOVERLAY;
467
468 name_len = sep - name;
469 if (!name_len)
470 return -FDT_ERR_BADOVERLAY;
471
472 poffset = strtoul(sep + 1, &endptr, 10);
473 if ((*endptr != '\0') || (endptr <= (sep + 1)))
474 return -FDT_ERR_BADOVERLAY;
475
476 ret = overlay_fixup_one_phandle(fdt, fdto, symbols_off,
477 path, path_len, name, name_len,
478 poffset, label);
479 if (ret)
480 return ret;
481 } while (len > 0);
482
483 return 0;
484}
485
486/**
487 * overlay_fixup_phandles - Resolve the overlay phandles to the base
488 * device tree
489 * @fdt: Base Device Tree blob
490 * @fdto: Device tree overlay blob
491 *
492 * overlay_fixup_phandles() resolves all the overlay phandles pointing
493 * to nodes in the base device tree.
494 *
495 * This is one of the steps of the device tree overlay application
496 * process, when you want all the phandles in the overlay to point to
497 * the actual base dt nodes.
498 *
499 * returns:
500 * 0 on success
501 * Negative error code on failure
502 */
503static int overlay_fixup_phandles(void *fdt, void *fdto)
504{
505 int fixups_off, symbols_off;
506 int property;
507
508 /* We can have overlays without any fixups */
509 fixups_off = fdt_path_offset(fdto, "/__fixups__");
510 if (fixups_off == -FDT_ERR_NOTFOUND)
511 return 0; /* nothing to do */
512 if (fixups_off < 0)
513 return fixups_off;
514
515 /* And base DTs without symbols */
516 symbols_off = fdt_path_offset(fdt, "/__symbols__");
517 if ((symbols_off < 0 && (symbols_off != -FDT_ERR_NOTFOUND)))
518 return symbols_off;
519
520 fdt_for_each_property_offset(property, fdto, fixups_off) {
521 int ret;
522
523 ret = overlay_fixup_phandle(fdt, fdto, symbols_off, property);
524 if (ret)
525 return ret;
526 }
527
528 return 0;
529}
530
531/**
532 * overlay_apply_node - Merges a node into the base device tree
533 * @fdt: Base Device Tree blob
534 * @target: Node offset in the base device tree to apply the fragment to
535 * @fdto: Device tree overlay blob
536 * @node: Node offset in the overlay holding the changes to merge
537 *
538 * overlay_apply_node() merges a node into a target base device tree
539 * node pointed.
540 *
541 * This is part of the final step in the device tree overlay
542 * application process, when all the phandles have been adjusted and
543 * resolved and you just have to merge overlay into the base device
544 * tree.
545 *
546 * returns:
547 * 0 on success
548 * Negative error code on failure
549 */
550static int overlay_apply_node(void *fdt, int target,
551 void *fdto, int node)
552{
553 int property;
554 int subnode;
555
556 fdt_for_each_property_offset(property, fdto, node) {
557 const char *name;
558 const void *prop;
559 int prop_len;
560 int ret;
561
562 prop = fdt_getprop_by_offset(fdto, property, &name,
563 &prop_len);
564 if (prop_len == -FDT_ERR_NOTFOUND)
565 return -FDT_ERR_INTERNAL;
566 if (prop_len < 0)
567 return prop_len;
568
569 ret = fdt_setprop(fdt, target, name, prop, prop_len);
570 if (ret)
571 return ret;
572 }
573
574 fdt_for_each_subnode(subnode, fdto, node) {
575 const char *name = fdt_get_name(fdto, subnode, NULL);
576 int nnode;
577 int ret;
578
579 nnode = fdt_add_subnode(fdt, target, name);
580 if (nnode == -FDT_ERR_EXISTS) {
581 nnode = fdt_subnode_offset(fdt, target, name);
582 if (nnode == -FDT_ERR_NOTFOUND)
583 return -FDT_ERR_INTERNAL;
584 }
585
586 if (nnode < 0)
587 return nnode;
588
589 ret = overlay_apply_node(fdt, nnode, fdto, subnode);
590 if (ret)
591 return ret;
592 }
593
594 return 0;
595}
596
597/**
598 * overlay_merge - Merge an overlay into its base device tree
599 * @fdt: Base Device Tree blob
600 * @fdto: Device tree overlay blob
601 *
602 * overlay_merge() merges an overlay into its base device tree.
603 *
604 * This is the next to last step in the device tree overlay application
605 * process, when all the phandles have been adjusted and resolved and
606 * you just have to merge overlay into the base device tree.
607 *
608 * returns:
609 * 0 on success
610 * Negative error code on failure
611 */
612static int overlay_merge(void *fdt, void *fdto)
613{
614 int fragment;
615
616 fdt_for_each_subnode(fragment, fdto, 0) {
617 int overlay;
618 int target;
619 int ret;
620
621 /*
622 * Each fragments will have an __overlay__ node. If
623 * they don't, it's not supposed to be merged
624 */
625 overlay = fdt_subnode_offset(fdto, fragment, "__overlay__");
626 if (overlay == -FDT_ERR_NOTFOUND)
627 continue;
628
629 if (overlay < 0)
630 return overlay;
631
632 target = overlay_get_target(fdt, fdto, fragment, NULL);
633 if (target < 0)
634 return target;
635
636 ret = overlay_apply_node(fdt, target, fdto, overlay);
637 if (ret)
638 return ret;
639 }
640
641 return 0;
642}
643
644static int get_path_len(const void *fdt, int nodeoffset)
645{
646 int len = 0, namelen;
647 const char *name;
648
649 FDT_CHECK_HEADER(fdt);
650
651 for (;;) {
652 name = fdt_get_name(fdt, nodeoffset, &namelen);
653 if (!name)
654 return namelen;
655
656 /* root? we're done */
657 if (namelen == 0)
658 break;
659
660 nodeoffset = fdt_parent_offset(fdt, nodeoffset);
661 if (nodeoffset < 0)
662 return nodeoffset;
663 len += namelen + 1;
664 }
665
666 /* in case of root pretend it's "/" */
667 if (len == 0)
668 len++;
669 return len;
670}
671
672/**
673 * overlay_symbol_update - Update the symbols of base tree after a merge
674 * @fdt: Base Device Tree blob
675 * @fdto: Device tree overlay blob
676 *
677 * overlay_symbol_update() updates the symbols of the base tree with the
678 * symbols of the applied overlay
679 *
680 * This is the last step in the device tree overlay application
681 * process, allowing the reference of overlay symbols by subsequent
682 * overlay operations.
683 *
684 * returns:
685 * 0 on success
686 * Negative error code on failure
687 */
688static int overlay_symbol_update(void *fdt, void *fdto)
689{
690 int root_sym, ov_sym, prop, path_len, fragment, target;
691 int len, frag_name_len, ret, rel_path_len;
692 const char *s, *e;
693 const char *path;
694 const char *name;
695 const char *frag_name;
696 const char *rel_path;
697 const char *target_path;
698 char *buf;
699 void *p;
700
701 ov_sym = fdt_subnode_offset(fdto, 0, "__symbols__");
702
703 /* if no overlay symbols exist no problem */
704 if (ov_sym < 0)
705 return 0;
706
707 root_sym = fdt_subnode_offset(fdt, 0, "__symbols__");
708
709 /* it no root symbols exist we should create them */
710 if (root_sym == -FDT_ERR_NOTFOUND)
711 root_sym = fdt_add_subnode(fdt, 0, "__symbols__");
712
713 /* any error is fatal now */
714 if (root_sym < 0)
715 return root_sym;
716
717 /* iterate over each overlay symbol */
718 fdt_for_each_property_offset(prop, fdto, ov_sym) {
719 path = fdt_getprop_by_offset(fdto, prop, &name, &path_len);
720 if (!path)
721 return path_len;
722
723 /* verify it's a string property (terminated by a single \0) */
724 if (path_len < 1 || memchr(path, '\0', path_len) != &path[path_len - 1])
725 return -FDT_ERR_BADVALUE;
726
727 /* keep end marker to avoid strlen() */
728 e = path + path_len;
729
730 /* format: /<fragment-name>/__overlay__/<relative-subnode-path> */
731
732 if (*path != '/')
733 return -FDT_ERR_BADVALUE;
734
735 /* get fragment name first */
736 s = strchr(path + 1, '/');
737 if (!s)
738 return -FDT_ERR_BADOVERLAY;
739
740 frag_name = path + 1;
741 frag_name_len = s - path - 1;
742
743 /* verify format; safe since "s" lies in \0 terminated prop */
744 len = sizeof("/__overlay__/") - 1;
745 if ((e - s) < len || memcmp(s, "/__overlay__/", len))
746 return -FDT_ERR_BADOVERLAY;
747
748 rel_path = s + len;
749 rel_path_len = e - rel_path;
750
751 /* find the fragment index in which the symbol lies */
752 ret = fdt_subnode_offset_namelen(fdto, 0, frag_name,
753 frag_name_len);
754 /* not found? */
755 if (ret < 0)
756 return -FDT_ERR_BADOVERLAY;
757 fragment = ret;
758
759 /* an __overlay__ subnode must exist */
760 ret = fdt_subnode_offset(fdto, fragment, "__overlay__");
761 if (ret < 0)
762 return -FDT_ERR_BADOVERLAY;
763
764 /* get the target of the fragment */
765 ret = overlay_get_target(fdt, fdto, fragment, &target_path);
766 if (ret < 0)
767 return ret;
768 target = ret;
769
770 /* if we have a target path use */
771 if (!target_path) {
772 ret = get_path_len(fdt, target);
773 if (ret < 0)
774 return ret;
775 len = ret;
776 } else {
777 len = strlen(target_path);
778 }
779
780 ret = fdt_setprop_placeholder(fdt, root_sym, name,
781 len + (len > 1) + rel_path_len + 1, &p);
782 if (ret < 0)
783 return ret;
784
785 if (!target_path) {
786 /* again in case setprop_placeholder changed it */
787 ret = overlay_get_target(fdt, fdto, fragment, &target_path);
788 if (ret < 0)
789 return ret;
790 target = ret;
791 }
792
793 buf = p;
794 if (len > 1) { /* target is not root */
795 if (!target_path) {
796 ret = fdt_get_path(fdt, target, buf, len + 1);
797 if (ret < 0)
798 return ret;
799 } else
800 memcpy(buf, target_path, len + 1);
801
802 } else
803 len--;
804
805 buf[len] = '/';
806 memcpy(buf + len + 1, rel_path, rel_path_len);
807 buf[len + 1 + rel_path_len] = '\0';
808 }
809
810 return 0;
811}
812
813int fdt_overlay_apply(void *fdt, void *fdto)
814{
815 uint32_t delta = fdt_get_max_phandle(fdt);
816 int ret;
817
818 FDT_CHECK_HEADER(fdt);
819 FDT_CHECK_HEADER(fdto);
820
821 ret = overlay_adjust_local_phandles(fdto, delta);
822 if (ret)
823 goto err;
824
825 ret = overlay_update_local_references(fdto, delta);
826 if (ret)
827 goto err;
828
829 ret = overlay_fixup_phandles(fdt, fdto);
830 if (ret)
831 goto err;
832
833 ret = overlay_merge(fdt, fdto);
834 if (ret)
835 goto err;
836
837 ret = overlay_symbol_update(fdt, fdto);
838 if (ret)
839 goto err;
840
841 /*
842 * The overlay has been damaged, erase its magic.
843 */
844 fdt_set_magic(fdto, ~0);
845
846 return 0;
847
848err:
849 /*
850 * The overlay might have been damaged, erase its magic.
851 */
852 fdt_set_magic(fdto, ~0);
853
854 /*
855 * The base device tree might have been damaged, erase its
856 * magic.
857 */
858 fdt_set_magic(fdt, ~0);
859
860 return ret;
861}
diff --git a/scripts/dtc/libfdt/fdt_ro.c b/scripts/dtc/libfdt/fdt_ro.c
index 3d00d2eee0e3..08de2cce674d 100644
--- a/scripts/dtc/libfdt/fdt_ro.c
+++ b/scripts/dtc/libfdt/fdt_ro.c
@@ -60,7 +60,7 @@ static int _fdt_nodename_eq(const void *fdt, int offset,
60{ 60{
61 const char *p = fdt_offset_ptr(fdt, offset + FDT_TAGSIZE, len+1); 61 const char *p = fdt_offset_ptr(fdt, offset + FDT_TAGSIZE, len+1);
62 62
63 if (! p) 63 if (!p)
64 /* short match */ 64 /* short match */
65 return 0; 65 return 0;
66 66
@@ -327,7 +327,7 @@ const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
327 const struct fdt_property *prop; 327 const struct fdt_property *prop;
328 328
329 prop = fdt_get_property_namelen(fdt, nodeoffset, name, namelen, lenp); 329 prop = fdt_get_property_namelen(fdt, nodeoffset, name, namelen, lenp);
330 if (! prop) 330 if (!prop)
331 return NULL; 331 return NULL;
332 332
333 return prop->data; 333 return prop->data;
diff --git a/scripts/dtc/libfdt/fdt_rw.c b/scripts/dtc/libfdt/fdt_rw.c
index 3fd5847377c9..5c3a2bb0bc6b 100644
--- a/scripts/dtc/libfdt/fdt_rw.c
+++ b/scripts/dtc/libfdt/fdt_rw.c
@@ -207,7 +207,7 @@ static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name,
207 int err; 207 int err;
208 208
209 *prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen); 209 *prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen);
210 if (! (*prop)) 210 if (!*prop)
211 return oldlen; 211 return oldlen;
212 212
213 if ((err = _fdt_splice_struct(fdt, (*prop)->data, FDT_TAGALIGN(oldlen), 213 if ((err = _fdt_splice_struct(fdt, (*prop)->data, FDT_TAGALIGN(oldlen),
@@ -269,8 +269,8 @@ int fdt_set_name(void *fdt, int nodeoffset, const char *name)
269 return 0; 269 return 0;
270} 270}
271 271
272int fdt_setprop(void *fdt, int nodeoffset, const char *name, 272int fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name,
273 const void *val, int len) 273 int len, void **prop_data)
274{ 274{
275 struct fdt_property *prop; 275 struct fdt_property *prop;
276 int err; 276 int err;
@@ -283,8 +283,22 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
283 if (err) 283 if (err)
284 return err; 284 return err;
285 285
286 *prop_data = prop->data;
287 return 0;
288}
289
290int fdt_setprop(void *fdt, int nodeoffset, const char *name,
291 const void *val, int len)
292{
293 void *prop_data;
294 int err;
295
296 err = fdt_setprop_placeholder(fdt, nodeoffset, name, len, &prop_data);
297 if (err)
298 return err;
299
286 if (len) 300 if (len)
287 memcpy(prop->data, val, len); 301 memcpy(prop_data, val, len);
288 return 0; 302 return 0;
289} 303}
290 304
@@ -323,7 +337,7 @@ int fdt_delprop(void *fdt, int nodeoffset, const char *name)
323 FDT_RW_CHECK_HEADER(fdt); 337 FDT_RW_CHECK_HEADER(fdt);
324 338
325 prop = fdt_get_property_w(fdt, nodeoffset, name, &len); 339 prop = fdt_get_property_w(fdt, nodeoffset, name, &len);
326 if (! prop) 340 if (!prop)
327 return len; 341 return len;
328 342
329 proplen = sizeof(*prop) + FDT_TAGALIGN(len); 343 proplen = sizeof(*prop) + FDT_TAGALIGN(len);
diff --git a/scripts/dtc/libfdt/fdt_sw.c b/scripts/dtc/libfdt/fdt_sw.c
index 6a804859fd0c..2bd15e7aef87 100644
--- a/scripts/dtc/libfdt/fdt_sw.c
+++ b/scripts/dtc/libfdt/fdt_sw.c
@@ -220,7 +220,7 @@ static int _fdt_find_add_string(void *fdt, const char *s)
220 return offset; 220 return offset;
221} 221}
222 222
223int fdt_property(void *fdt, const char *name, const void *val, int len) 223int fdt_property_placeholder(void *fdt, const char *name, int len, void **valp)
224{ 224{
225 struct fdt_property *prop; 225 struct fdt_property *prop;
226 int nameoff; 226 int nameoff;
@@ -238,7 +238,19 @@ int fdt_property(void *fdt, const char *name, const void *val, int len)
238 prop->tag = cpu_to_fdt32(FDT_PROP); 238 prop->tag = cpu_to_fdt32(FDT_PROP);
239 prop->nameoff = cpu_to_fdt32(nameoff); 239 prop->nameoff = cpu_to_fdt32(nameoff);
240 prop->len = cpu_to_fdt32(len); 240 prop->len = cpu_to_fdt32(len);
241 memcpy(prop->data, val, len); 241 *valp = prop->data;
242 return 0;
243}
244
245int fdt_property(void *fdt, const char *name, const void *val, int len)
246{
247 void *ptr;
248 int ret;
249
250 ret = fdt_property_placeholder(fdt, name, len, &ptr);
251 if (ret)
252 return ret;
253 memcpy(ptr, val, len);
242 return 0; 254 return 0;
243} 255}
244 256
diff --git a/scripts/dtc/libfdt/fdt_wip.c b/scripts/dtc/libfdt/fdt_wip.c
index 6aaab399929c..5e859198622b 100644
--- a/scripts/dtc/libfdt/fdt_wip.c
+++ b/scripts/dtc/libfdt/fdt_wip.c
@@ -82,7 +82,7 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
82 int proplen; 82 int proplen;
83 83
84 propval = fdt_getprop(fdt, nodeoffset, name, &proplen); 84 propval = fdt_getprop(fdt, nodeoffset, name, &proplen);
85 if (! propval) 85 if (!propval)
86 return proplen; 86 return proplen;
87 87
88 if (proplen != len) 88 if (proplen != len)
@@ -107,7 +107,7 @@ int fdt_nop_property(void *fdt, int nodeoffset, const char *name)
107 int len; 107 int len;
108 108
109 prop = fdt_get_property_w(fdt, nodeoffset, name, &len); 109 prop = fdt_get_property_w(fdt, nodeoffset, name, &len);
110 if (! prop) 110 if (!prop)
111 return len; 111 return len;
112 112
113 _fdt_nop_region(prop, len + sizeof(*prop)); 113 _fdt_nop_region(prop, len + sizeof(*prop));
diff --git a/scripts/dtc/libfdt/libfdt.h b/scripts/dtc/libfdt/libfdt.h
index ba86caa73d01..7f83023ee109 100644
--- a/scripts/dtc/libfdt/libfdt.h
+++ b/scripts/dtc/libfdt/libfdt.h
@@ -1314,6 +1314,22 @@ static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val)
1314{ 1314{
1315 return fdt_property_u32(fdt, name, val); 1315 return fdt_property_u32(fdt, name, val);
1316} 1316}
1317
1318/**
1319 * fdt_property_placeholder - add a new property and return a ptr to its value
1320 *
1321 * @fdt: pointer to the device tree blob
1322 * @name: name of property to add
1323 * @len: length of property value in bytes
1324 * @valp: returns a pointer to where where the value should be placed
1325 *
1326 * returns:
1327 * 0, on success
1328 * -FDT_ERR_BADMAGIC,
1329 * -FDT_ERR_NOSPACE, standard meanings
1330 */
1331int fdt_property_placeholder(void *fdt, const char *name, int len, void **valp);
1332
1317#define fdt_property_string(fdt, name, str) \ 1333#define fdt_property_string(fdt, name, str) \
1318 fdt_property(fdt, name, str, strlen(str)+1) 1334 fdt_property(fdt, name, str, strlen(str)+1)
1319int fdt_end_node(void *fdt); 1335int fdt_end_node(void *fdt);
@@ -1433,6 +1449,37 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
1433 const void *val, int len); 1449 const void *val, int len);
1434 1450
1435/** 1451/**
1452 * fdt_setprop _placeholder - allocate space for a property
1453 * @fdt: pointer to the device tree blob
1454 * @nodeoffset: offset of the node whose property to change
1455 * @name: name of the property to change
1456 * @len: length of the property value
1457 * @prop_data: return pointer to property data
1458 *
1459 * fdt_setprop_placeholer() allocates the named property in the given node.
1460 * If the property exists it is resized. In either case a pointer to the
1461 * property data is returned.
1462 *
1463 * This function may insert or delete data from the blob, and will
1464 * therefore change the offsets of some existing nodes.
1465 *
1466 * returns:
1467 * 0, on success
1468 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
1469 * contain the new property value
1470 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1471 * -FDT_ERR_BADLAYOUT,
1472 * -FDT_ERR_BADMAGIC,
1473 * -FDT_ERR_BADVERSION,
1474 * -FDT_ERR_BADSTATE,
1475 * -FDT_ERR_BADSTRUCTURE,
1476 * -FDT_ERR_BADLAYOUT,
1477 * -FDT_ERR_TRUNCATED, standard meanings
1478 */
1479int fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name,
1480 int len, void **prop_data);
1481
1482/**
1436 * fdt_setprop_u32 - set a property to a 32-bit integer 1483 * fdt_setprop_u32 - set a property to a 32-bit integer
1437 * @fdt: pointer to the device tree blob 1484 * @fdt: pointer to the device tree blob
1438 * @nodeoffset: offset of the node whose property to change 1485 * @nodeoffset: offset of the node whose property to change
diff --git a/scripts/dtc/livetree.c b/scripts/dtc/livetree.c
index 3673de07e4e5..6846ad2fd6d2 100644
--- a/scripts/dtc/livetree.c
+++ b/scripts/dtc/livetree.c
@@ -216,6 +216,28 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node)
216 return old_node; 216 return old_node;
217} 217}
218 218
219void add_orphan_node(struct node *dt, struct node *new_node, char *ref)
220{
221 static unsigned int next_orphan_fragment = 0;
222 struct node *node;
223 struct property *p;
224 struct data d = empty_data;
225 char *name;
226
227 d = data_add_marker(d, REF_PHANDLE, ref);
228 d = data_append_integer(d, 0xffffffff, 32);
229
230 p = build_property("target", d);
231
232 xasprintf(&name, "fragment@%u",
233 next_orphan_fragment++);
234 name_node(new_node, "__overlay__");
235 node = build_node(p, new_node);
236 name_node(node, name);
237
238 add_child(dt, node);
239}
240
219struct node *chain_node(struct node *first, struct node *list) 241struct node *chain_node(struct node *first, struct node *list)
220{ 242{
221 assert(first->next_sibling == NULL); 243 assert(first->next_sibling == NULL);
@@ -396,6 +418,12 @@ cell_t propval_cell(struct property *prop)
396 return fdt32_to_cpu(*((fdt32_t *)prop->val.val)); 418 return fdt32_to_cpu(*((fdt32_t *)prop->val.val));
397} 419}
398 420
421cell_t propval_cell_n(struct property *prop, int n)
422{
423 assert(prop->val.len / sizeof(cell_t) >= n);
424 return fdt32_to_cpu(*((fdt32_t *)prop->val.val + n));
425}
426
399struct property *get_property_by_label(struct node *tree, const char *label, 427struct property *get_property_by_label(struct node *tree, const char *label,
400 struct node **node) 428 struct node **node)
401{ 429{
@@ -478,7 +506,8 @@ struct node *get_node_by_path(struct node *tree, const char *path)
478 p = strchr(path, '/'); 506 p = strchr(path, '/');
479 507
480 for_each_child(tree, child) { 508 for_each_child(tree, child) {
481 if (p && strneq(path, child->name, p-path)) 509 if (p && (strlen(child->name) == p-path) &&
510 strneq(path, child->name, p-path))
482 return get_node_by_path(child, p+1); 511 return get_node_by_path(child, p+1);
483 else if (!p && streq(path, child->name)) 512 else if (!p && streq(path, child->name))
484 return child; 513 return child;
diff --git a/scripts/dtc/update-dtc-source.sh b/scripts/dtc/update-dtc-source.sh
index b8ebcc6722d2..fe8926bb3b54 100755
--- a/scripts/dtc/update-dtc-source.sh
+++ b/scripts/dtc/update-dtc-source.sh
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2# Simple script to update the version of DTC carried by the Linux kernel 3# Simple script to update the version of DTC carried by the Linux kernel
3# 4#
4# This script assumes that the dtc and the linux git trees are in the 5# This script assumes that the dtc and the linux git trees are in the
@@ -34,7 +35,9 @@ DTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c
34 srcpos.h treesource.c util.c util.h version_gen.h Makefile.dtc \ 35 srcpos.h treesource.c util.c util.h version_gen.h Makefile.dtc \
35 dtc-lexer.l dtc-parser.y" 36 dtc-lexer.l dtc-parser.y"
36DTC_GENERATED="dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h" 37DTC_GENERATED="dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h"
37LIBFDT_SOURCE="Makefile.libfdt fdt.c fdt.h fdt_empty_tree.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c fdt_wip.c libfdt.h libfdt_env.h libfdt_internal.h" 38LIBFDT_SOURCE="Makefile.libfdt fdt.c fdt.h fdt_addresses.c fdt_empty_tree.c \
39 fdt_overlay.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c \
40 fdt_wip.c libfdt.h libfdt_env.h libfdt_internal.h"
38 41
39get_last_dtc_version() { 42get_last_dtc_version() {
40 git log --oneline scripts/dtc/ | grep 'upstream' | head -1 | sed -e 's/^.* \(.*\)/\1/' 43 git log --oneline scripts/dtc/ | grep 'upstream' | head -1 | sed -e 's/^.* \(.*\)/\1/'
diff --git a/scripts/dtc/version_gen.h b/scripts/dtc/version_gen.h
index 1229e07b4912..6a4e84798966 100644
--- a/scripts/dtc/version_gen.h
+++ b/scripts/dtc/version_gen.h
@@ -1 +1 @@
#define DTC_VERSION "DTC 1.4.4-g756ffc4f" #define DTC_VERSION "DTC 1.4.5-gc1e55a55"
diff --git a/scripts/extract-module-sig.pl b/scripts/extract-module-sig.pl
index 0f161ea41261..36a2f59c4e41 100755
--- a/scripts/extract-module-sig.pl
+++ b/scripts/extract-module-sig.pl
@@ -1,4 +1,5 @@
1#!/usr/bin/env perl 1#!/usr/bin/env perl
2# SPDX-License-Identifier: GPL-2.0
2# 3#
3# extract-mod-sig <part> <module-file> 4# extract-mod-sig <part> <module-file>
4# 5#
diff --git a/scripts/extract-sys-certs.pl b/scripts/extract-sys-certs.pl
index 2aa873b944e0..fa8ab15118cc 100755
--- a/scripts/extract-sys-certs.pl
+++ b/scripts/extract-sys-certs.pl
@@ -1,4 +1,5 @@
1#!/usr/bin/env perl 1#!/usr/bin/env perl
2# SPDX-License-Identifier: GPL-2.0
2# 3#
3use warnings; 4use warnings;
4use strict; 5use strict;
diff --git a/scripts/faddr2line b/scripts/faddr2line
index 29df825d375c..1f5ce959f596 100755
--- a/scripts/faddr2line
+++ b/scripts/faddr2line
@@ -1,4 +1,5 @@
1#!/bin/bash 1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
2# 3#
3# Translate stack dump function offsets. 4# Translate stack dump function offsets.
4# 5#
@@ -103,11 +104,12 @@ __faddr2line() {
103 104
104 # Go through each of the object's symbols which match the func name. 105 # Go through each of the object's symbols which match the func name.
105 # In rare cases there might be duplicates. 106 # In rare cases there might be duplicates.
107 file_end=$(size -Ax $objfile | awk '$1 == ".text" {print $2}')
106 while read symbol; do 108 while read symbol; do
107 local fields=($symbol) 109 local fields=($symbol)
108 local sym_base=0x${fields[0]} 110 local sym_base=0x${fields[0]}
109 local sym_type=${fields[1]} 111 local sym_type=${fields[1]}
110 local sym_end=0x${fields[3]} 112 local sym_end=${fields[3]}
111 113
112 # calculate the size 114 # calculate the size
113 local sym_size=$(($sym_end - $sym_base)) 115 local sym_size=$(($sym_end - $sym_base))
@@ -157,7 +159,7 @@ __faddr2line() {
157 addr2line -fpie $objfile $addr | sed "s; $dir_prefix\(\./\)*; ;" 159 addr2line -fpie $objfile $addr | sed "s; $dir_prefix\(\./\)*; ;"
158 DONE=1 160 DONE=1
159 161
160 done < <(nm -n $objfile | awk -v fn=$func '$3 == fn { found=1; line=$0; start=$1; next } found == 1 { found=0; print line, $1 }') 162 done < <(nm -n $objfile | awk -v fn=$func -v end=$file_end '$3 == fn { found=1; line=$0; start=$1; next } found == 1 { found=0; print line, "0x"$1 } END {if (found == 1) print line, end; }')
161} 163}
162 164
163[[ $# -lt 2 ]] && usage 165[[ $# -lt 2 ]] && usage
diff --git a/scripts/find-unused-docs.sh b/scripts/find-unused-docs.sh
new file mode 100755
index 000000000000..3f46f8977dc4
--- /dev/null
+++ b/scripts/find-unused-docs.sh
@@ -0,0 +1,62 @@
1#!/bin/bash
2# (c) 2017, Jonathan Corbet <corbet@lwn.net>
3# sayli karnik <karniksayli1995@gmail.com>
4#
5# This script detects files with kernel-doc comments for exported functions
6# that are not included in documentation.
7#
8# usage: Run 'scripts/find-unused-docs.sh directory' from top level of kernel
9# tree.
10#
11# example: $scripts/find-unused-docs.sh drivers/scsi
12#
13# Licensed under the terms of the GNU GPL License
14
15if ! [ -d "Documentation" ]; then
16 echo "Run from top level of kernel tree"
17 exit 1
18fi
19
20if [ "$#" -ne 1 ]; then
21 echo "Usage: scripts/find-unused-docs.sh directory"
22 exit 1
23fi
24
25if ! [ -d "$1" ]; then
26 echo "Directory $1 doesn't exist"
27 exit 1
28fi
29
30cd "$( dirname "${BASH_SOURCE[0]}" )"
31cd ..
32
33cd Documentation/
34
35echo "The following files contain kerneldoc comments for exported functions \
36that are not used in the formatted documentation"
37
38# FILES INCLUDED
39
40files_included=($(grep -rHR ".. kernel-doc" --include \*.rst | cut -d " " -f 3))
41
42declare -A FILES_INCLUDED
43
44for each in "${files_included[@]}"; do
45 FILES_INCLUDED[$each]="$each"
46 done
47
48cd ..
49
50# FILES NOT INCLUDED
51
52for file in `find $1 -name '*.c'`; do
53
54 if [[ ${FILES_INCLUDED[$file]+_} ]]; then
55 continue;
56 fi
57 str=$(scripts/kernel-doc -text -export "$file" 2>/dev/null)
58 if [[ -n "$str" ]]; then
59 echo "$file"
60 fi
61 done
62
diff --git a/scripts/gcc-goto.sh b/scripts/gcc-goto.sh
index c9469d34ecc6..083c526073ef 100755
--- a/scripts/gcc-goto.sh
+++ b/scripts/gcc-goto.sh
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2# Test for gcc 'asm goto' support 3# Test for gcc 'asm goto' support
3# Copyright (C) 2010, Jason Baron <jbaron@redhat.com> 4# Copyright (C) 2010, Jason Baron <jbaron@redhat.com>
4 5
diff --git a/scripts/gcc-ld b/scripts/gcc-ld
index cadab9a13ed7..997b818c3962 100755
--- a/scripts/gcc-ld
+++ b/scripts/gcc-ld
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2# run gcc with ld options 3# run gcc with ld options
3# used as a wrapper to execute link time optimizations 4# used as a wrapper to execute link time optimizations
4# yes virginia, this is not pretty 5# yes virginia, this is not pretty
diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
index b65224bfb847..d3caefe53eab 100755
--- a/scripts/gcc-plugin.sh
+++ b/scripts/gcc-plugin.sh
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2srctree=$(dirname "$0") 3srctree=$(dirname "$0")
3 4
4SHOW_ERROR= 5SHOW_ERROR=
diff --git a/scripts/gcc-plugins/Makefile b/scripts/gcc-plugins/Makefile
index 214eb2335c31..e2ff425f4c7e 100644
--- a/scripts/gcc-plugins/Makefile
+++ b/scripts/gcc-plugins/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1GCC_PLUGINS_DIR := $(shell $(CC) -print-file-name=plugin) 2GCC_PLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
2 3
3ifeq ($(PLUGINCC),$(HOSTCC)) 4ifeq ($(PLUGINCC),$(HOSTCC))
diff --git a/scripts/gcc-plugins/gcc-common.h b/scripts/gcc-plugins/gcc-common.h
index 6948898b3cdf..ffd1dfaa1cc1 100644
--- a/scripts/gcc-plugins/gcc-common.h
+++ b/scripts/gcc-plugins/gcc-common.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef GCC_COMMON_H_INCLUDED 2#ifndef GCC_COMMON_H_INCLUDED
2#define GCC_COMMON_H_INCLUDED 3#define GCC_COMMON_H_INCLUDED
3 4
diff --git a/scripts/gcc-plugins/gcc-generate-gimple-pass.h b/scripts/gcc-plugins/gcc-generate-gimple-pass.h
index 526c3c79b68e..f20797e80b6d 100644
--- a/scripts/gcc-plugins/gcc-generate-gimple-pass.h
+++ b/scripts/gcc-plugins/gcc-generate-gimple-pass.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Generator for GIMPLE pass related boilerplate code/data 3 * Generator for GIMPLE pass related boilerplate code/data
3 * 4 *
diff --git a/scripts/gcc-plugins/gcc-generate-ipa-pass.h b/scripts/gcc-plugins/gcc-generate-ipa-pass.h
index 9bd926e072f0..92bb4f3a87a4 100644
--- a/scripts/gcc-plugins/gcc-generate-ipa-pass.h
+++ b/scripts/gcc-plugins/gcc-generate-ipa-pass.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Generator for IPA pass related boilerplate code/data 3 * Generator for IPA pass related boilerplate code/data
3 * 4 *
diff --git a/scripts/gcc-plugins/gcc-generate-rtl-pass.h b/scripts/gcc-plugins/gcc-generate-rtl-pass.h
index 1dc67a5aeadf..d69cd80b6c10 100644
--- a/scripts/gcc-plugins/gcc-generate-rtl-pass.h
+++ b/scripts/gcc-plugins/gcc-generate-rtl-pass.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Generator for RTL pass related boilerplate code/data 3 * Generator for RTL pass related boilerplate code/data
3 * 4 *
diff --git a/scripts/gcc-plugins/gcc-generate-simple_ipa-pass.h b/scripts/gcc-plugins/gcc-generate-simple_ipa-pass.h
index a27e2b36afaa..06800bc477e0 100644
--- a/scripts/gcc-plugins/gcc-generate-simple_ipa-pass.h
+++ b/scripts/gcc-plugins/gcc-generate-simple_ipa-pass.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * Generator for SIMPLE_IPA pass related boilerplate code/data 3 * Generator for SIMPLE_IPA pass related boilerplate code/data
3 * 4 *
diff --git a/scripts/gcc-plugins/gen-random-seed.sh b/scripts/gcc-plugins/gen-random-seed.sh
index 7514850f4815..68af5cc20a64 100644
--- a/scripts/gcc-plugins/gen-random-seed.sh
+++ b/scripts/gcc-plugins/gen-random-seed.sh
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2 3
3if [ ! -f "$1" ]; then 4if [ ! -f "$1" ]; then
4 SEED=`od -A n -t x8 -N 32 /dev/urandom | tr -d ' \n'` 5 SEED=`od -A n -t x8 -N 32 /dev/urandom | tr -d ' \n'`
diff --git a/scripts/gcc-version.sh b/scripts/gcc-version.sh
index 7f2126df91f2..11bb909845e7 100755
--- a/scripts/gcc-version.sh
+++ b/scripts/gcc-version.sh
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2# 3#
3# gcc-version [-p] gcc-command 4# gcc-version [-p] gcc-command
4# 5#
diff --git a/scripts/gcc-x86_32-has-stack-protector.sh b/scripts/gcc-x86_32-has-stack-protector.sh
index 12dbd0b11ea4..6b2aeefb9cd3 100755
--- a/scripts/gcc-x86_32-has-stack-protector.sh
+++ b/scripts/gcc-x86_32-has-stack-protector.sh
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2 3
3echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs" 4echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
4if [ "$?" -eq "0" ] ; then 5if [ "$?" -eq "0" ] ; then
diff --git a/scripts/gcc-x86_64-has-stack-protector.sh b/scripts/gcc-x86_64-has-stack-protector.sh
index 17867e723a51..4a48bdcd4d6b 100755
--- a/scripts/gcc-x86_64-has-stack-protector.sh
+++ b/scripts/gcc-x86_64-has-stack-protector.sh
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2 3
3echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -mcmodel=kernel -fno-PIE -fstack-protector - -o - 2> /dev/null | grep -q "%gs" 4echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -mcmodel=kernel -fno-PIE -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
4if [ "$?" -eq "0" ] ; then 5if [ "$?" -eq "0" ] ; then
diff --git a/scripts/gdb/linux/Makefile b/scripts/gdb/linux/Makefile
index ab3cfe727a4e..aba23be985e4 100644
--- a/scripts/gdb/linux/Makefile
+++ b/scripts/gdb/linux/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1always := gdb-scripts 2always := gdb-scripts
2 3
3SRCTREE := $(abspath $(srctree)) 4SRCTREE := $(abspath $(srctree))
diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile
index 3c23bab3367b..34d6ab1811a4 100644
--- a/scripts/genksyms/Makefile
+++ b/scripts/genksyms/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1 2
2hostprogs-y := genksyms 3hostprogs-y := genksyms
3always := $(hostprogs-y) 4always := $(hostprogs-y)
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index bc443201d3ef..99c96e86eccb 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -57,6 +57,7 @@ my $sections = 0;
57my $file_emails = 0; 57my $file_emails = 0;
58my $from_filename = 0; 58my $from_filename = 0;
59my $pattern_depth = 0; 59my $pattern_depth = 0;
60my $self_test = undef;
60my $version = 0; 61my $version = 0;
61my $help = 0; 62my $help = 0;
62my $find_maintainer_files = 0; 63my $find_maintainer_files = 0;
@@ -138,6 +139,7 @@ my %VCS_cmds_git = (
138 "subject_pattern" => "^GitSubject: (.*)", 139 "subject_pattern" => "^GitSubject: (.*)",
139 "stat_pattern" => "^(\\d+)\\t(\\d+)\\t\$file\$", 140 "stat_pattern" => "^(\\d+)\\t(\\d+)\\t\$file\$",
140 "file_exists_cmd" => "git ls-files \$file", 141 "file_exists_cmd" => "git ls-files \$file",
142 "list_files_cmd" => "git ls-files \$file",
141); 143);
142 144
143my %VCS_cmds_hg = ( 145my %VCS_cmds_hg = (
@@ -167,6 +169,7 @@ my %VCS_cmds_hg = (
167 "subject_pattern" => "^HgSubject: (.*)", 169 "subject_pattern" => "^HgSubject: (.*)",
168 "stat_pattern" => "^(\\d+)\t(\\d+)\t\$file\$", 170 "stat_pattern" => "^(\\d+)\t(\\d+)\t\$file\$",
169 "file_exists_cmd" => "hg files \$file", 171 "file_exists_cmd" => "hg files \$file",
172 "list_files_cmd" => "hg manifest -R \$file",
170); 173);
171 174
172my $conf = which_conf(".get_maintainer.conf"); 175my $conf = which_conf(".get_maintainer.conf");
@@ -216,6 +219,14 @@ if (-f $ignore_file) {
216 close($ignore); 219 close($ignore);
217} 220}
218 221
222if ($#ARGV > 0) {
223 foreach (@ARGV) {
224 if ($_ =~ /^-{1,2}self-test(?:=|$)/) {
225 die "$P: using --self-test does not allow any other option or argument\n";
226 }
227 }
228}
229
219if (!GetOptions( 230if (!GetOptions(
220 'email!' => \$email, 231 'email!' => \$email,
221 'git!' => \$email_git, 232 'git!' => \$email_git,
@@ -252,6 +263,7 @@ if (!GetOptions(
252 'fe|file-emails!' => \$file_emails, 263 'fe|file-emails!' => \$file_emails,
253 'f|file' => \$from_filename, 264 'f|file' => \$from_filename,
254 'find-maintainer-files' => \$find_maintainer_files, 265 'find-maintainer-files' => \$find_maintainer_files,
266 'self-test:s' => \$self_test,
255 'v|version' => \$version, 267 'v|version' => \$version,
256 'h|help|usage' => \$help, 268 'h|help|usage' => \$help,
257 )) { 269 )) {
@@ -268,6 +280,12 @@ if ($version != 0) {
268 exit 0; 280 exit 0;
269} 281}
270 282
283if (defined $self_test) {
284 read_all_maintainer_files();
285 self_test();
286 exit 0;
287}
288
271if (-t STDIN && !@ARGV) { 289if (-t STDIN && !@ARGV) {
272 # We're talking to a terminal, but have no command line arguments. 290 # We're talking to a terminal, but have no command line arguments.
273 die "$P: missing patchfile or -f file - use --help if necessary\n"; 291 die "$P: missing patchfile or -f file - use --help if necessary\n";
@@ -311,14 +329,17 @@ if (!top_of_kernel_tree($lk_path)) {
311my @typevalue = (); 329my @typevalue = ();
312my %keyword_hash; 330my %keyword_hash;
313my @mfiles = (); 331my @mfiles = ();
332my @self_test_info = ();
314 333
315sub read_maintainer_file { 334sub read_maintainer_file {
316 my ($file) = @_; 335 my ($file) = @_;
317 336
318 open (my $maint, '<', "$file") 337 open (my $maint, '<', "$file")
319 or die "$P: Can't open MAINTAINERS file '$file': $!\n"; 338 or die "$P: Can't open MAINTAINERS file '$file': $!\n";
339 my $i = 1;
320 while (<$maint>) { 340 while (<$maint>) {
321 my $line = $_; 341 my $line = $_;
342 chomp $line;
322 343
323 if ($line =~ m/^([A-Z]):\s*(.*)/) { 344 if ($line =~ m/^([A-Z]):\s*(.*)/) {
324 my $type = $1; 345 my $type = $1;
@@ -338,9 +359,12 @@ sub read_maintainer_file {
338 } 359 }
339 push(@typevalue, "$type:$value"); 360 push(@typevalue, "$type:$value");
340 } elsif (!(/^\s*$/ || /^\s*\#/)) { 361 } elsif (!(/^\s*$/ || /^\s*\#/)) {
341 $line =~ s/\n$//g;
342 push(@typevalue, $line); 362 push(@typevalue, $line);
343 } 363 }
364 if (defined $self_test) {
365 push(@self_test_info, {file=>$file, linenr=>$i, line=>$line});
366 }
367 $i++;
344 } 368 }
345 close($maint); 369 close($maint);
346} 370}
@@ -357,26 +381,30 @@ sub find_ignore_git {
357 return grep { $_ !~ /^\.git$/; } @_; 381 return grep { $_ !~ /^\.git$/; } @_;
358} 382}
359 383
360if (-d "${lk_path}MAINTAINERS") { 384read_all_maintainer_files();
361 opendir(DIR, "${lk_path}MAINTAINERS") or die $!; 385
362 my @files = readdir(DIR); 386sub read_all_maintainer_files {
363 closedir(DIR); 387 if (-d "${lk_path}MAINTAINERS") {
364 foreach my $file (@files) { 388 opendir(DIR, "${lk_path}MAINTAINERS") or die $!;
365 push(@mfiles, "${lk_path}MAINTAINERS/$file") if ($file !~ /^\./); 389 my @files = readdir(DIR);
390 closedir(DIR);
391 foreach my $file (@files) {
392 push(@mfiles, "${lk_path}MAINTAINERS/$file") if ($file !~ /^\./);
393 }
366 } 394 }
367}
368 395
369if ($find_maintainer_files) { 396 if ($find_maintainer_files) {
370 find( { wanted => \&find_is_maintainer_file, 397 find( { wanted => \&find_is_maintainer_file,
371 preprocess => \&find_ignore_git, 398 preprocess => \&find_ignore_git,
372 no_chdir => 1, 399 no_chdir => 1,
373 }, "${lk_path}"); 400 }, "${lk_path}");
374} else { 401 } else {
375 push(@mfiles, "${lk_path}MAINTAINERS") if -f "${lk_path}MAINTAINERS"; 402 push(@mfiles, "${lk_path}MAINTAINERS") if -f "${lk_path}MAINTAINERS";
376} 403 }
377 404
378foreach my $file (@mfiles) { 405 foreach my $file (@mfiles) {
379 read_maintainer_file("$file"); 406 read_maintainer_file("$file");
407 }
380} 408}
381 409
382# 410#
@@ -586,6 +614,135 @@ if ($web) {
586 614
587exit($exit); 615exit($exit);
588 616
617sub self_test {
618 my @lsfiles = ();
619 my @good_links = ();
620 my @bad_links = ();
621 my @section_headers = ();
622 my $index = 0;
623
624 @lsfiles = vcs_list_files($lk_path);
625
626 for my $x (@self_test_info) {
627 $index++;
628
629 ## Section header duplication and missing section content
630 if (($self_test eq "" || $self_test =~ /\bsections\b/) &&
631 $x->{line} =~ /^\S[^:]/ &&
632 defined $self_test_info[$index] &&
633 $self_test_info[$index]->{line} =~ /^([A-Z]):\s*\S/) {
634 my $has_S = 0;
635 my $has_F = 0;
636 my $has_ML = 0;
637 my $status = "";
638 if (grep(m@^\Q$x->{line}\E@, @section_headers)) {
639 print("$x->{file}:$x->{linenr}: warning: duplicate section header\t$x->{line}\n");
640 } else {
641 push(@section_headers, $x->{line});
642 }
643 my $nextline = $index;
644 while (defined $self_test_info[$nextline] &&
645 $self_test_info[$nextline]->{line} =~ /^([A-Z]):\s*(\S.*)/) {
646 my $type = $1;
647 my $value = $2;
648 if ($type eq "S") {
649 $has_S = 1;
650 $status = $value;
651 } elsif ($type eq "F" || $type eq "N") {
652 $has_F = 1;
653 } elsif ($type eq "M" || $type eq "R" || $type eq "L") {
654 $has_ML = 1;
655 }
656 $nextline++;
657 }
658 if (!$has_ML && $status !~ /orphan|obsolete/i) {
659 print("$x->{file}:$x->{linenr}: warning: section without email address\t$x->{line}\n");
660 }
661 if (!$has_S) {
662 print("$x->{file}:$x->{linenr}: warning: section without status \t$x->{line}\n");
663 }
664 if (!$has_F) {
665 print("$x->{file}:$x->{linenr}: warning: section without file pattern\t$x->{line}\n");
666 }
667 }
668
669 next if ($x->{line} !~ /^([A-Z]):\s*(.*)/);
670
671 my $type = $1;
672 my $value = $2;
673
674 ## Filename pattern matching
675 if (($type eq "F" || $type eq "X") &&
676 ($self_test eq "" || $self_test =~ /\bpatterns\b/)) {
677 $value =~ s@\.@\\\.@g; ##Convert . to \.
678 $value =~ s/\*/\.\*/g; ##Convert * to .*
679 $value =~ s/\?/\./g; ##Convert ? to .
680 ##if pattern is a directory and it lacks a trailing slash, add one
681 if ((-d $value)) {
682 $value =~ s@([^/])$@$1/@;
683 }
684 if (!grep(m@^$value@, @lsfiles)) {
685 print("$x->{file}:$x->{linenr}: warning: no file matches\t$x->{line}\n");
686 }
687
688 ## Link reachability
689 } elsif (($type eq "W" || $type eq "Q" || $type eq "B") &&
690 $value =~ /^https?:/ &&
691 ($self_test eq "" || $self_test =~ /\blinks\b/)) {
692 next if (grep(m@^\Q$value\E$@, @good_links));
693 my $isbad = 0;
694 if (grep(m@^\Q$value\E$@, @bad_links)) {
695 $isbad = 1;
696 } else {
697 my $output = `wget --spider -q --no-check-certificate --timeout 10 --tries 1 $value`;
698 if ($? == 0) {
699 push(@good_links, $value);
700 } else {
701 push(@bad_links, $value);
702 $isbad = 1;
703 }
704 }
705 if ($isbad) {
706 print("$x->{file}:$x->{linenr}: warning: possible bad link\t$x->{line}\n");
707 }
708
709 ## SCM reachability
710 } elsif ($type eq "T" &&
711 ($self_test eq "" || $self_test =~ /\bscm\b/)) {
712 next if (grep(m@^\Q$value\E$@, @good_links));
713 my $isbad = 0;
714 if (grep(m@^\Q$value\E$@, @bad_links)) {
715 $isbad = 1;
716 } elsif ($value !~ /^(?:git|quilt|hg)\s+\S/) {
717 print("$x->{file}:$x->{linenr}: warning: malformed entry\t$x->{line}\n");
718 } elsif ($value =~ /^git\s+(\S+)(\s+([^\(]+\S+))?/) {
719 my $url = $1;
720 my $branch = "";
721 $branch = $3 if $3;
722 my $output = `git ls-remote --exit-code -h "$url" $branch > /dev/null 2>&1`;
723 if ($? == 0) {
724 push(@good_links, $value);
725 } else {
726 push(@bad_links, $value);
727 $isbad = 1;
728 }
729 } elsif ($value =~ /^(?:quilt|hg)\s+(https?:\S+)/) {
730 my $url = $1;
731 my $output = `wget --spider -q --no-check-certificate --timeout 10 --tries 1 $url`;
732 if ($? == 0) {
733 push(@good_links, $value);
734 } else {
735 push(@bad_links, $value);
736 $isbad = 1;
737 }
738 }
739 if ($isbad) {
740 print("$x->{file}:$x->{linenr}: warning: possible bad link\t$x->{line}\n");
741 }
742 }
743 }
744}
745
589sub ignore_email_address { 746sub ignore_email_address {
590 my ($address) = @_; 747 my ($address) = @_;
591 748
@@ -863,6 +1020,7 @@ Other options:
863 --sections => print all of the subsystem sections with pattern matches 1020 --sections => print all of the subsystem sections with pattern matches
864 --letters => print all matching 'letter' types from all matching sections 1021 --letters => print all matching 'letter' types from all matching sections
865 --mailmap => use .mailmap file (default: $email_use_mailmap) 1022 --mailmap => use .mailmap file (default: $email_use_mailmap)
1023 --self-test => show potential issues with MAINTAINERS file content
866 --version => show version 1024 --version => show version
867 --help => show this help information 1025 --help => show this help information
868 1026
@@ -2192,6 +2350,23 @@ sub vcs_file_exists {
2192 return $exists; 2350 return $exists;
2193} 2351}
2194 2352
2353sub vcs_list_files {
2354 my ($file) = @_;
2355
2356 my @lsfiles = ();
2357
2358 my $vcs_used = vcs_exists();
2359 return 0 if (!$vcs_used);
2360
2361 my $cmd = $VCS_cmds{"list_files_cmd"};
2362 $cmd =~ s/(\$\w+)/$1/eeg; # interpolate $cmd
2363 @lsfiles = &{$VCS_cmds{"execute_cmd"}}($cmd);
2364
2365 return () if ($? != 0);
2366
2367 return @lsfiles;
2368}
2369
2195sub uniq { 2370sub uniq {
2196 my (@parms) = @_; 2371 my (@parms) = @_;
2197 2372
diff --git a/scripts/headerdep.pl b/scripts/headerdep.pl
index 86ebb9ee7570..ebfcbef4371c 100755
--- a/scripts/headerdep.pl
+++ b/scripts/headerdep.pl
@@ -1,4 +1,5 @@
1#! /usr/bin/env perl 1#! /usr/bin/env perl
2# SPDX-License-Identifier: GPL-2.0
2# 3#
3# Detect cycles in the header file dependency graph 4# Detect cycles in the header file dependency graph
4# Vegard Nossum <vegardno@ifi.uio.no> 5# Vegard Nossum <vegardno@ifi.uio.no>
diff --git a/scripts/headers.sh b/scripts/headers.sh
index d4dc4de5cea1..e0f883eb39a2 100755
--- a/scripts/headers.sh
+++ b/scripts/headers.sh
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2# Run headers_$1 command for all suitable architectures 3# Run headers_$1 command for all suitable architectures
3 4
4# Stop on error 5# Stop on error
diff --git a/scripts/headers_check.pl b/scripts/headers_check.pl
index 3091e4ee6ee1..b6aec5e4365f 100755
--- a/scripts/headers_check.pl
+++ b/scripts/headers_check.pl
@@ -1,4 +1,5 @@
1#!/usr/bin/env perl 1#!/usr/bin/env perl
2# SPDX-License-Identifier: GPL-2.0
2# 3#
3# headers_check.pl execute a number of trivial consistency checks 4# headers_check.pl execute a number of trivial consistency checks
4# 5#
diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
index fdebd66f8fc1..a18bca720995 100755
--- a/scripts/headers_install.sh
+++ b/scripts/headers_install.sh
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2 3
3if [ $# -lt 2 ] 4if [ $# -lt 2 ]
4then 5then
@@ -33,7 +34,7 @@ do
33 sed -r \ 34 sed -r \
34 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \ 35 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
35 -e 's/__attribute_const__([ \t]|$)/\1/g' \ 36 -e 's/__attribute_const__([ \t]|$)/\1/g' \
36 -e 's@^#include <linux/compiler.h>@@' \ 37 -e 's@^#include <linux/compiler(|_types).h>@@' \
37 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \ 38 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
38 -e 's/(^|[ \t(])(inline|asm|volatile)([ \t(]|$)/\1__\2__\3/g' \ 39 -e 's/(^|[ \t(])(inline|asm|volatile)([ \t(]|$)/\1__\2__\3/g' \
39 -e 's@#(ifndef|define|endif[ \t]*/[*])[ \t]*_UAPI@#\1 @' \ 40 -e 's@#(ifndef|define|endif[ \t]*/[*])[ \t]*_UAPI@#\1 @' \
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index 5d554419170b..9ee9bf7fd1a2 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -158,7 +158,7 @@ static int read_symbol(FILE *in, struct sym_entry *s)
158 else if (str[0] == '$') 158 else if (str[0] == '$')
159 return -1; 159 return -1;
160 /* exclude debugging symbols */ 160 /* exclude debugging symbols */
161 else if (stype == 'N') 161 else if (stype == 'N' || stype == 'n')
162 return -1; 162 return -1;
163 163
164 /* include the type field in the symbol name, so that it gets 164 /* include the type field in the symbol name, so that it gets
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 8c12c20c55a6..297c1bf35140 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1# =========================================================================== 2# ===========================================================================
2# Kernel configuration targets 3# Kernel configuration targets
3# These targets are used from top-level makefile 4# These targets are used from top-level makefile
diff --git a/scripts/kconfig/check.sh b/scripts/kconfig/check.sh
index 55b79ba1ba2a..97f0fee7d173 100755
--- a/scripts/kconfig/check.sh
+++ b/scripts/kconfig/check.sh
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2# Needed for systems without gettext 3# Needed for systems without gettext
3$* -x c -o /dev/null - > /dev/null 2>&1 << EOF 4$* -x c -o /dev/null - > /dev/null 2>&1 << EOF
4#include <libintl.h> 5#include <libintl.h>
diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h
index 2cf23f002d3f..45cb237ab7ef 100644
--- a/scripts/kconfig/list.h
+++ b/scripts/kconfig/list.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#ifndef LIST_H 2#ifndef LIST_H
2#define LIST_H 3#define LIST_H
3 4
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index d5398718ec2a..5d86e2dfae59 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#include <stdarg.h> 2#include <stdarg.h>
2 3
3/* confdata.c */ 4/* confdata.c */
diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh
index 5075ebf2d3b9..a10bd9d6fafd 100755
--- a/scripts/kconfig/lxdialog/check-lxdialog.sh
+++ b/scripts/kconfig/lxdialog/check-lxdialog.sh
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2# Check ncurses compatibility 3# Check ncurses compatibility
3 4
4# What library to link 5# What library to link
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 20136ffefb23..3c8bd9bb4267 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -1061,7 +1061,7 @@ struct symbol **sym_re_search(const char *pattern)
1061 } 1061 }
1062 if (sym_match_arr) { 1062 if (sym_match_arr) {
1063 qsort(sym_match_arr, cnt, sizeof(struct sym_match), sym_rel_comp); 1063 qsort(sym_match_arr, cnt, sizeof(struct sym_match), sym_rel_comp);
1064 sym_arr = malloc((cnt+1) * sizeof(struct symbol)); 1064 sym_arr = malloc((cnt+1) * sizeof(struct symbol *));
1065 if (!sym_arr) 1065 if (!sym_arr)
1066 goto sym_re_search_free; 1066 goto sym_re_search_free;
1067 for (i = 0; i < cnt; i++) 1067 for (i = 0; i < cnt; i++)
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 9d3eafea58f0..bd29a92b4b48 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -58,6 +58,7 @@ Output format selection (mutually exclusive):
58 -man Output troff manual page format. This is the default. 58 -man Output troff manual page format. This is the default.
59 -rst Output reStructuredText format. 59 -rst Output reStructuredText format.
60 -text Output plain text format. 60 -text Output plain text format.
61 -none Do not output documentation, only warnings.
61 62
62Output selection (mutually exclusive): 63Output selection (mutually exclusive):
63 -export Only output documentation for symbols that have been 64 -export Only output documentation for symbols that have been
@@ -532,6 +533,8 @@ while ($ARGV[0] =~ m/^-(.*)/) {
532 $output_mode = "gnome"; 533 $output_mode = "gnome";
533 @highlights = @highlights_gnome; 534 @highlights = @highlights_gnome;
534 $blankline = $blankline_gnome; 535 $blankline = $blankline_gnome;
536 } elsif ($cmd eq "-none") {
537 $output_mode = "none";
535 } elsif ($cmd eq "-module") { # not needed for XML, inherits from calling document 538 } elsif ($cmd eq "-module") { # not needed for XML, inherits from calling document
536 $modulename = shift @ARGV; 539 $modulename = shift @ARGV;
537 } elsif ($cmd eq "-function") { # to only output specific functions 540 } elsif ($cmd eq "-function") { # to only output specific functions
@@ -2117,6 +2120,24 @@ sub output_blockhead_list(%) {
2117 } 2120 }
2118} 2121}
2119 2122
2123
2124## none mode output functions
2125
2126sub output_function_none(%) {
2127}
2128
2129sub output_enum_none(%) {
2130}
2131
2132sub output_typedef_none(%) {
2133}
2134
2135sub output_struct_none(%) {
2136}
2137
2138sub output_blockhead_none(%) {
2139}
2140
2120## 2141##
2121# generic output function for all types (function, struct/union, typedef, enum); 2142# generic output function for all types (function, struct/union, typedef, enum);
2122# calls the generated, variable output_ function name based on 2143# calls the generated, variable output_ function name based on
@@ -2168,7 +2189,7 @@ sub dump_struct($$) {
2168 my $nested; 2189 my $nested;
2169 2190
2170 if ($x =~ /(struct|union)\s+(\w+)\s*{(.*)}/) { 2191 if ($x =~ /(struct|union)\s+(\w+)\s*{(.*)}/) {
2171 #my $decl_type = $1; 2192 my $decl_type = $1;
2172 $declaration_name = $2; 2193 $declaration_name = $2;
2173 my $members = $3; 2194 my $members = $3;
2174 2195
@@ -2182,8 +2203,6 @@ sub dump_struct($$) {
2182 # strip comments: 2203 # strip comments:
2183 $members =~ s/\/\*.*?\*\///gos; 2204 $members =~ s/\/\*.*?\*\///gos;
2184 $nested =~ s/\/\*.*?\*\///gos; 2205 $nested =~ s/\/\*.*?\*\///gos;
2185 # strip kmemcheck_bitfield_{begin,end}.*;
2186 $members =~ s/kmemcheck_bitfield_.*?;//gos;
2187 # strip attributes 2206 # strip attributes
2188 $members =~ s/__attribute__\s*\(\([a-z,_\*\s\(\)]*\)\)//i; 2207 $members =~ s/__attribute__\s*\(\([a-z,_\*\s\(\)]*\)\)//i;
2189 $members =~ s/__aligned\s*\([^;]*\)//gos; 2208 $members =~ s/__aligned\s*\([^;]*\)//gos;
@@ -2194,7 +2213,7 @@ sub dump_struct($$) {
2194 $members =~ s/DECLARE_HASHTABLE\s*\(([^,)]+), ([^,)]+)\)/unsigned long $1\[1 << (($2) - 1)\]/gos; 2213 $members =~ s/DECLARE_HASHTABLE\s*\(([^,)]+), ([^,)]+)\)/unsigned long $1\[1 << (($2) - 1)\]/gos;
2195 2214
2196 create_parameterlist($members, ';', $file); 2215 create_parameterlist($members, ';', $file);
2197 check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested); 2216 check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual, $nested);
2198 2217
2199 output_declaration($declaration_name, 2218 output_declaration($declaration_name,
2200 'struct', 2219 'struct',
@@ -2226,6 +2245,8 @@ sub dump_enum($$) {
2226 if ($x =~ /enum\s+(\w+)\s*{(.*)}/) { 2245 if ($x =~ /enum\s+(\w+)\s*{(.*)}/) {
2227 $declaration_name = $1; 2246 $declaration_name = $1;
2228 my $members = $2; 2247 my $members = $2;
2248 my %_members;
2249
2229 $members =~ s/\s+$//; 2250 $members =~ s/\s+$//;
2230 2251
2231 foreach my $arg (split ',', $members) { 2252 foreach my $arg (split ',', $members) {
@@ -2236,9 +2257,16 @@ sub dump_enum($$) {
2236 print STDERR "${file}:$.: warning: Enum value '$arg' ". 2257 print STDERR "${file}:$.: warning: Enum value '$arg' ".
2237 "not described in enum '$declaration_name'\n"; 2258 "not described in enum '$declaration_name'\n";
2238 } 2259 }
2239 2260 $_members{$arg} = 1;
2240 } 2261 }
2241 2262
2263 while (my ($k, $v) = each %parameterdescs) {
2264 if (!exists($_members{$k})) {
2265 print STDERR "${file}:$.: warning: Excess enum value " .
2266 "'$k' description in '$declaration_name'\n";
2267 }
2268 }
2269
2242 output_declaration($declaration_name, 2270 output_declaration($declaration_name,
2243 'enum', 2271 'enum',
2244 {'enum' => $declaration_name, 2272 {'enum' => $declaration_name,
@@ -2506,7 +2534,7 @@ sub check_sections($$$$$$) {
2506 } else { 2534 } else {
2507 if ($nested !~ m/\Q$sects[$sx]\E/) { 2535 if ($nested !~ m/\Q$sects[$sx]\E/) {
2508 print STDERR "${file}:$.: warning: " . 2536 print STDERR "${file}:$.: warning: " .
2509 "Excess struct/union/enum/typedef member " . 2537 "Excess $decl_type member " .
2510 "'$sects[$sx]' " . 2538 "'$sects[$sx]' " .
2511 "description in '$decl_name'\n"; 2539 "description in '$decl_name'\n";
2512 ++$warnings; 2540 ++$warnings;
@@ -3136,7 +3164,9 @@ sub process_file($) {
3136 } 3164 }
3137 } 3165 }
3138 if ($initial_section_counter == $section_counter) { 3166 if ($initial_section_counter == $section_counter) {
3139 print STDERR "${file}:1: warning: no structured comments found\n"; 3167 if ($output_mode ne "none") {
3168 print STDERR "${file}:1: warning: no structured comments found\n";
3169 }
3140 if (($output_selection == OUTPUT_INCLUDE) && ($show_not_found == 1)) { 3170 if (($output_selection == OUTPUT_INCLUDE) && ($show_not_found == 1)) {
3141 print STDERR " Was looking for '$_'.\n" for keys %function_table; 3171 print STDERR " Was looking for '$_'.\n" for keys %function_table;
3142 } 3172 }
diff --git a/scripts/ld-version.sh b/scripts/ld-version.sh
index d135882e2c40..f2be0ff9a738 100755
--- a/scripts/ld-version.sh
+++ b/scripts/ld-version.sh
@@ -1,4 +1,5 @@
1#!/usr/bin/awk -f 1#!/usr/bin/awk -f
2# SPDX-License-Identifier: GPL-2.0
2# extract linker version number from stdin and turn into single number 3# extract linker version number from stdin and turn into single number
3 { 4 {
4 gsub(".*\\)", ""); 5 gsub(".*\\)", "");
diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl
new file mode 100755
index 000000000000..bc5788000018
--- /dev/null
+++ b/scripts/leaking_addresses.pl
@@ -0,0 +1,501 @@
1#!/usr/bin/env perl
2#
3# (c) 2017 Tobin C. Harding <me@tobin.cc>
4# Licensed under the terms of the GNU GPL License version 2
5#
6# leaking_addresses.pl: Scan 64 bit kernel for potential leaking addresses.
7# - Scans dmesg output.
8# - Walks directory tree and parses each file (for each directory in @DIRS).
9#
10# Use --debug to output path before parsing, this is useful to find files that
11# cause the script to choke.
12#
13# You may like to set kptr_restrict=2 before running script
14# (see Documentation/sysctl/kernel.txt).
15
16use warnings;
17use strict;
18use POSIX;
19use File::Basename;
20use File::Spec;
21use Cwd 'abs_path';
22use Term::ANSIColor qw(:constants);
23use Getopt::Long qw(:config no_auto_abbrev);
24use Config;
25
26my $P = $0;
27my $V = '0.01';
28
29# Directories to scan.
30my @DIRS = ('/proc', '/sys');
31
32# Timer for parsing each file, in seconds.
33my $TIMEOUT = 10;
34
35# Script can only grep for kernel addresses on the following architectures. If
36# your architecture is not listed here and has a grep'able kernel address please
37# consider submitting a patch.
38my @SUPPORTED_ARCHITECTURES = ('x86_64', 'ppc64');
39
40# Command line options.
41my $help = 0;
42my $debug = 0;
43my $raw = 0;
44my $output_raw = ""; # Write raw results to file.
45my $input_raw = ""; # Read raw results from file instead of scanning.
46
47my $suppress_dmesg = 0; # Don't show dmesg in output.
48my $squash_by_path = 0; # Summary report grouped by absolute path.
49my $squash_by_filename = 0; # Summary report grouped by filename.
50
51# Do not parse these files (absolute path).
52my @skip_parse_files_abs = ('/proc/kmsg',
53 '/proc/kcore',
54 '/proc/fs/ext4/sdb1/mb_groups',
55 '/proc/1/fd/3',
56 '/sys/firmware/devicetree',
57 '/proc/device-tree',
58 '/sys/kernel/debug/tracing/trace_pipe',
59 '/sys/kernel/security/apparmor/revision');
60
61# Do not parse these files under any subdirectory.
62my @skip_parse_files_any = ('0',
63 '1',
64 '2',
65 'pagemap',
66 'events',
67 'access',
68 'registers',
69 'snapshot_raw',
70 'trace_pipe_raw',
71 'ptmx',
72 'trace_pipe');
73
74# Do not walk these directories (absolute path).
75my @skip_walk_dirs_abs = ();
76
77# Do not walk these directories under any subdirectory.
78my @skip_walk_dirs_any = ('self',
79 'thread-self',
80 'cwd',
81 'fd',
82 'usbmon',
83 'stderr',
84 'stdin',
85 'stdout');
86
87sub help
88{
89 my ($exitcode) = @_;
90
91 print << "EOM";
92
93Usage: $P [OPTIONS]
94Version: $V
95
96Options:
97
98 -o, --output-raw=<file> Save results for future processing.
99 -i, --input-raw=<file> Read results from file instead of scanning.
100 --raw Show raw results (default).
101 --suppress-dmesg Do not show dmesg results.
102 --squash-by-path Show one result per unique path.
103 --squash-by-filename Show one result per unique filename.
104 -d, --debug Display debugging output.
105 -h, --help, --version Display this help and exit.
106
107Examples:
108
109 # Scan kernel and dump raw results.
110 $0
111
112 # Scan kernel and save results to file.
113 $0 --output-raw scan.out
114
115 # View summary report.
116 $0 --input-raw scan.out --squash-by-filename
117
118Scans the running (64 bit) kernel for potential leaking addresses.
119
120EOM
121 exit($exitcode);
122}
123
124GetOptions(
125 'd|debug' => \$debug,
126 'h|help' => \$help,
127 'version' => \$help,
128 'o|output-raw=s' => \$output_raw,
129 'i|input-raw=s' => \$input_raw,
130 'suppress-dmesg' => \$suppress_dmesg,
131 'squash-by-path' => \$squash_by_path,
132 'squash-by-filename' => \$squash_by_filename,
133 'raw' => \$raw,
134) or help(1);
135
136help(0) if ($help);
137
138if ($input_raw) {
139 format_output($input_raw);
140 exit(0);
141}
142
143if (!$input_raw and ($squash_by_path or $squash_by_filename)) {
144 printf "\nSummary reporting only available with --input-raw=<file>\n";
145 printf "(First run scan with --output-raw=<file>.)\n";
146 exit(128);
147}
148
149if (!is_supported_architecture()) {
150 printf "\nScript does not support your architecture, sorry.\n";
151 printf "\nCurrently we support: \n\n";
152 foreach(@SUPPORTED_ARCHITECTURES) {
153 printf "\t%s\n", $_;
154 }
155
156 my $archname = $Config{archname};
157 printf "\n\$ perl -MConfig -e \'print \"\$Config{archname}\\n\"\'\n";
158 printf "%s\n", $archname;
159
160 exit(129);
161}
162
163if ($output_raw) {
164 open my $fh, '>', $output_raw or die "$0: $output_raw: $!\n";
165 select $fh;
166}
167
168parse_dmesg();
169walk(@DIRS);
170
171exit 0;
172
173sub dprint
174{
175 printf(STDERR @_) if $debug;
176}
177
178sub is_supported_architecture
179{
180 return (is_x86_64() or is_ppc64());
181}
182
183sub is_x86_64
184{
185 my $archname = $Config{archname};
186
187 if ($archname =~ m/x86_64/) {
188 return 1;
189 }
190 return 0;
191}
192
193sub is_ppc64
194{
195 my $archname = $Config{archname};
196
197 if ($archname =~ m/powerpc/ and $archname =~ m/64/) {
198 return 1;
199 }
200 return 0;
201}
202
203sub is_false_positive
204{
205 my ($match) = @_;
206
207 if ($match =~ '\b(0x)?(f|F){16}\b' or
208 $match =~ '\b(0x)?0{16}\b') {
209 return 1;
210 }
211
212 if (is_x86_64) {
213 # vsyscall memory region, we should probably check against a range here.
214 if ($match =~ '\bf{10}600000\b' or
215 $match =~ '\bf{10}601000\b') {
216 return 1;
217 }
218 }
219
220 return 0;
221}
222
223# True if argument potentially contains a kernel address.
224sub may_leak_address
225{
226 my ($line) = @_;
227 my $address_re;
228
229 # Signal masks.
230 if ($line =~ '^SigBlk:' or
231 $line =~ '^SigIgn:' or
232 $line =~ '^SigCgt:') {
233 return 0;
234 }
235
236 if ($line =~ '\bKEY=[[:xdigit:]]{14} [[:xdigit:]]{16} [[:xdigit:]]{16}\b' or
237 $line =~ '\b[[:xdigit:]]{14} [[:xdigit:]]{16} [[:xdigit:]]{16}\b') {
238 return 0;
239 }
240
241 # One of these is guaranteed to be true.
242 if (is_x86_64()) {
243 $address_re = '\b(0x)?ffff[[:xdigit:]]{12}\b';
244 } elsif (is_ppc64()) {
245 $address_re = '\b(0x)?[89abcdef]00[[:xdigit:]]{13}\b';
246 }
247
248 while (/($address_re)/g) {
249 if (!is_false_positive($1)) {
250 return 1;
251 }
252 }
253
254 return 0;
255}
256
257sub parse_dmesg
258{
259 open my $cmd, '-|', 'dmesg';
260 while (<$cmd>) {
261 if (may_leak_address($_)) {
262 print 'dmesg: ' . $_;
263 }
264 }
265 close $cmd;
266}
267
268# True if we should skip this path.
269sub skip
270{
271 my ($path, $paths_abs, $paths_any) = @_;
272
273 foreach (@$paths_abs) {
274 return 1 if (/^$path$/);
275 }
276
277 my($filename, $dirs, $suffix) = fileparse($path);
278 foreach (@$paths_any) {
279 return 1 if (/^$filename$/);
280 }
281
282 return 0;
283}
284
285sub skip_parse
286{
287 my ($path) = @_;
288 return skip($path, \@skip_parse_files_abs, \@skip_parse_files_any);
289}
290
291sub timed_parse_file
292{
293 my ($file) = @_;
294
295 eval {
296 local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required.
297 alarm $TIMEOUT;
298 parse_file($file);
299 alarm 0;
300 };
301
302 if ($@) {
303 die unless $@ eq "alarm\n"; # Propagate unexpected errors.
304 printf STDERR "timed out parsing: %s\n", $file;
305 }
306}
307
308sub parse_file
309{
310 my ($file) = @_;
311
312 if (! -R $file) {
313 return;
314 }
315
316 if (skip_parse($file)) {
317 dprint "skipping file: $file\n";
318 return;
319 }
320 dprint "parsing: $file\n";
321
322 open my $fh, "<", $file or return;
323 while ( <$fh> ) {
324 if (may_leak_address($_)) {
325 print $file . ': ' . $_;
326 }
327 }
328 close $fh;
329}
330
331
332# True if we should skip walking this directory.
333sub skip_walk
334{
335 my ($path) = @_;
336 return skip($path, \@skip_walk_dirs_abs, \@skip_walk_dirs_any)
337}
338
339# Recursively walk directory tree.
340sub walk
341{
342 my @dirs = @_;
343
344 while (my $pwd = shift @dirs) {
345 next if (skip_walk($pwd));
346 next if (!opendir(DIR, $pwd));
347 my @files = readdir(DIR);
348 closedir(DIR);
349
350 foreach my $file (@files) {
351 next if ($file eq '.' or $file eq '..');
352
353 my $path = "$pwd/$file";
354 next if (-l $path);
355
356 if (-d $path) {
357 push @dirs, $path;
358 } else {
359 timed_parse_file($path);
360 }
361 }
362 }
363}
364
365sub format_output
366{
367 my ($file) = @_;
368
369 # Default is to show raw results.
370 if ($raw or (!$squash_by_path and !$squash_by_filename)) {
371 dump_raw_output($file);
372 return;
373 }
374
375 my ($total, $dmesg, $paths, $files) = parse_raw_file($file);
376
377 printf "\nTotal number of results from scan (incl dmesg): %d\n", $total;
378
379 if (!$suppress_dmesg) {
380 print_dmesg($dmesg);
381 }
382
383 if ($squash_by_filename) {
384 squash_by($files, 'filename');
385 }
386
387 if ($squash_by_path) {
388 squash_by($paths, 'path');
389 }
390}
391
392sub dump_raw_output
393{
394 my ($file) = @_;
395
396 open (my $fh, '<', $file) or die "$0: $file: $!\n";
397 while (<$fh>) {
398 if ($suppress_dmesg) {
399 if ("dmesg:" eq substr($_, 0, 6)) {
400 next;
401 }
402 }
403 print $_;
404 }
405 close $fh;
406}
407
408sub parse_raw_file
409{
410 my ($file) = @_;
411
412 my $total = 0; # Total number of lines parsed.
413 my @dmesg; # dmesg output.
414 my %files; # Unique filenames containing leaks.
415 my %paths; # Unique paths containing leaks.
416
417 open (my $fh, '<', $file) or die "$0: $file: $!\n";
418 while (my $line = <$fh>) {
419 $total++;
420
421 if ("dmesg:" eq substr($line, 0, 6)) {
422 push @dmesg, $line;
423 next;
424 }
425
426 cache_path(\%paths, $line);
427 cache_filename(\%files, $line);
428 }
429
430 return $total, \@dmesg, \%paths, \%files;
431}
432
433sub print_dmesg
434{
435 my ($dmesg) = @_;
436
437 print "\ndmesg output:\n";
438
439 if (@$dmesg == 0) {
440 print "<no results>\n";
441 return;
442 }
443
444 foreach(@$dmesg) {
445 my $index = index($_, ': ');
446 $index += 2; # skid ': '
447 print substr($_, $index);
448 }
449}
450
451sub squash_by
452{
453 my ($ref, $desc) = @_;
454
455 print "\nResults squashed by $desc (excl dmesg). ";
456 print "Displaying [<number of results> <$desc>], <example result>\n";
457
458 if (keys %$ref == 0) {
459 print "<no results>\n";
460 return;
461 }
462
463 foreach(keys %$ref) {
464 my $lines = $ref->{$_};
465 my $length = @$lines;
466 printf "[%d %s] %s", $length, $_, @$lines[0];
467 }
468}
469
470sub cache_path
471{
472 my ($paths, $line) = @_;
473
474 my $index = index($line, ': ');
475 my $path = substr($line, 0, $index);
476
477 $index += 2; # skip ': '
478 add_to_cache($paths, $path, substr($line, $index));
479}
480
481sub cache_filename
482{
483 my ($files, $line) = @_;
484
485 my $index = index($line, ': ');
486 my $path = substr($line, 0, $index);
487 my $filename = basename($path);
488
489 $index += 2; # skip ': '
490 add_to_cache($files, $filename, substr($line, $index));
491}
492
493sub add_to_cache
494{
495 my ($cache, $key, $value) = @_;
496
497 if (!$cache->{$key}) {
498 $cache->{$key} = ();
499 }
500 push @{$cache->{$key}}, $value;
501}
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index e7b7eee31538..c0d129d7f430 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2# 3#
3# link vmlinux 4# link vmlinux
4# 5#
@@ -187,10 +188,8 @@ sortextable()
187# Delete output files in case of error 188# Delete output files in case of error
188cleanup() 189cleanup()
189{ 190{
190 rm -f .old_version
191 rm -f .tmp_System.map 191 rm -f .tmp_System.map
192 rm -f .tmp_kallsyms* 192 rm -f .tmp_kallsyms*
193 rm -f .tmp_version
194 rm -f .tmp_vmlinux* 193 rm -f .tmp_vmlinux*
195 rm -f built-in.o 194 rm -f built-in.o
196 rm -f System.map 195 rm -f System.map
@@ -238,12 +237,12 @@ esac
238 237
239# Update version 238# Update version
240info GEN .version 239info GEN .version
241if [ ! -r .version ]; then 240if [ -r .version ]; then
242 rm -f .version; 241 VERSION=$(expr 0$(cat .version) + 1)
243 echo 1 >.version; 242 echo $VERSION > .version
244else 243else
245 mv .version .old_version; 244 rm -f .version
246 expr 0$(cat .old_version) + 1 >.version; 245 echo 1 > .version
247fi; 246fi;
248 247
249# final build of init/ 248# final build of init/
@@ -331,6 +330,3 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
331 exit 1 330 exit 1
332 fi 331 fi
333fi 332fi
334
335# We made a new kernel - delete old version file
336rm -f .old_version
diff --git a/scripts/makelst b/scripts/makelst
index e6581496d820..e432af073a65 100755
--- a/scripts/makelst
+++ b/scripts/makelst
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2# A script to dump mixed source code & assembly 3# A script to dump mixed source code & assembly
3# with correct relocations from System.map 4# with correct relocations from System.map
4# Requires the following lines in makefile: 5# Requires the following lines in makefile:
diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
index fd8fdb91581d..87f1fc9801d7 100755
--- a/scripts/mkcompile_h
+++ b/scripts/mkcompile_h
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2 3
3TARGET=$1 4TARGET=$1
4ARCH=$2 5ARCH=$2
@@ -27,12 +28,7 @@ LC_ALL=C
27export LC_ALL 28export LC_ALL
28 29
29if [ -z "$KBUILD_BUILD_VERSION" ]; then 30if [ -z "$KBUILD_BUILD_VERSION" ]; then
30 if [ -r .version ]; then 31 VERSION=$(cat .version 2>/dev/null || echo 1)
31 VERSION=`cat .version`
32 else
33 VERSION=0
34 echo 0 > .version
35 fi
36else 32else
37 VERSION=$KBUILD_BUILD_VERSION 33 VERSION=$KBUILD_BUILD_VERSION
38fi 34fi
diff --git a/scripts/mkmakefile b/scripts/mkmakefile
index 84af27bf0f99..e19d6565f245 100755
--- a/scripts/mkmakefile
+++ b/scripts/mkmakefile
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2# Generates a small Makefile used in the root of the output 3# Generates a small Makefile used in the root of the output
3# directory, to allow make to be started from there. 4# directory, to allow make to be started from there.
4# The Makefile also allow for more convinient build of external modules 5# The Makefile also allow for more convinient build of external modules
diff --git a/scripts/mkuboot.sh b/scripts/mkuboot.sh
index 446739c7843a..4b1fe09e9042 100755
--- a/scripts/mkuboot.sh
+++ b/scripts/mkuboot.sh
@@ -1,4 +1,5 @@
1#!/bin/bash 1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
2 3
3# 4#
4# Build U-Boot image when `mkimage' tool is available. 5# Build U-Boot image when `mkimage' tool is available.
diff --git a/scripts/mkversion b/scripts/mkversion
deleted file mode 100644
index c12addc9c7ef..000000000000
--- a/scripts/mkversion
+++ /dev/null
@@ -1,6 +0,0 @@
1if [ ! -f .version ]
2then
3 echo 1
4else
5 expr 0`cat .version` + 1
6fi
diff --git a/scripts/mod/Makefile b/scripts/mod/Makefile
index b497d9764dcf..42c5d50f2bcc 100644
--- a/scripts/mod/Makefile
+++ b/scripts/mod/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1OBJECT_FILES_NON_STANDARD := y 2OBJECT_FILES_NON_STANDARD := y
2 3
3hostprogs-y := modpost mk_elfconfig 4hostprogs-y := modpost mk_elfconfig
diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c
index e4d90e50f6fe..9826b9a6543c 100644
--- a/scripts/mod/devicetable-offsets.c
+++ b/scripts/mod/devicetable-offsets.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <linux/kbuild.h> 2#include <linux/kbuild.h>
2#include <linux/mod_devicetable.h> 3#include <linux/mod_devicetable.h>
3 4
@@ -206,5 +207,12 @@ int main(void)
206 DEVID_FIELD(fsl_mc_device_id, vendor); 207 DEVID_FIELD(fsl_mc_device_id, vendor);
207 DEVID_FIELD(fsl_mc_device_id, obj_type); 208 DEVID_FIELD(fsl_mc_device_id, obj_type);
208 209
210 DEVID(tb_service_id);
211 DEVID_FIELD(tb_service_id, match_flags);
212 DEVID_FIELD(tb_service_id, protocol_key);
213 DEVID_FIELD(tb_service_id, protocol_id);
214 DEVID_FIELD(tb_service_id, protocol_version);
215 DEVID_FIELD(tb_service_id, protocol_revision);
216
209 return 0; 217 return 0;
210} 218}
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 29d6699d5a06..6ef6e63f96fd 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -1301,6 +1301,31 @@ static int do_fsl_mc_entry(const char *filename, void *symval,
1301} 1301}
1302ADD_TO_DEVTABLE("fslmc", fsl_mc_device_id, do_fsl_mc_entry); 1302ADD_TO_DEVTABLE("fslmc", fsl_mc_device_id, do_fsl_mc_entry);
1303 1303
1304/* Looks like: tbsvc:kSpNvNrN */
1305static int do_tbsvc_entry(const char *filename, void *symval, char *alias)
1306{
1307 DEF_FIELD(symval, tb_service_id, match_flags);
1308 DEF_FIELD_ADDR(symval, tb_service_id, protocol_key);
1309 DEF_FIELD(symval, tb_service_id, protocol_id);
1310 DEF_FIELD(symval, tb_service_id, protocol_version);
1311 DEF_FIELD(symval, tb_service_id, protocol_revision);
1312
1313 strcpy(alias, "tbsvc:");
1314 if (match_flags & TBSVC_MATCH_PROTOCOL_KEY)
1315 sprintf(alias + strlen(alias), "k%s", *protocol_key);
1316 else
1317 strcat(alias + strlen(alias), "k*");
1318 ADD(alias, "p", match_flags & TBSVC_MATCH_PROTOCOL_ID, protocol_id);
1319 ADD(alias, "v", match_flags & TBSVC_MATCH_PROTOCOL_VERSION,
1320 protocol_version);
1321 ADD(alias, "r", match_flags & TBSVC_MATCH_PROTOCOL_REVISION,
1322 protocol_revision);
1323
1324 add_wildcard(alias);
1325 return 1;
1326}
1327ADD_TO_DEVTABLE("tbsvc", tb_service_id, do_tbsvc_entry);
1328
1304/* Does namelen bytes of name exactly match the symbol? */ 1329/* Does namelen bytes of name exactly match the symbol? */
1305static bool sym_is(const char *name, unsigned namelen, const char *symbol) 1330static bool sym_is(const char *name, unsigned namelen, const char *symbol)
1306{ 1331{
diff --git a/scripts/mod/mk_elfconfig.c b/scripts/mod/mk_elfconfig.c
index a4fd71d71d65..680eade89be1 100644
--- a/scripts/mod/mk_elfconfig.c
+++ b/scripts/mod/mk_elfconfig.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1#include <stdio.h> 2#include <stdio.h>
2#include <stdlib.h> 3#include <stdlib.h>
3#include <string.h> 4#include <string.h>
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 98314b400a95..f51cf977c65b 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1963,7 +1963,7 @@ static void read_symbols(char *modname)
1963 } 1963 }
1964 1964
1965 license = get_modinfo(info.modinfo, info.modinfo_len, "license"); 1965 license = get_modinfo(info.modinfo, info.modinfo_len, "license");
1966 if (info.modinfo && !license && !is_vmlinux(modname)) 1966 if (!license && !is_vmlinux(modname))
1967 warn("modpost: missing MODULE_LICENSE() in %s\n" 1967 warn("modpost: missing MODULE_LICENSE() in %s\n"
1968 "see include/linux/module.h for " 1968 "see include/linux/module.h for "
1969 "more information\n", modname); 1969 "more information\n", modname);
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index 6a5e1515123b..8453d6ac2f77 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -1,3 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1#include <stdio.h> 2#include <stdio.h>
2#include <stdlib.h> 3#include <stdlib.h>
3#include <stdarg.h> 4#include <stdarg.h>
diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index 71b4a8af9d4d..c23534925b38 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -39,33 +39,28 @@ if test "$(objtree)" != "$(srctree)"; then \
39 false; \ 39 false; \
40fi ; \ 40fi ; \
41$(srctree)/scripts/setlocalversion --save-scmversion; \ 41$(srctree)/scripts/setlocalversion --save-scmversion; \
42ln -sf $(srctree) $(2); \
43tar -cz $(RCS_TAR_IGNORE) -f $(2).tar.gz \ 42tar -cz $(RCS_TAR_IGNORE) -f $(2).tar.gz \
44 $(addprefix $(2)/,$(TAR_CONTENT) $(3)); \ 43 --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3); \
45rm -f $(2) $(objtree)/.scmversion 44rm -f $(objtree)/.scmversion
46 45
47# rpm-pkg 46# rpm-pkg
48# --------------------------------------------------------------------------- 47# ---------------------------------------------------------------------------
49rpm-pkg rpm: FORCE 48rpm-pkg: FORCE
50 $(MAKE) clean 49 $(MAKE) clean
51 $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec 50 $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
52 $(call cmd,src_tar,$(KERNELPATH),kernel.spec) 51 $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
53 $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version 52 +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz \
54 mv -f $(objtree)/.tmp_version $(objtree)/.version 53 --define='_smp_mflags %{nil}'
55 rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz
56 rm $(KERNELPATH).tar.gz kernel.spec
57 54
58# binrpm-pkg 55# binrpm-pkg
59# --------------------------------------------------------------------------- 56# ---------------------------------------------------------------------------
60binrpm-pkg: FORCE 57binrpm-pkg: FORCE
61 $(MAKE) KBUILD_SRC= 58 $(MAKE) KBUILD_SRC=
62 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec 59 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
63 $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version 60 +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
64 mv -f $(objtree)/.tmp_version $(objtree)/.version
65
66 rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
67 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec 61 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec
68 rm binkernel.spec 62
63clean-files += $(objtree)/*.spec
69 64
70# Deb target 65# Deb target
71# --------------------------------------------------------------------------- 66# ---------------------------------------------------------------------------
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index aad67000e4dd..b4f0f2b3f8d2 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -92,12 +92,10 @@ else
92fi 92fi
93sourcename=$KDEB_SOURCENAME 93sourcename=$KDEB_SOURCENAME
94tmpdir="$objtree/debian/tmp" 94tmpdir="$objtree/debian/tmp"
95fwdir="$objtree/debian/fwtmp"
96kernel_headers_dir="$objtree/debian/hdrtmp" 95kernel_headers_dir="$objtree/debian/hdrtmp"
97libc_headers_dir="$objtree/debian/headertmp" 96libc_headers_dir="$objtree/debian/headertmp"
98dbg_dir="$objtree/debian/dbgtmp" 97dbg_dir="$objtree/debian/dbgtmp"
99packagename=linux-image-$version 98packagename=linux-image-$version
100fwpackagename=linux-firmware-image-$version
101kernel_headers_packagename=linux-headers-$version 99kernel_headers_packagename=linux-headers-$version
102libc_headers_packagename=linux-libc-dev 100libc_headers_packagename=linux-libc-dev
103dbg_packagename=$packagename-dbg 101dbg_packagename=$packagename-dbg
@@ -126,10 +124,9 @@ esac
126BUILD_DEBUG="$(grep -s '^CONFIG_DEBUG_INFO=y' $KCONFIG_CONFIG || true)" 124BUILD_DEBUG="$(grep -s '^CONFIG_DEBUG_INFO=y' $KCONFIG_CONFIG || true)"
127 125
128# Setup the directory structure 126# Setup the directory structure
129rm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir" $objtree/debian/files 127rm -rf "$tmpdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir" $objtree/debian/files
130mkdir -m 755 -p "$tmpdir/DEBIAN" 128mkdir -m 755 -p "$tmpdir/DEBIAN"
131mkdir -p "$tmpdir/lib" "$tmpdir/boot" 129mkdir -p "$tmpdir/lib" "$tmpdir/boot"
132mkdir -p "$fwdir/lib/firmware/$version/"
133mkdir -p "$kernel_headers_dir/lib/modules/$version/" 130mkdir -p "$kernel_headers_dir/lib/modules/$version/"
134 131
135# Build and install the kernel 132# Build and install the kernel
@@ -306,7 +303,6 @@ else
306 cat <<EOF >> debian/control 303 cat <<EOF >> debian/control
307 304
308Package: $packagename 305Package: $packagename
309Suggests: $fwpackagename
310Architecture: any 306Architecture: any
311Description: Linux kernel, version $version 307Description: Linux kernel, version $version
312 This package contains the Linux kernel, modules and corresponding other 308 This package contains the Linux kernel, modules and corresponding other
@@ -345,22 +341,6 @@ Description: Linux kernel headers for $KERNELRELEASE on \${kernel:debarch}
345 This is useful for people who need to build external modules 341 This is useful for people who need to build external modules
346EOF 342EOF
347 343
348# Do we have firmware? Move it out of the way and build it into a package.
349if [ -e "$tmpdir/lib/firmware" ]; then
350 mv "$tmpdir/lib/firmware"/* "$fwdir/lib/firmware/$version/"
351 rmdir "$tmpdir/lib/firmware"
352
353 cat <<EOF >> debian/control
354
355Package: $fwpackagename
356Architecture: all
357Description: Linux kernel firmware, version $version
358 This package contains firmware from the Linux kernel, version $version.
359EOF
360
361 create_package "$fwpackagename" "$fwdir"
362fi
363
364cat <<EOF >> debian/control 344cat <<EOF >> debian/control
365 345
366Package: $libc_headers_packagename 346Package: $libc_headers_packagename
@@ -428,9 +408,9 @@ EOF
428 dpkg-source -cdebian/control -ldebian/changelog --format="3.0 (custom)" --target-format="3.0 (quilt)" \ 408 dpkg-source -cdebian/control -ldebian/changelog --format="3.0 (custom)" --target-format="3.0 (quilt)" \
429 -b / ../${sourcename}_${version}.orig.tar.gz ../${sourcename}_${packageversion}.debian.tar.gz 409 -b / ../${sourcename}_${version}.orig.tar.gz ../${sourcename}_${packageversion}.debian.tar.gz
430 mv ${sourcename}_${packageversion}*dsc .. 410 mv ${sourcename}_${packageversion}*dsc ..
431 dpkg-genchanges > ../${sourcename}_${packageversion}_${debarch}.changes 411 dpkg-genchanges -Vkernel:debarch="${debarch}" > ../${sourcename}_${packageversion}_${debarch}.changes
432else 412else
433 dpkg-genchanges -b > ../${sourcename}_${packageversion}_${debarch}.changes 413 dpkg-genchanges -b -Vkernel:debarch="${debarch}" > ../${sourcename}_${packageversion}_${debarch}.changes
434fi 414fi
435 415
436exit 0 416exit 0
diff --git a/scripts/package/buildtar b/scripts/package/buildtar
index 51f947118256..e8cc72a51b32 100755
--- a/scripts/package/buildtar
+++ b/scripts/package/buildtar
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2 3
3# 4#
4# buildtar 0.0.4 5# buildtar 0.0.4
diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index bb43f153fd8e..280027fad991 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -10,162 +10,135 @@
10# 10#
11 11
12# how we were called determines which rpms we build and how we build them 12# how we were called determines which rpms we build and how we build them
13if [ "$1" = "prebuilt" ]; then 13if [ "$1" = prebuilt ]; then
14 PREBUILT=true 14 S=DEL
15else 15else
16 PREBUILT=false 16 S=
17fi 17fi
18 18
19# starting to output the spec 19if grep -q CONFIG_MODULES=y .config; then
20if [ "`grep CONFIG_DRM=y .config | cut -f2 -d\=`" = "y" ]; then 20 M=
21 PROVIDES=kernel-drm 21else
22fi 22 M=DEL
23
24PROVIDES="$PROVIDES kernel-$KERNELRELEASE"
25__KERNELRELEASE=`echo $KERNELRELEASE | sed -e "s/-/_/g"`
26
27echo "Name: kernel"
28echo "Summary: The Linux Kernel"
29echo "Version: $__KERNELRELEASE"
30# we need to determine the NEXT version number so that uname and
31# rpm -q will agree
32echo "Release: `. $srctree/scripts/mkversion`"
33echo "License: GPL"
34echo "Group: System Environment/Kernel"
35echo "Vendor: The Linux Community"
36echo "URL: http://www.kernel.org"
37
38if ! $PREBUILT; then
39echo "Source: kernel-$__KERNELRELEASE.tar.gz"
40fi
41
42echo "BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION}-root"
43echo "Provides: $PROVIDES"
44echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :"
45echo "%define debug_package %{nil}"
46echo ""
47echo "%description"
48echo "The Linux Kernel, the operating system core itself"
49echo ""
50echo "%package headers"
51echo "Summary: Header files for the Linux kernel for use by glibc"
52echo "Group: Development/System"
53echo "Obsoletes: kernel-headers"
54echo "Provides: kernel-headers = %{version}"
55echo "%description headers"
56echo "Kernel-headers includes the C header files that specify the interface"
57echo "between the Linux kernel and userspace libraries and programs. The"
58echo "header files define structures and constants that are needed for"
59echo "building most standard programs and are also needed for rebuilding the"
60echo "glibc package."
61echo ""
62echo "%package devel"
63echo "Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel"
64echo "Group: System Environment/Kernel"
65echo "AutoReqProv: no"
66echo "%description -n kernel-devel"
67echo "This package provides kernel headers and makefiles sufficient to build modules"
68echo "against the $__KERNELRELEASE kernel package."
69echo ""
70
71if ! $PREBUILT; then
72echo "%prep"
73echo "%setup -q"
74echo ""
75fi 23fi
76 24
77echo "%build" 25if grep -q CONFIG_DRM=y .config; then
78 26 PROVIDES=kernel-drm
79if ! $PREBUILT; then
80echo "make clean && make %{?_smp_mflags}"
81echo ""
82fi 27fi
83 28
84echo "%install" 29PROVIDES="$PROVIDES kernel-$KERNELRELEASE"
85echo 'KBUILD_IMAGE=$(make image_name)' 30__KERNELRELEASE=$(echo $KERNELRELEASE | sed -e "s/-/_/g")
86echo "%ifarch ia64" 31EXCLUDES="$RCS_TAR_IGNORE --exclude=.tmp_versions --exclude=*vmlinux* \
87echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules' 32--exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \
88echo "%else" 33--exclude=.config.old --exclude=.missing-syscalls.d"
89echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules'
90echo "%endif"
91echo 'mkdir -p $RPM_BUILD_ROOT'"/lib/firmware/$KERNELRELEASE"
92
93echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{?_smp_mflags} KBUILD_SRC= mod-fw= modules_install'
94echo 'INSTALL_FW_PATH=$RPM_BUILD_ROOT'"/lib/firmware/$KERNELRELEASE"
95echo 'make INSTALL_FW_PATH=$INSTALL_FW_PATH' firmware_install
96echo "%ifarch ia64"
97echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE"
98echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/"
99echo "%else"
100echo "%ifarch ppc64"
101echo "cp vmlinux arch/powerpc/boot"
102echo "cp arch/powerpc/boot/"'$KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
103echo "%else"
104echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
105echo "%endif"
106echo "%endif"
107
108echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install'
109echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE"
110
111echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE"
112
113echo "%ifnarch ppc64"
114echo 'bzip2 -9 --keep vmlinux'
115echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2"
116echo "%endif"
117
118if ! $PREBUILT; then
119echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/build"
120echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/source"
121echo "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE"
122echo "EXCLUDES=\"$RCS_TAR_IGNORE --exclude .tmp_versions --exclude=*vmlinux* --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation --exclude=firmware --exclude .config.old --exclude .missing-syscalls.d\""
123echo "tar "'$EXCLUDES'" -cf- . | (cd "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE;tar xvf -)"
124echo 'cd $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE"
125echo "ln -sf /usr/src/kernels/$KERNELRELEASE build"
126echo "ln -sf /usr/src/kernels/$KERNELRELEASE source"
127fi
128 34
129echo "" 35# We can label the here-doc lines for conditional output to the spec file
130echo "%clean" 36#
131echo 'rm -rf $RPM_BUILD_ROOT' 37# Labels:
132echo "" 38# $S: this line is enabled only when building source package
133echo "%post" 39# $M: this line is enabled only when CONFIG_MODULES is enabled
134echo "if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then" 40sed -e '/^DEL/d' -e 's/^\t*//' <<EOF
135echo "cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm" 41 Name: kernel
136echo "cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm" 42 Summary: The Linux Kernel
137echo "rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE" 43 Version: $__KERNELRELEASE
138echo "/sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm" 44 Release: $(cat .version 2>/dev/null || echo 1)
139echo "rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm" 45 License: GPL
140echo "fi" 46 Group: System Environment/Kernel
141echo "" 47 Vendor: The Linux Community
142echo "%preun" 48 URL: http://www.kernel.org
143echo "if [ -x /sbin/new-kernel-pkg ]; then" 49$S Source: kernel-$__KERNELRELEASE.tar.gz
144echo "new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img" 50 Provides: $PROVIDES
145echo "fi" 51 %define __spec_install_post /usr/lib/rpm/brp-compress || :
146echo "" 52 %define debug_package %{nil}
147echo "%postun" 53
148echo "if [ -x /sbin/update-bootloader ]; then" 54 %description
149echo "/sbin/update-bootloader --remove $KERNELRELEASE" 55 The Linux Kernel, the operating system core itself
150echo "fi" 56
151echo "" 57 %package headers
152echo "%files" 58 Summary: Header files for the Linux kernel for use by glibc
153echo '%defattr (-, root, root)' 59 Group: Development/System
154echo "/lib/modules/$KERNELRELEASE" 60 Obsoletes: kernel-headers
155echo "%exclude /lib/modules/$KERNELRELEASE/build" 61 Provides: kernel-headers = %{version}
156echo "%exclude /lib/modules/$KERNELRELEASE/source" 62 %description headers
157echo "/lib/firmware/$KERNELRELEASE" 63 Kernel-headers includes the C header files that specify the interface
158echo "/boot/*" 64 between the Linux kernel and userspace libraries and programs. The
159echo "" 65 header files define structures and constants that are needed for
160echo "%files headers" 66 building most standard programs and are also needed for rebuilding the
161echo '%defattr (-, root, root)' 67 glibc package.
162echo "/usr/include" 68
163echo "" 69$S$M %package devel
164if ! $PREBUILT; then 70$S$M Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel
165echo "%files devel" 71$S$M Group: System Environment/Kernel
166echo '%defattr (-, root, root)' 72$S$M AutoReqProv: no
167echo "/usr/src/kernels/$KERNELRELEASE" 73$S$M %description -n kernel-devel
168echo "/lib/modules/$KERNELRELEASE/build" 74$S$M This package provides kernel headers and makefiles sufficient to build modules
169echo "/lib/modules/$KERNELRELEASE/source" 75$S$M against the $__KERNELRELEASE kernel package.
170echo "" 76$S$M
171fi 77$S %prep
78$S %setup -q
79$S
80$S %build
81$S make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}
82$S
83 %install
84 mkdir -p %{buildroot}/boot
85 %ifarch ia64
86 mkdir -p %{buildroot}/boot/efi
87 cp \$(make image_name) %{buildroot}/boot/efi/vmlinuz-$KERNELRELEASE
88 ln -s efi/vmlinuz-$KERNELRELEASE %{buildroot}/boot/
89 %else
90 cp \$(make image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE
91 %endif
92$M make %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} KBUILD_SRC= modules_install
93 make %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr KBUILD_SRC= headers_install
94 cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE
95 cp .config %{buildroot}/boot/config-$KERNELRELEASE
96 bzip2 -9 --keep vmlinux
97 mv vmlinux.bz2 %{buildroot}/boot/vmlinux-$KERNELRELEASE.bz2
98$S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build
99$S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/source
100$S$M mkdir -p %{buildroot}/usr/src/kernels/$KERNELRELEASE
101$S$M tar cf - . $EXCLUDES | tar xf - -C %{buildroot}/usr/src/kernels/$KERNELRELEASE
102$S$M cd %{buildroot}/lib/modules/$KERNELRELEASE
103$S$M ln -sf /usr/src/kernels/$KERNELRELEASE build
104$S$M ln -sf /usr/src/kernels/$KERNELRELEASE source
105
106 %clean
107 rm -rf %{buildroot}
108
109 %post
110 if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then
111 cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm
112 cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm
113 rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE
114 /sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm
115 rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm
116 fi
117
118 %preun
119 if [ -x /sbin/new-kernel-pkg ]; then
120 new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img
121 fi
122
123 %postun
124 if [ -x /sbin/update-bootloader ]; then
125 /sbin/update-bootloader --remove $KERNELRELEASE
126 fi
127
128 %files
129 %defattr (-, root, root)
130$M /lib/modules/$KERNELRELEASE
131$M %exclude /lib/modules/$KERNELRELEASE/build
132$M %exclude /lib/modules/$KERNELRELEASE/source
133 /boot/*
134
135 %files headers
136 %defattr (-, root, root)
137 /usr/include
138$S$M
139$S$M %files devel
140$S$M %defattr (-, root, root)
141$S$M /usr/src/kernels/$KERNELRELEASE
142$S$M /lib/modules/$KERNELRELEASE/build
143$S$M /lib/modules/$KERNELRELEASE/source
144EOF
diff --git a/scripts/parse-maintainers.pl b/scripts/parse-maintainers.pl
index e40b53db7f9f..255cef1b098d 100644
--- a/scripts/parse-maintainers.pl
+++ b/scripts/parse-maintainers.pl
@@ -1,9 +1,45 @@
1#!/usr/bin/perl -w 1#!/usr/bin/perl -w
2# SPDX-License-Identifier: GPL-2.0
2 3
3use strict; 4use strict;
5use Getopt::Long qw(:config no_auto_abbrev);
6
7my $input_file = "MAINTAINERS";
8my $output_file = "MAINTAINERS.new";
9my $output_section = "SECTION.new";
10my $help = 0;
4 11
5my $P = $0; 12my $P = $0;
6 13
14if (!GetOptions(
15 'input=s' => \$input_file,
16 'output=s' => \$output_file,
17 'section=s' => \$output_section,
18 'h|help|usage' => \$help,
19 )) {
20 die "$P: invalid argument - use --help if necessary\n";
21}
22
23if ($help != 0) {
24 usage();
25 exit 0;
26}
27
28sub usage {
29 print <<EOT;
30usage: $P [options] <pattern matching regexes>
31
32 --input => MAINTAINERS file to read (default: MAINTAINERS)
33 --output => sorted MAINTAINERS file to write (default: MAINTAINERS.new)
34 --section => new sorted MAINTAINERS file to write to (default: SECTION.new)
35
36If <pattern match regexes> exist, then the sections that match the
37regexes are not written to the output file but are written to the
38section file.
39
40EOT
41}
42
7# sort comparison functions 43# sort comparison functions
8sub by_category($$) { 44sub by_category($$) {
9 my ($a, $b) = @_; 45 my ($a, $b) = @_;
@@ -55,13 +91,20 @@ sub trim {
55sub alpha_output { 91sub alpha_output {
56 my ($hashref, $filename) = (@_); 92 my ($hashref, $filename) = (@_);
57 93
94 return if ! scalar(keys %$hashref);
95
58 open(my $file, '>', "$filename") or die "$P: $filename: open failed - $!\n"; 96 open(my $file, '>', "$filename") or die "$P: $filename: open failed - $!\n";
97 my $separator;
59 foreach my $key (sort by_category keys %$hashref) { 98 foreach my $key (sort by_category keys %$hashref) {
60 if ($key eq " ") { 99 if ($key eq " ") {
61 chomp $$hashref{$key};
62 print $file $$hashref{$key}; 100 print $file $$hashref{$key};
63 } else { 101 } else {
64 print $file "\n" . $key . "\n"; 102 if (! defined $separator) {
103 $separator = "\n";
104 } else {
105 print $file $separator;
106 }
107 print $file $key . "\n";
65 foreach my $pattern (sort by_pattern split('\n', %$hashref{$key})) { 108 foreach my $pattern (sort by_pattern split('\n', %$hashref{$key})) {
66 print $file ($pattern . "\n"); 109 print $file ($pattern . "\n");
67 } 110 }
@@ -111,7 +154,7 @@ sub file_input {
111my %hash; 154my %hash;
112my %new_hash; 155my %new_hash;
113 156
114file_input(\%hash, "MAINTAINERS"); 157file_input(\%hash, $input_file);
115 158
116foreach my $type (@ARGV) { 159foreach my $type (@ARGV) {
117 foreach my $key (keys %hash) { 160 foreach my $key (keys %hash) {
@@ -122,7 +165,7 @@ foreach my $type (@ARGV) {
122 } 165 }
123} 166}
124 167
125alpha_output(\%hash, "MAINTAINERS.new"); 168alpha_output(\%hash, $output_file);
126alpha_output(\%new_hash, "SECTION.new"); 169alpha_output(\%new_hash, $output_section);
127 170
128exit(0); 171exit(0);
diff --git a/scripts/patch-kernel b/scripts/patch-kernel
index 49b4241e814a..033d5916797d 100755
--- a/scripts/patch-kernel
+++ b/scripts/patch-kernel
@@ -1,4 +1,5 @@
1#! /bin/sh 1#! /bin/sh
2# SPDX-License-Identifier: GPL-2.0
2# Script to apply kernel patches. 3# Script to apply kernel patches.
3# usage: patch-kernel [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ] 4# usage: patch-kernel [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ]
4# The source directory defaults to /usr/src/linux, and the patch 5# The source directory defaults to /usr/src/linux, and the patch
diff --git a/scripts/profile2linkerlist.pl b/scripts/profile2linkerlist.pl
index f23d7be94394..316e71918ac8 100755
--- a/scripts/profile2linkerlist.pl
+++ b/scripts/profile2linkerlist.pl
@@ -1,4 +1,5 @@
1#!/usr/bin/env perl 1#!/usr/bin/env perl
2# SPDX-License-Identifier: GPL-2.0
2 3
3# 4#
4# Takes a (sorted) output of readprofile and turns it into a list suitable for 5# Takes a (sorted) output of readprofile and turns it into a list suitable for
diff --git a/scripts/prune-kernel b/scripts/prune-kernel
index ab5034e1d081..e8aa940bc0a9 100755
--- a/scripts/prune-kernel
+++ b/scripts/prune-kernel
@@ -1,4 +1,5 @@
1#!/bin/bash 1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
2 3
3# because I use CONFIG_LOCALVERSION_AUTO, not the same version again and 4# because I use CONFIG_LOCALVERSION_AUTO, not the same version again and
4# again, /boot and /lib/modules/ eventually fill up. 5# again, /boot and /lib/modules/ eventually fill up.
diff --git a/scripts/selinux/Makefile b/scripts/selinux/Makefile
index e8049da1831f..b3048b894a39 100644
--- a/scripts/selinux/Makefile
+++ b/scripts/selinux/Makefile
@@ -1,2 +1 @@
1subdir-y := mdp genheaders subdir-y := mdp genheaders
2subdir- += mdp genheaders
diff --git a/scripts/selinux/genheaders/Makefile b/scripts/selinux/genheaders/Makefile
index 6fc2b8789a0b..e8c533140981 100644
--- a/scripts/selinux/genheaders/Makefile
+++ b/scripts/selinux/genheaders/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1hostprogs-y := genheaders 2hostprogs-y := genheaders
2HOST_EXTRACFLAGS += \ 3HOST_EXTRACFLAGS += \
3 -I$(srctree)/include/uapi -I$(srctree)/include \ 4 -I$(srctree)/include/uapi -I$(srctree)/include \
diff --git a/scripts/selinux/genheaders/genheaders.c b/scripts/selinux/genheaders/genheaders.c
index 672b069dcfea..fa48fabcb330 100644
--- a/scripts/selinux/genheaders/genheaders.c
+++ b/scripts/selinux/genheaders/genheaders.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1 2
2/* NOTE: we really do want to use the kernel headers here */ 3/* NOTE: we really do want to use the kernel headers here */
3#define __EXPORTED_HEADERS__ 4#define __EXPORTED_HEADERS__
diff --git a/scripts/selinux/install_policy.sh b/scripts/selinux/install_policy.sh
index f6a0ce71015f..0b86c47baf7d 100755
--- a/scripts/selinux/install_policy.sh
+++ b/scripts/selinux/install_policy.sh
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2if [ `id -u` -ne 0 ]; then 3if [ `id -u` -ne 0 ]; then
3 echo "$0: must be root to install the selinux policy" 4 echo "$0: must be root to install the selinux policy"
4 exit 1 5 exit 1
diff --git a/scripts/selinux/mdp/Makefile b/scripts/selinux/mdp/Makefile
index d6a83cafe59f..e9c92db7e2a3 100644
--- a/scripts/selinux/mdp/Makefile
+++ b/scripts/selinux/mdp/Makefile
@@ -1,3 +1,4 @@
1# SPDX-License-Identifier: GPL-2.0
1hostprogs-y := mdp 2hostprogs-y := mdp
2HOST_EXTRACFLAGS += \ 3HOST_EXTRACFLAGS += \
3 -I$(srctree)/include/uapi -I$(srctree)/include \ 4 -I$(srctree)/include/uapi -I$(srctree)/include \
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 966dd3924ea9..71f39410691b 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2# 3#
3# This scripts adds local version information from the version 4# This scripts adds local version information from the version
4# control systems git, mercurial (hg) and subversion (svn). 5# control systems git, mercurial (hg) and subversion (svn).
diff --git a/scripts/spelling.txt b/scripts/spelling.txt
index 400ef35169c5..9a058cff49d4 100644
--- a/scripts/spelling.txt
+++ b/scripts/spelling.txt
@@ -53,6 +53,7 @@ acumulator||accumulator
53adapater||adapter 53adapater||adapter
54addional||additional 54addional||additional
55additionaly||additionally 55additionaly||additionally
56additonal||additional
56addres||address 57addres||address
57adddress||address 58adddress||address
58addreses||addresses 59addreses||addresses
@@ -67,6 +68,8 @@ adviced||advised
67afecting||affecting 68afecting||affecting
68againt||against 69againt||against
69agaist||against 70agaist||against
71aggreataon||aggregation
72aggreation||aggregation
70albumns||albums 73albumns||albums
71alegorical||allegorical 74alegorical||allegorical
72algined||aligned 75algined||aligned
@@ -80,6 +83,8 @@ aligment||alignment
80alignement||alignment 83alignement||alignment
81allign||align 84allign||align
82alligned||aligned 85alligned||aligned
86alllocate||allocate
87alloated||allocated
83allocatote||allocate 88allocatote||allocate
84allocatrd||allocated 89allocatrd||allocated
85allocte||allocate 90allocte||allocate
@@ -171,6 +176,7 @@ availale||available
171availavility||availability 176availavility||availability
172availble||available 177availble||available
173availiable||available 178availiable||available
179availible||available
174avalable||available 180avalable||available
175avaliable||available 181avaliable||available
176aysnc||async 182aysnc||async
@@ -203,6 +209,7 @@ broadcat||broadcast
203cacluated||calculated 209cacluated||calculated
204caculation||calculation 210caculation||calculation
205calender||calendar 211calender||calendar
212calescing||coalescing
206calle||called 213calle||called
207callibration||calibration 214callibration||calibration
208calucate||calculate 215calucate||calculate
@@ -210,6 +217,7 @@ calulate||calculate
210cancelation||cancellation 217cancelation||cancellation
211cancle||cancel 218cancle||cancel
212capabilites||capabilities 219capabilites||capabilities
220capabilty||capability
213capabitilies||capabilities 221capabitilies||capabilities
214capatibilities||capabilities 222capatibilities||capabilities
215capapbilities||capabilities 223capapbilities||capabilities
@@ -302,6 +310,7 @@ containts||contains
302contaisn||contains 310contaisn||contains
303contant||contact 311contant||contact
304contence||contents 312contence||contents
313continious||continuous
305continous||continuous 314continous||continuous
306continously||continuously 315continously||continuously
307continueing||continuing 316continueing||continuing
@@ -393,6 +402,7 @@ differrence||difference
393diffrent||different 402diffrent||different
394diffrentiate||differentiate 403diffrentiate||differentiate
395difinition||definition 404difinition||definition
405dimesions||dimensions
396diplay||display 406diplay||display
397direectly||directly 407direectly||directly
398disassocation||disassociation 408disassocation||disassociation
@@ -449,6 +459,7 @@ equiped||equipped
449equivelant||equivalent 459equivelant||equivalent
450equivilant||equivalent 460equivilant||equivalent
451eror||error 461eror||error
462errorr||error
452estbalishment||establishment 463estbalishment||establishment
453etsablishment||establishment 464etsablishment||establishment
454etsbalishment||establishment 465etsbalishment||establishment
@@ -481,6 +492,7 @@ failied||failed
481faillure||failure 492faillure||failure
482failue||failure 493failue||failure
483failuer||failure 494failuer||failure
495failng||failing
484faireness||fairness 496faireness||fairness
485falied||failed 497falied||failed
486faliure||failure 498faliure||failure
@@ -493,6 +505,7 @@ fetaure||feature
493fetaures||features 505fetaures||features
494fileystem||filesystem 506fileystem||filesystem
495fimware||firmware 507fimware||firmware
508firware||firmware
496finanize||finalize 509finanize||finalize
497findn||find 510findn||find
498finilizes||finalizes 511finilizes||finalizes
@@ -502,6 +515,7 @@ folloing||following
502followign||following 515followign||following
503followings||following 516followings||following
504follwing||following 517follwing||following
518fonud||found
505forseeable||foreseeable 519forseeable||foreseeable
506forse||force 520forse||force
507fortan||fortran 521fortan||fortran
@@ -532,6 +546,7 @@ grabing||grabbing
532grahical||graphical 546grahical||graphical
533grahpical||graphical 547grahpical||graphical
534grapic||graphic 548grapic||graphic
549grranted||granted
535guage||gauge 550guage||gauge
536guarenteed||guaranteed 551guarenteed||guaranteed
537guarentee||guarantee 552guarentee||guarantee
@@ -543,6 +558,7 @@ happend||happened
543harware||hardware 558harware||hardware
544heirarchically||hierarchically 559heirarchically||hierarchically
545helpfull||helpful 560helpfull||helpful
561hybernate||hibernate
546hierachy||hierarchy 562hierachy||hierarchy
547hierarchie||hierarchy 563hierarchie||hierarchy
548howver||however 564howver||however
@@ -565,16 +581,19 @@ implemenation||implementation
565implementaiton||implementation 581implementaiton||implementation
566implementated||implemented 582implementated||implemented
567implemention||implementation 583implemention||implementation
584implementd||implemented
568implemetation||implementation 585implemetation||implementation
569implemntation||implementation 586implemntation||implementation
570implentation||implementation 587implentation||implementation
571implmentation||implementation 588implmentation||implementation
572implmenting||implementing 589implmenting||implementing
590incative||inactive
573incomming||incoming 591incomming||incoming
574incompatabilities||incompatibilities 592incompatabilities||incompatibilities
575incompatable||incompatible 593incompatable||incompatible
576inconsistant||inconsistent 594inconsistant||inconsistent
577increas||increase 595increas||increase
596incremeted||incremented
578incrment||increment 597incrment||increment
579indendation||indentation 598indendation||indentation
580indended||intended 599indended||intended
@@ -619,6 +638,7 @@ interger||integer
619intermittant||intermittent 638intermittant||intermittent
620internel||internal 639internel||internal
621interoprability||interoperability 640interoprability||interoperability
641interuupt||interrupt
622interrface||interface 642interrface||interface
623interrrupt||interrupt 643interrrupt||interrupt
624interrup||interrupt 644interrup||interrupt
@@ -638,8 +658,10 @@ intrrupt||interrupt
638intterrupt||interrupt 658intterrupt||interrupt
639intuative||intuitive 659intuative||intuitive
640invaid||invalid 660invaid||invalid
661invald||invalid
641invalde||invalid 662invalde||invalid
642invalide||invalid 663invalide||invalid
664invalidiate||invalidate
643invalud||invalid 665invalud||invalid
644invididual||individual 666invididual||individual
645invokation||invocation 667invokation||invocation
@@ -713,6 +735,7 @@ misformed||malformed
713mispelled||misspelled 735mispelled||misspelled
714mispelt||misspelt 736mispelt||misspelt
715mising||missing 737mising||missing
738mismactch||mismatch
716missmanaged||mismanaged 739missmanaged||mismanaged
717missmatch||mismatch 740missmatch||mismatch
718miximum||maximum 741miximum||maximum
@@ -731,6 +754,7 @@ multidimensionnal||multidimensional
731multple||multiple 754multple||multiple
732mumber||number 755mumber||number
733muticast||multicast 756muticast||multicast
757mutilcast||multicast
734mutiple||multiple 758mutiple||multiple
735mutli||multi 759mutli||multi
736nams||names 760nams||names
@@ -834,6 +858,7 @@ posible||possible
834positon||position 858positon||position
835possibilites||possibilities 859possibilites||possibilities
836powerfull||powerful 860powerfull||powerful
861preample||preamble
837preapre||prepare 862preapre||prepare
838preceeded||preceded 863preceeded||preceded
839preceeding||preceding 864preceeding||preceding
@@ -1059,6 +1084,7 @@ sturcture||structure
1059subdirectoires||subdirectories 1084subdirectoires||subdirectories
1060suble||subtle 1085suble||subtle
1061substract||subtract 1086substract||subtract
1087submition||submission
1062succesfully||successfully 1088succesfully||successfully
1063succesful||successful 1089succesful||successful
1064successed||succeeded 1090successed||succeeded
@@ -1078,6 +1104,7 @@ suppoted||supported
1078suppported||supported 1104suppported||supported
1079suppport||support 1105suppport||support
1080supress||suppress 1106supress||suppress
1107surpressed||suppressed
1081surpresses||suppresses 1108surpresses||suppresses
1082susbsystem||subsystem 1109susbsystem||subsystem
1083suspeneded||suspended 1110suspeneded||suspended
@@ -1091,6 +1118,7 @@ swithced||switched
1091swithcing||switching 1118swithcing||switching
1092swithed||switched 1119swithed||switched
1093swithing||switching 1120swithing||switching
1121swtich||switch
1094symetric||symmetric 1122symetric||symmetric
1095synax||syntax 1123synax||syntax
1096synchonized||synchronized 1124synchonized||synchronized
@@ -1111,7 +1139,9 @@ therfore||therefore
1111thier||their 1139thier||their
1112threds||threads 1140threds||threads
1113threshhold||threshold 1141threshhold||threshold
1142thresold||threshold
1114throught||through 1143throught||through
1144troughput||throughput
1115thses||these 1145thses||these
1116tiggered||triggered 1146tiggered||triggered
1117tipically||typically 1147tipically||typically
@@ -1120,6 +1150,7 @@ tmis||this
1120torerable||tolerable 1150torerable||tolerable
1121tramsmitted||transmitted 1151tramsmitted||transmitted
1122tramsmit||transmit 1152tramsmit||transmit
1153tranasction||transaction
1123tranfer||transfer 1154tranfer||transfer
1124transciever||transceiver 1155transciever||transceiver
1125transferd||transferred 1156transferd||transferred
@@ -1133,6 +1164,7 @@ trasmission||transmission
1133treshold||threshold 1164treshold||threshold
1134trigerring||triggering 1165trigerring||triggering
1135trun||turn 1166trun||turn
1167tunning||tuning
1136ture||true 1168ture||true
1137tyep||type 1169tyep||type
1138udpate||update 1170udpate||update
@@ -1155,6 +1187,10 @@ unknonw||unknown
1155unknow||unknown 1187unknow||unknown
1156unkown||unknown 1188unkown||unknown
1157unneded||unneeded 1189unneded||unneeded
1190unneccecary||unnecessary
1191unneccesary||unnecessary
1192unneccessary||unnecessary
1193unnecesary||unnecessary
1158unneedingly||unnecessarily 1194unneedingly||unnecessarily
1159unnsupported||unsupported 1195unnsupported||unsupported
1160unmached||unmatched 1196unmached||unmatched
@@ -1199,6 +1235,7 @@ visiters||visitors
1199vitual||virtual 1235vitual||virtual
1200wakeus||wakeups 1236wakeus||wakeups
1201wating||waiting 1237wating||waiting
1238wiat||wait
1202wether||whether 1239wether||whether
1203whataver||whatever 1240whataver||whatever
1204whcih||which 1241whcih||which
diff --git a/scripts/stackdelta b/scripts/stackdelta
index 20a79f19a111..44d2dfd6216f 100755
--- a/scripts/stackdelta
+++ b/scripts/stackdelta
@@ -1,4 +1,5 @@
1#!/usr/bin/env perl 1#!/usr/bin/env perl
2# SPDX-License-Identifier: GPL-2.0
2 3
3# Read two files produced by the stackusage script, and show the 4# Read two files produced by the stackusage script, and show the
4# delta between them. 5# delta between them.
diff --git a/scripts/stackusage b/scripts/stackusage
index 8cf26640ef8a..56ef1ab670ac 100755
--- a/scripts/stackusage
+++ b/scripts/stackusage
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2 3
3outfile="" 4outfile=""
4now=`date +%s` 5now=`date +%s`
diff --git a/scripts/tracing/ftrace-bisect.sh b/scripts/tracing/ftrace-bisect.sh
index 9ff8ac5fc53c..926701162bc8 100755
--- a/scripts/tracing/ftrace-bisect.sh
+++ b/scripts/tracing/ftrace-bisect.sh
@@ -1,4 +1,5 @@
1#!/bin/bash 1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
2# 3#
3# Here's how to use this: 4# Here's how to use this:
4# 5#
diff --git a/scripts/ver_linux b/scripts/ver_linux
index b51de8a7e2a3..545ec7388eb7 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -1,4 +1,5 @@
1#!/usr/bin/awk -f 1#!/usr/bin/awk -f
2# SPDX-License-Identifier: GPL-2.0
2# Before running this script please ensure that your PATH is 3# Before running this script please ensure that your PATH is
3# typical as you use for compilation/installation. I use 4# typical as you use for compilation/installation. I use
4# /bin /sbin /usr/bin /usr/sbin /usr/local/bin, but it may 5# /bin /sbin /usr/bin /usr/sbin /usr/local/bin, but it may
diff --git a/scripts/xen-hypercalls.sh b/scripts/xen-hypercalls.sh
index 676d9226814f..f18b00843df3 100644
--- a/scripts/xen-hypercalls.sh
+++ b/scripts/xen-hypercalls.sh
@@ -1,4 +1,5 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
2out="$1" 3out="$1"
3shift 4shift
4in="$@" 5in="$@"