From 9c19722c5e1c623f2d7939bdeb74427e9a73c5d5 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 1 Mar 2021 23:49:44 +0900 Subject: sh: syscalls: switch to generic syscalltbl.sh Many architectures duplicate similar shell scripts. This commit converts sh to use scripts/syscalltbl.sh. Signed-off-by: Masahiro Yamada --- arch/sh/kernel/syscalls/Makefile | 7 ++----- arch/sh/kernel/syscalls/syscalltbl.sh | 32 -------------------------------- 2 files changed, 2 insertions(+), 37 deletions(-) delete mode 100644 arch/sh/kernel/syscalls/syscalltbl.sh diff --git a/arch/sh/kernel/syscalls/Makefile b/arch/sh/kernel/syscalls/Makefile index 285aaba832d9..ad2492cb5568 100644 --- a/arch/sh/kernel/syscalls/Makefile +++ b/arch/sh/kernel/syscalls/Makefile @@ -7,7 +7,7 @@ _dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \ syscall := $(src)/syscall.tbl syshdr := $(srctree)/$(src)/syscallhdr.sh -systbl := $(srctree)/$(src)/syscalltbl.sh +systbl := $(srctree)/scripts/syscalltbl.sh quiet_cmd_syshdr = SYSHDR $@ cmd_syshdr = $(CONFIG_SHELL) '$(syshdr)' '$<' '$@' \ @@ -16,10 +16,7 @@ quiet_cmd_syshdr = SYSHDR $@ '$(syshdr_offset_$(basetarget))' quiet_cmd_systbl = SYSTBL $@ - cmd_systbl = $(CONFIG_SHELL) '$(systbl)' '$<' '$@' \ - '$(systbl_abis_$(basetarget))' \ - '$(systbl_abi_$(basetarget))' \ - '$(systbl_offset_$(basetarget))' + cmd_systbl = $(CONFIG_SHELL) $(systbl) $< $@ $(uapi)/unistd_32.h: $(syscall) $(syshdr) FORCE $(call if_changed,syshdr) diff --git a/arch/sh/kernel/syscalls/syscalltbl.sh b/arch/sh/kernel/syscalls/syscalltbl.sh deleted file mode 100644 index 904b8e6e625d..000000000000 --- a/arch/sh/kernel/syscalls/syscalltbl.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: GPL-2.0 - -in="$1" -out="$2" -my_abis=`echo "($3)" | tr ',' '|'` -my_abi="$4" -offset="$5" - -emit() { - t_nxt="$1" - t_nr="$2" - t_entry="$3" - - while [ $t_nxt -lt $t_nr ]; do - printf "__SYSCALL(%s,sys_ni_syscall)\n" "${t_nxt}" - t_nxt=$((t_nxt+1)) - done - printf "__SYSCALL(%s,%s)\n" "${t_nxt}" "${t_entry}" -} - -grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | ( - nxt=0 - if [ -z "$offset" ]; then - offset=0 - fi - - while read nr abi name entry ; do - emit $((nxt+offset)) $((nr+offset)) $entry - nxt=$((nr+1)) - done -) > "$out" -- cgit From eb6111495ca94a8c9fa7ca043bd5d5cff9a661f4 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 1 Mar 2021 23:49:45 +0900 Subject: sh: syscalls: switch to generic syscallhdr.sh Many architectures duplicate similar shell scripts. This commit converts sh to use scripts/syscallhdr.sh. Signed-off-by: Masahiro Yamada --- arch/sh/kernel/syscalls/Makefile | 7 ++----- arch/sh/kernel/syscalls/syscallhdr.sh | 36 ----------------------------------- 2 files changed, 2 insertions(+), 41 deletions(-) delete mode 100644 arch/sh/kernel/syscalls/syscallhdr.sh diff --git a/arch/sh/kernel/syscalls/Makefile b/arch/sh/kernel/syscalls/Makefile index ad2492cb5568..6713c65a25e1 100644 --- a/arch/sh/kernel/syscalls/Makefile +++ b/arch/sh/kernel/syscalls/Makefile @@ -6,14 +6,11 @@ _dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \ $(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)') syscall := $(src)/syscall.tbl -syshdr := $(srctree)/$(src)/syscallhdr.sh +syshdr := $(srctree)/scripts/syscallhdr.sh systbl := $(srctree)/scripts/syscalltbl.sh quiet_cmd_syshdr = SYSHDR $@ - cmd_syshdr = $(CONFIG_SHELL) '$(syshdr)' '$<' '$@' \ - '$(syshdr_abis_$(basetarget))' \ - '$(syshdr_pfx_$(basetarget))' \ - '$(syshdr_offset_$(basetarget))' + cmd_syshdr = $(CONFIG_SHELL) $(syshdr) --emit-nr $< $@ quiet_cmd_systbl = SYSTBL $@ cmd_systbl = $(CONFIG_SHELL) $(systbl) $< $@ diff --git a/arch/sh/kernel/syscalls/syscallhdr.sh b/arch/sh/kernel/syscalls/syscallhdr.sh deleted file mode 100644 index 4c0519861e97..000000000000 --- a/arch/sh/kernel/syscalls/syscallhdr.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: GPL-2.0 - -in="$1" -out="$2" -my_abis=`echo "($3)" | tr ',' '|'` -prefix="$4" -offset="$5" - -fileguard=_UAPI_ASM_SH_`basename "$out" | sed \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ - -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'` -grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | ( - printf "#ifndef %s\n" "${fileguard}" - printf "#define %s\n" "${fileguard}" - printf "\n" - - nxt=0 - while read nr abi name entry ; do - if [ -z "$offset" ]; then - printf "#define __NR_%s%s\t%s\n" \ - "${prefix}" "${name}" "${nr}" - else - printf "#define __NR_%s%s\t(%s + %s)\n" \ - "${prefix}" "${name}" "${offset}" "${nr}" - fi - nxt=$((nr+1)) - done - - printf "\n" - printf "#ifdef __KERNEL__\n" - printf "#define __NR_syscalls\t%s\n" "${nxt}" - printf "#endif\n" - printf "\n" - printf "#endif /* %s */\n" "${fileguard}" -) > "$out" -- cgit From 5ad4e94b46a618f333a6b1a34ee391c8a6bb40b2 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 1 Mar 2021 23:51:01 +0900 Subject: sparc: syscalls: switch to generic syscalltbl.sh Many architectures duplicate similar shell scripts. This commit converts sparc to use scripts/syscalltbl.sh. This also unifies syscall_table_64.h and syscall_table_c32.h. Signed-off-by: Masahiro Yamada --- arch/sparc/include/asm/Kbuild | 1 - arch/sparc/kernel/syscalls/Makefile | 19 +++++------------ arch/sparc/kernel/syscalls/syscalltbl.sh | 36 -------------------------------- arch/sparc/kernel/systbls_32.S | 4 ++-- arch/sparc/kernel/systbls_64.S | 8 ++++--- 5 files changed, 12 insertions(+), 56 deletions(-) delete mode 100644 arch/sparc/kernel/syscalls/syscalltbl.sh diff --git a/arch/sparc/include/asm/Kbuild b/arch/sparc/include/asm/Kbuild index aec20406145e..0b9d98ced34a 100644 --- a/arch/sparc/include/asm/Kbuild +++ b/arch/sparc/include/asm/Kbuild @@ -1,7 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 generated-y += syscall_table_32.h generated-y += syscall_table_64.h -generated-y += syscall_table_c32.h generic-y += export.h generic-y += kvm_para.h generic-y += mcs_spinlock.h diff --git a/arch/sparc/kernel/syscalls/Makefile b/arch/sparc/kernel/syscalls/Makefile index 283f64407b07..11424f1c8d9e 100644 --- a/arch/sparc/kernel/syscalls/Makefile +++ b/arch/sparc/kernel/syscalls/Makefile @@ -7,7 +7,7 @@ _dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \ syscall := $(src)/syscall.tbl syshdr := $(srctree)/$(src)/syscallhdr.sh -systbl := $(srctree)/$(src)/syscalltbl.sh +systbl := $(srctree)/scripts/syscalltbl.sh quiet_cmd_syshdr = SYSHDR $@ cmd_syshdr = $(CONFIG_SHELL) '$(syshdr)' '$<' '$@' \ @@ -16,10 +16,7 @@ quiet_cmd_syshdr = SYSHDR $@ '$(syshdr_offset_$(basetarget))' quiet_cmd_systbl = SYSTBL $@ - cmd_systbl = $(CONFIG_SHELL) '$(systbl)' '$<' '$@' \ - '$(systbl_abis_$(basetarget))' \ - '$(systbl_abi_$(basetarget))' \ - '$(systbl_offset_$(basetarget))' + cmd_systbl = $(CONFIG_SHELL) $(systbl) --abis $(abis) $< $@ syshdr_abis_unistd_32 := common,32 $(uapi)/unistd_32.h: $(syscall) $(syshdr) FORCE @@ -29,23 +26,17 @@ syshdr_abis_unistd_64 := common,64 $(uapi)/unistd_64.h: $(syscall) $(syshdr) FORCE $(call if_changed,syshdr) -systbl_abis_syscall_table_32 := common,32 +$(kapi)/syscall_table_32.h: abis := common,32 $(kapi)/syscall_table_32.h: $(syscall) $(systbl) FORCE $(call if_changed,systbl) -systbl_abis_syscall_table_64 := common,64 +$(kapi)/syscall_table_64.h: abis := common,64 $(kapi)/syscall_table_64.h: $(syscall) $(systbl) FORCE $(call if_changed,systbl) -systbl_abis_syscall_table_c32 := common,32 -systbl_abi_syscall_table_c32 := c32 -$(kapi)/syscall_table_c32.h: $(syscall) $(systbl) FORCE - $(call if_changed,systbl) - uapisyshdr-y += unistd_32.h unistd_64.h kapisyshdr-y += syscall_table_32.h \ - syscall_table_64.h \ - syscall_table_c32.h + syscall_table_64.h uapisyshdr-y := $(addprefix $(uapi)/, $(uapisyshdr-y)) kapisyshdr-y := $(addprefix $(kapi)/, $(kapisyshdr-y)) diff --git a/arch/sparc/kernel/syscalls/syscalltbl.sh b/arch/sparc/kernel/syscalls/syscalltbl.sh deleted file mode 100644 index 77cf0143ba19..000000000000 --- a/arch/sparc/kernel/syscalls/syscalltbl.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: GPL-2.0 - -in="$1" -out="$2" -my_abis=`echo "($3)" | tr ',' '|'` -my_abi="$4" -offset="$5" - -emit() { - t_nxt="$1" - t_nr="$2" - t_entry="$3" - - while [ $t_nxt -lt $t_nr ]; do - printf "__SYSCALL(%s, sys_nis_syscall, )\n" "${t_nxt}" - t_nxt=$((t_nxt+1)) - done - printf "__SYSCALL(%s, %s, )\n" "${t_nxt}" "${t_entry}" -} - -grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | ( - nxt=0 - if [ -z "$offset" ]; then - offset=0 - fi - - while read nr abi name entry compat ; do - if [ "$my_abi" = "c32" ] && [ ! -z "$compat" ]; then - emit $((nxt+offset)) $((nr+offset)) $compat - else - emit $((nxt+offset)) $((nr+offset)) $entry - fi - nxt=$((nr+1)) - done -) > "$out" diff --git a/arch/sparc/kernel/systbls_32.S b/arch/sparc/kernel/systbls_32.S index ab9e4d57685a..3aaffa017706 100644 --- a/arch/sparc/kernel/systbls_32.S +++ b/arch/sparc/kernel/systbls_32.S @@ -9,10 +9,10 @@ * Copyright (C) 1995 Adrian M. Rodriguez (adrian@remus.rutgers.edu) */ -#define __SYSCALL(nr, entry, nargs) .long entry +#define __SYSCALL_WITH_COMPAT(nr, native, compat) __SYSCALL(nr, native) +#define __SYSCALL(nr, entry) .long entry .data .align 4 .globl sys_call_table sys_call_table: #include /* 32-bit native syscalls */ -#undef __SYSCALL diff --git a/arch/sparc/kernel/systbls_64.S b/arch/sparc/kernel/systbls_64.S index a27394bf7d7f..398fe449dd34 100644 --- a/arch/sparc/kernel/systbls_64.S +++ b/arch/sparc/kernel/systbls_64.S @@ -10,18 +10,20 @@ * Copyright (C) 1995 Adrian M. Rodriguez (adrian@remus.rutgers.edu) */ -#define __SYSCALL(nr, entry, nargs) .word entry +#define __SYSCALL(nr, entry) .word entry .text .align 4 #ifdef CONFIG_COMPAT .globl sys_call_table32 sys_call_table32: -#include /* Compat syscalls */ +#define __SYSCALL_WITH_COMPAT(nr, native, compat) __SYSCALL(nr, compat) +#include /* Compat syscalls */ +#undef __SYSCALL_WITH_COMPAT #endif /* CONFIG_COMPAT */ .align 4 .globl sys_call_table64, sys_call_table sys_call_table64: sys_call_table: +#define __SYSCALL_WITH_COMPAT(nr, native, compat) __SYSCALL(nr, native) #include /* 64-bit native syscalls */ -#undef __SYSCALL -- cgit From c5849b7c206bf36b8ce7079d4777e0a59305ccce Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 1 Mar 2021 23:51:02 +0900 Subject: sparc: syscalls: switch to generic syscallshdr.sh Many architectures duplicate similar shell scripts. This commit converts sparc to use scripts/syscallhdr.sh. Signed-off-by: Masahiro Yamada --- arch/sparc/kernel/syscalls/Makefile | 11 ++++------ arch/sparc/kernel/syscalls/syscallhdr.sh | 36 -------------------------------- 2 files changed, 4 insertions(+), 43 deletions(-) delete mode 100644 arch/sparc/kernel/syscalls/syscallhdr.sh diff --git a/arch/sparc/kernel/syscalls/Makefile b/arch/sparc/kernel/syscalls/Makefile index 11424f1c8d9e..0f2ea5bcb0d7 100644 --- a/arch/sparc/kernel/syscalls/Makefile +++ b/arch/sparc/kernel/syscalls/Makefile @@ -6,23 +6,20 @@ _dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \ $(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)') syscall := $(src)/syscall.tbl -syshdr := $(srctree)/$(src)/syscallhdr.sh +syshdr := $(srctree)/scripts/syscallhdr.sh systbl := $(srctree)/scripts/syscalltbl.sh quiet_cmd_syshdr = SYSHDR $@ - cmd_syshdr = $(CONFIG_SHELL) '$(syshdr)' '$<' '$@' \ - '$(syshdr_abis_$(basetarget))' \ - '$(syshdr_pfx_$(basetarget))' \ - '$(syshdr_offset_$(basetarget))' + cmd_syshdr = $(CONFIG_SHELL) $(syshdr) --emit-nr --abis $(abis) $< $@ quiet_cmd_systbl = SYSTBL $@ cmd_systbl = $(CONFIG_SHELL) $(systbl) --abis $(abis) $< $@ -syshdr_abis_unistd_32 := common,32 +$(uapi)/unistd_32.h: abis := common,32 $(uapi)/unistd_32.h: $(syscall) $(syshdr) FORCE $(call if_changed,syshdr) -syshdr_abis_unistd_64 := common,64 +$(uapi)/unistd_64.h: abis := common,64 $(uapi)/unistd_64.h: $(syscall) $(syshdr) FORCE $(call if_changed,syshdr) diff --git a/arch/sparc/kernel/syscalls/syscallhdr.sh b/arch/sparc/kernel/syscalls/syscallhdr.sh deleted file mode 100644 index cf50a75cc0bb..000000000000 --- a/arch/sparc/kernel/syscalls/syscallhdr.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: GPL-2.0 - -in="$1" -out="$2" -my_abis=`echo "($3)" | tr ',' '|'` -prefix="$4" -offset="$5" - -fileguard=_UAPI_ASM_SPARC_`basename "$out" | sed \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ - -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'` -grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | ( - printf "#ifndef %s\n" "${fileguard}" - printf "#define %s\n" "${fileguard}" - printf "\n" - - nxt=0 - while read nr abi name entry compat ; do - if [ -z "$offset" ]; then - printf "#define __NR_%s%s\t%s\n" \ - "${prefix}" "${name}" "${nr}" - else - printf "#define __NR_%s%s\t(%s + %s)\n" \ - "${prefix}" "${name}" "${offset}" "${nr}" - fi - nxt=$((nr+1)) - done - - printf "\n" - printf "#ifdef __KERNEL__\n" - printf "#define __NR_syscalls\t%s\n" "${nxt}" - printf "#endif\n" - printf "\n" - printf "#endif /* %s */\n" "${fileguard}" -) > "$out" -- cgit From 3787b7da5d3e2c849fe8ffed987922a4e6dd6cfd Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 24 Apr 2021 20:55:53 +0900 Subject: kbuild: add comment about why cmd_shipped uses 'cat' cmd_shipped uses 'cat' instead of 'cp' for copying a file. The reason is explained in the commit [1], but it was in the pre-git era. $ touch a $ chmod -w a $ cp a b $ cp a b cp: cannot create regular file 'b': Permission denied Add comments so that you can see the reason without looking into the history. [1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=a70dba8086160449cc94c5bdaff78419b6b8e3c8 Signed-off-by: Masahiro Yamada --- scripts/Makefile.lib | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 64daf37e874b..c0982b8b2b6d 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -252,6 +252,9 @@ quiet_cmd_copy = COPY $@ # Shipped files # =========================================================================== +# 'cp' preserves permissions. If you use it to copy a file in read-only srctree, +# the copy would be read-only as well, leading to an error when executing the +# rule next time. Use 'cat' instead in order to generate a writable file. quiet_cmd_shipped = SHIPPED $@ cmd_shipped = cat $< > $@ -- cgit From 382243f346416f5ed14cc2517d8a3947bf25d628 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 24 Apr 2021 21:08:29 +0900 Subject: genksyms: fix stale comment (shipped source) is a stale comment. Since commit 833e62245943 ("genksyms: generate lexer and parser during build instead of shipping"), there is no source file to be shipped in this directory. Signed-off-by: Masahiro Yamada --- scripts/genksyms/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile index ce4f99935de5..d6a422a63b6a 100644 --- a/scripts/genksyms/Makefile +++ b/scripts/genksyms/Makefile @@ -22,7 +22,7 @@ $(obj)/pars%.tab.c $(obj)/pars%.tab.h: $(src)/pars%.y FORCE endif -# -I needed for generated C source (shipped source) +# -I needed for generated C source to include headers in source tree HOSTCFLAGS_parse.tab.o := -I $(srctree)/$(src) HOSTCFLAGS_lex.lex.o := -I $(srctree)/$(src) -- cgit From 5134e94ac4f5e58d73f39fde8ee6735b47f5c63d Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 25 Apr 2021 04:47:19 +0900 Subject: usr/include: refactor .gitignore The current .gitignore intends to ignore everything under usr/include/ except .gitignore and Makefile. A cleaner solution is to use a pattern suffixed with '/', which matches only directories. It works well here because all the exported headers are located in sub-directories, like , . Signed-off-by: Masahiro Yamada --- usr/include/.gitignore | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/usr/include/.gitignore b/usr/include/.gitignore index d2fab782cb7d..17b0ba1bd325 100644 --- a/usr/include/.gitignore +++ b/usr/include/.gitignore @@ -1,4 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -* -!.gitignore -!Makefile +/*/ -- cgit From 1fca37660326b3c7a310e35768cf554425dd7f64 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 25 Apr 2021 15:24:03 +0900 Subject: kernel/.gitgnore: remove stale timeconst.h and hz.bc timeconst.h and hz.bc used to exist in kernel/. Commit 5cee96459726 ("time/timers: Move all time(r) related files into kernel/time") moved them to kernel/time/. Commit 0a227985d4a9 ("time: Move timeconst.h into include/generated") moved timeconst.h to include/generated/ and removed hz.bc . Signed-off-by: Masahiro Yamada --- kernel/.gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/kernel/.gitignore b/kernel/.gitignore index 78701ea37c97..4abc4e033ed8 100644 --- a/kernel/.gitignore +++ b/kernel/.gitignore @@ -1,4 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only kheaders.md5 -timeconst.h -hz.bc -- cgit From 819cb9fc80733e346f3f913293c0a70e00a61d33 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 25 Apr 2021 15:24:04 +0900 Subject: .gitignore: move tags and TAGS close to other tag files For consistency, move tags and TAGS close to the cscope and GNU Global patterns. I removed the '/' prefix in case somebody wants to manually create tag files in sub-directories. Signed-off-by: Masahiro Yamada --- .gitignore | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index df8d3146a43f..deb68b7555ad 100644 --- a/.gitignore +++ b/.gitignore @@ -54,8 +54,6 @@ modules.order # # Top-level generic files # -/tags -/TAGS /linux /modules-only.symvers /vmlinux @@ -114,6 +112,10 @@ patches-* patches series +# ctags files +tags +TAGS + # cscope files cscope.* ncscope.* -- cgit From 40cb020305f40bafc2a13c7e879a33dbbd607507 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 25 Apr 2021 15:24:05 +0900 Subject: .gitignore: ignore only top-level modules.builtin modules.builtin used to be created in every directory. Since commit 8b41fc4454e3 ("kbuild: create modules.builtin without Makefile.modbuiltin or tristate.conf"), modules.builtin is created only in the top directory. Add the '/' prefix so that it matches to only the modules.builtin located in the top directory. It has been more than one year since that change. I hope this will not flood 'Untracked files' of 'git status'. Signed-off-by: Masahiro Yamada --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index deb68b7555ad..7afd412dadd2 100644 --- a/.gitignore +++ b/.gitignore @@ -48,7 +48,6 @@ *.xz *.zst Module.symvers -modules.builtin modules.order # @@ -64,6 +63,7 @@ modules.order /vmlinuz /System.map /Module.markers +/modules.builtin /modules.builtin.modinfo /modules.nsdeps -- cgit From 46b41d5dd8019b264717978c39c43313a524d033 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 25 Apr 2021 15:24:07 +0900 Subject: kbuild: update config_data.gz only when the content of .config is changed If the timestamp of the .config file is updated, config_data.gz is regenerated, then vmlinux is re-linked. This occurs even if the content of the .config has not changed at all. This issue was mitigated by commit 67424f61f813 ("kconfig: do not write .config if the content is the same"); Kconfig does not update the .config when it ends up with the identical configuration. The issue is remaining when the .config is created by *_defconfig with some config fragment(s) applied on top. This is typical for powerpc and mips, where several *_defconfig targets are constructed by using merge_config.sh. One workaround is to have the copy of the .config. The filechk rule updates the copy, kernel/config_data, by checking the content instead of the timestamp. With this commit, the second run with the same configuration avoids the needless rebuilds. $ make ARCH=mips defconfig all [ snip ] $ make ARCH=mips defconfig all *** Default configuration is based on target '32r2el_defconfig' Using ./arch/mips/configs/generic_defconfig as base Merging arch/mips/configs/generic/32r2.config Merging arch/mips/configs/generic/el.config Merging ./arch/mips/configs/generic/board-boston.config Merging ./arch/mips/configs/generic/board-ni169445.config Merging ./arch/mips/configs/generic/board-ocelot.config Merging ./arch/mips/configs/generic/board-ranchu.config Merging ./arch/mips/configs/generic/board-sead-3.config Merging ./arch/mips/configs/generic/board-xilfpga.config # # configuration written to .config # SYNC include/config/auto.conf CALL scripts/checksyscalls.sh CALL scripts/atomic/check-atomics.sh CHK include/generated/compile.h CHK include/generated/autoksyms.h Reported-by: Elliot Berman Signed-off-by: Masahiro Yamada --- kernel/.gitignore | 1 + kernel/Makefile | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/.gitignore b/kernel/.gitignore index 4abc4e033ed8..dafdce3d18c5 100644 --- a/kernel/.gitignore +++ b/kernel/.gitignore @@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only +/config_data kheaders.md5 diff --git a/kernel/Makefile b/kernel/Makefile index e8a6715f38dc..4df609be42d0 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -142,10 +142,15 @@ obj-$(CONFIG_SCF_TORTURE_TEST) += scftorture.o $(obj)/configs.o: $(obj)/config_data.gz -targets += config_data.gz -$(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE +targets += config_data config_data.gz +$(obj)/config_data.gz: $(obj)/config_data FORCE $(call if_changed,gzip) +filechk_cat = cat $< + +$(obj)/config_data: $(KCONFIG_CONFIG) FORCE + $(call filechk,cat) + $(obj)/kheaders.o: $(obj)/kheaders_data.tar.xz quiet_cmd_genikh = CHK $(obj)/kheaders_data.tar.xz -- cgit From 1476fee5c53e24e06cfc436110cdefbc1868e8c1 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 25 Apr 2021 16:07:12 +0900 Subject: kbuild: add a script to remove stale generated files We maintain .gitignore and Makefiles so build artifacts are properly ignored by Git, and cleaned up by 'make clean'. However, the code is always changing; generated files are often moved to another directory, or removed when they become unnecessary. Such garbage files tend to be left over in the source tree because people usually git-pull without cleaning the tree. This is not only the noise for 'git status', but also a build issue in some cases. One solution is to remove a stale file like commit 223c24a7dba9 ("kbuild: Automatically remove stale file") did. Such workaround should be removed after a while, but we forget about that if we scatter the workaround code in random places. So, this commit adds a new script to collect cleanings of stale files. As a start point, move the code in arch/arm/boot/compressed/Makefile into this script. Signed-off-by: Masahiro Yamada --- Makefile | 6 +++++- arch/arm/boot/compressed/Makefile | 7 ------- scripts/remove-stale-files | 31 +++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 8 deletions(-) create mode 100755 scripts/remove-stale-files diff --git a/Makefile b/Makefile index 6eafedd7efc6..9f5a3cac63e7 100644 --- a/Makefile +++ b/Makefile @@ -1225,7 +1225,7 @@ PHONY += prepare archprepare archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \ asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \ - include/generated/autoconf.h + include/generated/autoconf.h remove-stale-files prepare0: archprepare $(Q)$(MAKE) $(build)=scripts/mod @@ -1234,6 +1234,10 @@ prepare0: archprepare # All the preparing.. prepare: prepare0 prepare-objtool prepare-resolve_btfids +PHONY += remove-stale-files +remove-stale-files: + $(Q)$(srctree)/scripts/remove-stale-files + # Support for using generic headers in asm-generic asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index fd94e27ba4fa..182b300e3f8a 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -96,13 +96,6 @@ endif $(foreach o, $(libfdt_objs) atags_to_fdt.o fdt_check_mem_start.o, \ $(eval CFLAGS_$(o) := -I $(srctree)/scripts/dtc/libfdt -fno-stack-protector)) -# These were previously generated C files. When you are building the kernel -# with O=, make sure to remove the stale files in the output tree. Otherwise, -# the build system wrongly compiles the stale ones. -ifdef building_out_of_srctree -$(shell rm -f $(addprefix $(obj)/, fdt_rw.c fdt_ro.c fdt_wip.c fdt.c)) -endif - targets := vmlinux vmlinux.lds piggy_data piggy.o \ lib1funcs.o ashldi3.o bswapsdi2.o \ head.o $(OBJS) diff --git a/scripts/remove-stale-files b/scripts/remove-stale-files new file mode 100755 index 000000000000..c3eb81c3f7de --- /dev/null +++ b/scripts/remove-stale-files @@ -0,0 +1,31 @@ +#!/bin/sh + +set -e + +# When you move, remove or rename generated files, you probably also update +# .gitignore and cleaning rules in the Makefile. This is the right thing +# to do. However, people usually do 'git pull', 'git bisect', etc. without +# running 'make clean'. Then, the stale generated files are left over, often +# causing build issues. +# +# Also, 'git status' shows such stale build artifacts as untracked files. +# What is worse, some people send a wrong patch to get them back to .gitignore +# without checking the commit history. +# +# So, when you (re)move generated files, please move the cleaning rules from +# the Makefile to this script. This is run before Kbuild starts building +# anything, so people will not be annoyed by such garbage files. +# +# This script is not intended to grow endlessly. Rather, it is a temporary scrap +# yard. Stale files stay in this file for a while (for some release cycles?), +# then will be really dead and removed from the code base entirely. + +# These were previously generated source files. When you are building the kernel +# with O=, make sure to remove the stale files in the output tree. Otherwise, +# the build system wrongly compiles the stale ones. +if [ -n "${building_out_of_srctree}" ]; then + for f in fdt_rw.c fdt_ro.c fdt_wip.c fdt.c + do + rm -f arch/arm/boot/compressed/${f} + done +fi -- cgit From 885480b084696331bea61a4f7eba10652999a9c1 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Wed, 28 Apr 2021 18:23:50 -0700 Subject: Makefile: Move -Wno-unused-but-set-variable out of GCC only block Currently, -Wunused-but-set-variable is only supported by GCC so it is disabled unconditionally in a GCC only block (it is enabled with W=1). clang currently has its implementation for this warning in review so preemptively move this statement out of the GCC only block and wrap it with cc-disable-warning so that both compilers function the same. Cc: stable@vger.kernel.org Link: https://reviews.llvm.org/D100581 Signed-off-by: Nathan Chancellor Reviewed-by: Nick Desaulniers Tested-by: Nick Desaulniers Signed-off-by: Masahiro Yamada --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 9f5a3cac63e7..3597fd75d5b5 100644 --- a/Makefile +++ b/Makefile @@ -792,16 +792,16 @@ KBUILD_CFLAGS += -Wno-gnu KBUILD_CFLAGS += -mno-global-merge else -# These warnings generated too much noise in a regular build. -# Use make W=1 to enable them (see scripts/Makefile.extrawarn) -KBUILD_CFLAGS += -Wno-unused-but-set-variable - # Warn about unmarked fall-throughs in switch statement. # Disabled for clang while comment to attribute conversion happens and # https://github.com/ClangBuiltLinux/linux/issues/636 is discussed. KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,) endif +# These warnings generated too much noise in a regular build. +# Use make W=1 to enable them (see scripts/Makefile.extrawarn) +KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) + KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) ifdef CONFIG_FRAME_POINTER KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls -- cgit From 77a88274dc1a2cf3a775161d9a3242bc798ee680 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 30 Apr 2021 10:56:27 +0900 Subject: kbuild: replace LANG=C with LC_ALL=C LANG gives a weak default to each LC_* in case it is not explicitly defined. LC_ALL, if set, overrides all other LC_* variables. LANG < LC_CTYPE, LC_COLLATE, LC_MONETARY, LC_NUMERIC, ... < LC_ALL This is why documentation such as [1] suggests to set LC_ALL in build scripts to get the deterministic result. LANG=C is not strong enough to override LC_* that may be set by end users. [1]: https://reproducible-builds.org/docs/locales/ Signed-off-by: Masahiro Yamada Acked-by: Michael Ellerman (powerpc) Reviewed-by: Matthias Maennich Acked-by: Matthieu Baerts (mptcp) Reviewed-by: Greg Kroah-Hartman --- arch/powerpc/boot/wrapper | 2 +- scripts/nsdeps | 2 +- scripts/recordmcount.pl | 2 +- scripts/setlocalversion | 2 +- scripts/tags.sh | 2 +- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 2 +- usr/gen_initramfs.sh | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper index 41fa0a8715e3..cdb796b76e2e 100755 --- a/arch/powerpc/boot/wrapper +++ b/arch/powerpc/boot/wrapper @@ -191,7 +191,7 @@ if [ -z "$kernel" ]; then kernel=vmlinux fi -LANG=C elfformat="`${CROSS}objdump -p "$kernel" | grep 'file format' | awk '{print $4}'`" +LC_ALL=C elfformat="`${CROSS}objdump -p "$kernel" | grep 'file format' | awk '{print $4}'`" case "$elfformat" in elf64-powerpcle) format=elf64lppc ;; elf64-powerpc) format=elf32ppc ;; diff --git a/scripts/nsdeps b/scripts/nsdeps index e8ce2a4d704a..04c4b96e95ec 100644 --- a/scripts/nsdeps +++ b/scripts/nsdeps @@ -44,7 +44,7 @@ generate_deps() { for source_file in $mod_source_files; do sed '/MODULE_IMPORT_NS/Q' $source_file > ${source_file}.tmp offset=$(wc -l ${source_file}.tmp | awk '{print $1;}') - cat $source_file | grep MODULE_IMPORT_NS | LANG=C sort -u >> ${source_file}.tmp + cat $source_file | grep MODULE_IMPORT_NS | LC_ALL=C sort -u >> ${source_file}.tmp tail -n +$((offset +1)) ${source_file} | grep -v MODULE_IMPORT_NS >> ${source_file}.tmp if ! diff -q ${source_file} ${source_file}.tmp; then mv ${source_file}.tmp ${source_file} diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl index 867860ea57da..0a7fc9507d6f 100755 --- a/scripts/recordmcount.pl +++ b/scripts/recordmcount.pl @@ -497,7 +497,7 @@ sub update_funcs # # Step 2: find the sections and mcount call sites # -open(IN, "LANG=C $objdump -hdr $inputfile|") || die "error running $objdump"; +open(IN, "LC_ALL=C $objdump -hdr $inputfile|") || die "error running $objdump"; my $text; diff --git a/scripts/setlocalversion b/scripts/setlocalversion index bb709eda96cd..db941f6d9591 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -126,7 +126,7 @@ scm_version() fi # Check for svn and a svn repo. - if rev=$(LANG= LC_ALL= LC_MESSAGES=C svn info 2>/dev/null | grep '^Last Changed Rev'); then + if rev=$(LC_ALL=C svn info 2>/dev/null | grep '^Last Changed Rev'); then rev=$(echo $rev | awk '{print $NF}') printf -- '-svn%s' "$rev" diff --git a/scripts/tags.sh b/scripts/tags.sh index fd96734deff1..db8ba411860a 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -326,5 +326,5 @@ esac # Remove structure forward declarations. if [ -n "$remove_structs" ]; then - LANG=C sed -i -e '/^\([a-zA-Z_][a-zA-Z0-9_]*\)\t.*\t\/\^struct \1;.*\$\/;"\tx$/d' $1 + LC_ALL=C sed -i -e '/^\([a-zA-Z_][a-zA-Z0-9_]*\)\t.*\t\/\^struct \1;.*\$\/;"\tx$/d' $1 fi diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh index 9236609731b1..3c4cb72ed8a4 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -274,7 +274,7 @@ check_mptcp_disabled() ip netns exec ${disabled_ns} sysctl -q net.mptcp.enabled=0 local err=0 - LANG=C ip netns exec ${disabled_ns} ./mptcp_connect -p 10000 -s MPTCP 127.0.0.1 < "$cin" 2>&1 | \ + LC_ALL=C ip netns exec ${disabled_ns} ./mptcp_connect -p 10000 -s MPTCP 127.0.0.1 < "$cin" 2>&1 | \ grep -q "^socket: Protocol not available$" && err=1 ip netns delete ${disabled_ns} diff --git a/usr/gen_initramfs.sh b/usr/gen_initramfs.sh index 8ae831657e5d..63476bb70b41 100755 --- a/usr/gen_initramfs.sh +++ b/usr/gen_initramfs.sh @@ -147,7 +147,7 @@ dir_filelist() { header "$1" srcdir=$(echo "$1" | sed -e 's://*:/:g') - dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" | LANG=C sort) + dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" | LC_ALL=C sort) # If $dirlist is only one line, then the directory is empty if [ "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then -- cgit From 9009b455811b0fa1f6b0adfa94db136984db5a38 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 30 Apr 2021 11:03:08 +0900 Subject: .gitignore: prefix local generated files with a slash The pattern prefixed with '/' matches files in the same directory, but not ones in sub-directories. Signed-off-by: Masahiro Yamada Acked-by: Miguel Ojeda Acked-by: Rob Herring Acked-by: Andra Paraschiv Acked-by: Greg Kroah-Hartman Acked-by: Gabriel Krisman Bertazi --- Documentation/devicetree/bindings/.gitignore | 4 ++-- arch/.gitignore | 4 ++-- certs/.gitignore | 4 ++-- drivers/memory/.gitignore | 2 +- drivers/tty/vt/.gitignore | 6 +++--- fs/unicode/.gitignore | 4 ++-- kernel/.gitignore | 2 +- lib/.gitignore | 10 +++++----- samples/auxdisplay/.gitignore | 2 +- samples/binderfs/.gitignore | 3 ++- samples/connector/.gitignore | 2 +- samples/hidraw/.gitignore | 2 +- samples/mei/.gitignore | 2 +- samples/nitro_enclaves/.gitignore | 2 +- samples/pidfd/.gitignore | 2 +- samples/seccomp/.gitignore | 8 ++++---- samples/timers/.gitignore | 2 +- samples/vfs/.gitignore | 4 ++-- samples/watch_queue/.gitignore | 3 ++- samples/watchdog/.gitignore | 2 +- scripts/.gitignore | 18 +++++++++--------- scripts/basic/.gitignore | 2 +- scripts/dtc/.gitignore | 4 ++-- scripts/gcc-plugins/.gitignore | 2 +- scripts/genksyms/.gitignore | 2 +- scripts/mod/.gitignore | 8 ++++---- usr/.gitignore | 4 ++-- 27 files changed, 56 insertions(+), 54 deletions(-) diff --git a/Documentation/devicetree/bindings/.gitignore b/Documentation/devicetree/bindings/.gitignore index 3a05b99bfa26..a77719968a7e 100644 --- a/Documentation/devicetree/bindings/.gitignore +++ b/Documentation/devicetree/bindings/.gitignore @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only *.example.dts -processed-schema*.yaml -processed-schema*.json +/processed-schema*.yaml +/processed-schema*.json diff --git a/arch/.gitignore b/arch/.gitignore index 4191da401dbb..756c19c34f99 100644 --- a/arch/.gitignore +++ b/arch/.gitignore @@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only -i386 -x86_64 +/i386/ +/x86_64/ diff --git a/certs/.gitignore b/certs/.gitignore index 6cbd1f1a5837..8c3763f80be3 100644 --- a/certs/.gitignore +++ b/certs/.gitignore @@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only -x509_certificate_list -x509_revocation_list +/x509_certificate_list +/x509_revocation_list diff --git a/drivers/memory/.gitignore b/drivers/memory/.gitignore index caedc4c7d2db..5e84bee05ef8 100644 --- a/drivers/memory/.gitignore +++ b/drivers/memory/.gitignore @@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -ti-emif-asm-offsets.h +/ti-emif-asm-offsets.h diff --git a/drivers/tty/vt/.gitignore b/drivers/tty/vt/.gitignore index 3ecf42234d89..0221709b177d 100644 --- a/drivers/tty/vt/.gitignore +++ b/drivers/tty/vt/.gitignore @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -conmakehash -consolemap_deftbl.c -defkeymap.c +/conmakehash +/consolemap_deftbl.c +/defkeymap.c diff --git a/fs/unicode/.gitignore b/fs/unicode/.gitignore index 9b2467e77b2d..361294571ab0 100644 --- a/fs/unicode/.gitignore +++ b/fs/unicode/.gitignore @@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only -mkutf8data -utf8data.h +/mkutf8data +/utf8data.h diff --git a/kernel/.gitignore b/kernel/.gitignore index dafdce3d18c5..c6b299a6b786 100644 --- a/kernel/.gitignore +++ b/kernel/.gitignore @@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only /config_data -kheaders.md5 +/kheaders.md5 diff --git a/lib/.gitignore b/lib/.gitignore index 327cb2c7f2c9..5e7fa54c4536 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only -gen_crc32table -gen_crc64table -crc32table.h -crc64table.h -oid_registry_data.c +/crc32table.h +/crc64table.h +/gen_crc32table +/gen_crc64table +/oid_registry_data.c diff --git a/samples/auxdisplay/.gitignore b/samples/auxdisplay/.gitignore index 2ed744c0e741..d023816849bd 100644 --- a/samples/auxdisplay/.gitignore +++ b/samples/auxdisplay/.gitignore @@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -cfag12864b-example +/cfag12864b-example diff --git a/samples/binderfs/.gitignore b/samples/binderfs/.gitignore index eb60241e8087..8fa415a3640b 100644 --- a/samples/binderfs/.gitignore +++ b/samples/binderfs/.gitignore @@ -1 +1,2 @@ -binderfs_example +# SPDX-License-Identifier: GPL-2.0 +/binderfs_example diff --git a/samples/connector/.gitignore b/samples/connector/.gitignore index d86f2ff9c947..0e26039f39b5 100644 --- a/samples/connector/.gitignore +++ b/samples/connector/.gitignore @@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -ucon +/ucon diff --git a/samples/hidraw/.gitignore b/samples/hidraw/.gitignore index d7a6074ebcf9..5233ab63262e 100644 --- a/samples/hidraw/.gitignore +++ b/samples/hidraw/.gitignore @@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -hid-example +/hid-example diff --git a/samples/mei/.gitignore b/samples/mei/.gitignore index db5e802f041e..fe894bcb6a62 100644 --- a/samples/mei/.gitignore +++ b/samples/mei/.gitignore @@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -mei-amt-version +/mei-amt-version diff --git a/samples/nitro_enclaves/.gitignore b/samples/nitro_enclaves/.gitignore index 827934129c90..6a718eec71f4 100644 --- a/samples/nitro_enclaves/.gitignore +++ b/samples/nitro_enclaves/.gitignore @@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0 -ne_ioctl_sample +/ne_ioctl_sample diff --git a/samples/pidfd/.gitignore b/samples/pidfd/.gitignore index eea857fca736..d4cfa3176b1b 100644 --- a/samples/pidfd/.gitignore +++ b/samples/pidfd/.gitignore @@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -pidfd-metadata +/pidfd-metadata diff --git a/samples/seccomp/.gitignore b/samples/seccomp/.gitignore index 4a5a5b7db30b..a6df0da77c5d 100644 --- a/samples/seccomp/.gitignore +++ b/samples/seccomp/.gitignore @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -bpf-direct -bpf-fancy -dropper -user-trap +/bpf-direct +/bpf-fancy +/dropper +/user-trap diff --git a/samples/timers/.gitignore b/samples/timers/.gitignore index 40510c33cf08..cd9ff7b95383 100644 --- a/samples/timers/.gitignore +++ b/samples/timers/.gitignore @@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -hpet_example +/hpet_example diff --git a/samples/vfs/.gitignore b/samples/vfs/.gitignore index 8fdabf7e5373..79212d91285b 100644 --- a/samples/vfs/.gitignore +++ b/samples/vfs/.gitignore @@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only -test-fsmount -test-statx +/test-fsmount +/test-statx diff --git a/samples/watch_queue/.gitignore b/samples/watch_queue/.gitignore index 2aa3c7e56a1a..823b351d3db9 100644 --- a/samples/watch_queue/.gitignore +++ b/samples/watch_queue/.gitignore @@ -1 +1,2 @@ -watch_test +# SPDX-License-Identifier: GPL-2.0-only +/watch_test diff --git a/samples/watchdog/.gitignore b/samples/watchdog/.gitignore index 74153b831244..a70a0150ed9f 100644 --- a/samples/watchdog/.gitignore +++ b/samples/watchdog/.gitignore @@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -watchdog-simple +/watchdog-simple diff --git a/scripts/.gitignore b/scripts/.gitignore index a6c11316c969..e83c620ef52c 100644 --- a/scripts/.gitignore +++ b/scripts/.gitignore @@ -1,11 +1,11 @@ # SPDX-License-Identifier: GPL-2.0-only -bin2c -kallsyms -unifdef -recordmcount -sorttable -asn1_compiler -extract-cert -sign-file -insert-sys-cert +/asn1_compiler +/bin2c +/extract-cert +/insert-sys-cert +/kallsyms /module.lds +/recordmcount +/sign-file +/sorttable +/unifdef diff --git a/scripts/basic/.gitignore b/scripts/basic/.gitignore index 98ae1f509592..961c91c8a884 100644 --- a/scripts/basic/.gitignore +++ b/scripts/basic/.gitignore @@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -fixdep +/fixdep diff --git a/scripts/dtc/.gitignore b/scripts/dtc/.gitignore index 8a8b62bf3d3c..e0b5c1d2464a 100644 --- a/scripts/dtc/.gitignore +++ b/scripts/dtc/.gitignore @@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only -dtc -fdtoverlay +/dtc +/fdtoverlay diff --git a/scripts/gcc-plugins/.gitignore b/scripts/gcc-plugins/.gitignore index b04e0f0f033e..5cc385b9eb97 100644 --- a/scripts/gcc-plugins/.gitignore +++ b/scripts/gcc-plugins/.gitignore @@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -randomize_layout_seed.h +/randomize_layout_seed.h diff --git a/scripts/genksyms/.gitignore b/scripts/genksyms/.gitignore index 999af710f83d..0b275abf9405 100644 --- a/scripts/genksyms/.gitignore +++ b/scripts/genksyms/.gitignore @@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -genksyms +/genksyms diff --git a/scripts/mod/.gitignore b/scripts/mod/.gitignore index 07e4a39f90a6..0465ec33c9bf 100644 --- a/scripts/mod/.gitignore +++ b/scripts/mod/.gitignore @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -elfconfig.h -mk_elfconfig -modpost -devicetable-offsets.h +/devicetable-offsets.h +/elfconfig.h +/mk_elfconfig +/modpost diff --git a/usr/.gitignore b/usr/.gitignore index 935442ed1eb2..8996e7a88902 100644 --- a/usr/.gitignore +++ b/usr/.gitignore @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only -gen_init_cpio -initramfs_data.cpio +/gen_init_cpio +/initramfs_data.cpio /initramfs_inc_data -- cgit From 45799491a92174ff78d9c46de55d614814bdd3e1 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 2 May 2021 02:24:35 +0900 Subject: kbuild: remove ARCH=sh64 support from top Makefile Commit 37744feebc08 ("sh: remove sh5 support") removed the SUPERH64 support entirely. Remove the left-over code from the top Makefile. Signed-off-by: Masahiro Yamada Acked-by: Arnd Bergmann --- Makefile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Makefile b/Makefile index 3597fd75d5b5..cbf4b18cf51c 100644 --- a/Makefile +++ b/Makefile @@ -399,11 +399,6 @@ ifeq ($(ARCH),sparc64) SRCARCH := sparc endif -# Additional ARCH settings for sh -ifeq ($(ARCH),sh64) - SRCARCH := sh -endif - export cross_compiling := ifneq ($(SRCARCH),$(SUBARCH)) cross_compiling := 1 -- cgit From 23243c1ace9fb4eae2f75e0fe0ece8e3219fb4f3 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 2 May 2021 02:24:36 +0900 Subject: arch: use cross_compiling to check whether it is a cross build or not 'cross_compiling' is defined by the top Makefile and available for arch Makefiles to check whether it is a cross build or not. A good thing is the variable name 'cross_compiling' is self-documenting. This is a simple replacement for m68k, mips, sh, for which $(ARCH) and $(SRCARCH) always match. No functional change is intended for xtensa, either. This is rather a fix for parisc because arch/parisc/Makefile defines UTS_MATCHINE depending on CONFIG_64BIT, therefore cc-cross-prefix is not working in Kconfig time. Signed-off-by: Masahiro Yamada Acked-by: Geert Uytterhoeven Acked-by: Helge Deller # parisc Acked-by: Max Filippov # xtensa --- arch/m68k/Makefile | 2 +- arch/mips/Makefile | 2 +- arch/parisc/Makefile | 2 +- arch/sh/Makefile | 2 +- arch/xtensa/Makefile | 6 +----- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile index ea14f2046fb4..82620f14124d 100644 --- a/arch/m68k/Makefile +++ b/arch/m68k/Makefile @@ -16,7 +16,7 @@ KBUILD_DEFCONFIG := multi_defconfig -ifneq ($(SUBARCH),$(ARCH)) +ifdef cross_compiling ifeq ($(CROSS_COMPILE),) CROSS_COMPILE := $(call cc-cross-prefix, \ m68k-linux-gnu- m68k-linux- m68k-unknown-linux-gnu-) diff --git a/arch/mips/Makefile b/arch/mips/Makefile index e71d587af49c..258234c35a09 100644 --- a/arch/mips/Makefile +++ b/arch/mips/Makefile @@ -50,7 +50,7 @@ tool-archpref = $(64bit-tool-archpref) UTS_MACHINE := mips64 endif -ifneq ($(SUBARCH),$(ARCH)) +ifdef cross_compiling ifeq ($(CROSS_COMPILE),) CROSS_COMPILE := $(call cc-cross-prefix, $(tool-archpref)-linux- $(tool-archpref)-linux-gnu- $(tool-archpref)-unknown-linux-gnu-) endif diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile index 7d9f71aa829a..aed8ea29268b 100644 --- a/arch/parisc/Makefile +++ b/arch/parisc/Makefile @@ -41,7 +41,7 @@ endif export LD_BFD -ifneq ($(SUBARCH),$(UTS_MACHINE)) +ifdef cross_compiling ifeq ($(CROSS_COMPILE),) CC_SUFFIXES = linux linux-gnu unknown-linux-gnu CROSS_COMPILE := $(call cc-cross-prefix, \ diff --git a/arch/sh/Makefile b/arch/sh/Makefile index 3bcbf52fb30e..44bcb80e791a 100644 --- a/arch/sh/Makefile +++ b/arch/sh/Makefile @@ -9,7 +9,7 @@ # License. See the file "COPYING" in the main directory of this archive # for more details. # -ifneq ($(SUBARCH),$(ARCH)) +ifdef cross_compiling ifeq ($(CROSS_COMPILE),) CROSS_COMPILE := $(call cc-cross-prefix, sh-linux- sh-linux-gnu- sh-unknown-linux-gnu-) endif diff --git a/arch/xtensa/Makefile b/arch/xtensa/Makefile index ba9fee75e675..e9c8f064c44d 100644 --- a/arch/xtensa/Makefile +++ b/arch/xtensa/Makefile @@ -19,12 +19,8 @@ variant-y := $(patsubst "%",%,$(CONFIG_XTENSA_VARIANT_NAME)) VARIANT = $(variant-y) export VARIANT -# Test for cross compiling - ifneq ($(VARIANT),) - COMPILE_ARCH = $(shell uname -m) - - ifneq ($(COMPILE_ARCH), xtensa) + ifdef cross_compiling ifndef CROSS_COMPILE CROSS_COMPILE = xtensa_$(VARIANT)- endif -- cgit From 44f87191d105519cdf37fb0d4988006ea04eb34e Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 3 May 2021 03:09:55 +0900 Subject: kbuild: parameterize the .o part of suffix-search The suffix-search macro hard-codes the suffix, '.o'. Make it a parameter so that the multi-search and real-search macros can be reused for foo-dtbs syntax introduced by commit 15d16d6dadf6 ("kbuild: Add generic rule to apply fdtoverlay"). Signed-off-by: Masahiro Yamada --- scripts/Makefile.lib | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index c0982b8b2b6d..0c8d146879eb 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -44,19 +44,22 @@ else obj-y := $(filter-out %/, $(obj-y)) endif -# Expand $(foo-objs) $(foo-y) by calling $(call suffix-search,foo.o,-objs -y) -suffix-search = $(strip $(foreach s, $2, $($(1:.o=$s)))) +# Expand $(foo-objs) $(foo-y) etc. by replacing their individuals +suffix-search = $(strip $(foreach s, $3, $($(1:%$(strip $2)=%$s)))) +# List composite targets that are constructed by combining other targets +multi-search = $(sort $(foreach m, $1, $(if $(call suffix-search, $m, $2, $3 -), $m))) +# List primitive targets that are compiled from source files +real-search = $(foreach m, $1, $(if $(call suffix-search, $m, $2, $3 -), $(call suffix-search, $m, $2, $3), $m)) + # If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object -multi-search = $(sort $(foreach m, $1, $(if $(call suffix-search, $m, $2 -), $m))) -multi-obj-y := $(call multi-search,$(obj-y),-objs -y) -multi-obj-m := $(call multi-search,$(obj-m),-objs -y -m) +multi-obj-y := $(call multi-search, $(obj-y), .o, -objs -y) +multi-obj-m := $(call multi-search, $(obj-m), .o, -objs -y -m) multi-obj-ym := $(multi-obj-y) $(multi-obj-m) # Replace multi-part objects by their individual parts, # including built-in.a from subdirectories -real-search = $(foreach m, $1, $(if $(call suffix-search, $m, $2 -), $(call suffix-search, $m, $2), $m)) -real-obj-y := $(call real-search, $(obj-y),-objs -y) -real-obj-m := $(call real-search, $(obj-m),-objs -y -m) +real-obj-y := $(call real-search, $(obj-y), .o, -objs -y) +real-obj-m := $(call real-search, $(obj-m), .o, -objs -y -m) always-y += $(always-m) -- cgit From bcf0c6642833673830ee9d9b40862a4c476d1565 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 3 May 2021 03:09:56 +0900 Subject: kbuild: refactor fdtoverlay rule Rename overlay-y to multi-dtb-y, which is a consistent name with multi-obj-y. Also, use multi-search to avoid code duplication. Introduce real-dtb-y, which is a consistent name with real-obj-y, to contain primitive blobs compiled from *.dts. This is used to calculate the list of *.dt.yaml files. Set -@ to base DTB without using $(eval ). Signed-off-by: Masahiro Yamada --- scripts/Makefile.build | 2 +- scripts/Makefile.lib | 33 +++++++++++++++------------------ 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 5e39b0517186..949f723efe53 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -354,7 +354,7 @@ $(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE targets += $(filter-out $(subdir-builtin), $(real-obj-y)) targets += $(filter-out $(subdir-modorder), $(real-obj-m)) -targets += $(lib-y) $(always-y) $(MAKECMDGOALS) +targets += $(real-dtb-y) $(lib-y) $(always-y) $(MAKECMDGOALS) # Linker scripts preprocessor (.lds.S -> .lds) # --------------------------------------------------------------------------- diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 0c8d146879eb..deac60727e48 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -78,24 +78,18 @@ always-y += $(userprogs-always-y) $(userprogs-always-m) # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built dtb-$(CONFIG_OF_ALL_DTBS) += $(dtb-) -# List all dtbs to be generated by fdtoverlay -overlay-y := $(foreach m,$(dtb-y), $(if $(strip $($(m:.dtb=-dtbs))),$(m),)) - -# Generate symbols for the base files so overlays can be applied to them. -$(foreach m,$(overlay-y), $(eval DTC_FLAGS_$(basename $(firstword $($(m:.dtb=-dtbs)))) += -@)) - -# Add base dtb and overlay dtbo -dtb-y += $(foreach m,$(overlay-y), $($(m:.dtb=-dtbs))) +# Composite DTB (i.e. DTB constructed by overlay) +multi-dtb-y := $(call multi-search, $(dtb-y), .dtb, -dtbs) +# Primitive DTB compiled from *.dts +real-dtb-y := $(call real-search, $(dtb-y), .dtb, -dtbs) +# Base DTB that overlay is applied onto (each first word of $(*-dtbs) expansion) +base-dtb-y := $(foreach m, $(multi-dtb-y), $(firstword $(call suffix-search, $m, .dtb, -dtbs))) always-y += $(dtb-y) ifneq ($(CHECK_DTBS),) -# Don't run schema checks for dtbs created by fdtoverlay as they don't -# have corresponding dts files. -dt-yaml-y := $(filter-out $(overlay-y),$(dtb-y)) - -always-y += $(patsubst %.dtb,%.dt.yaml, $(dt-yaml-y)) -always-y += $(patsubst %.dtbo,%.dt.yaml, $(dt-yaml-y)) +always-y += $(patsubst %.dtb,%.dt.yaml, $(real-dtb-y)) +always-y += $(patsubst %.dtbo,%.dt.yaml, $(real-dtb-y)) endif # Add subdir path @@ -108,6 +102,8 @@ lib-y := $(addprefix $(obj)/,$(lib-y)) real-obj-y := $(addprefix $(obj)/,$(real-obj-y)) real-obj-m := $(addprefix $(obj)/,$(real-obj-m)) multi-obj-m := $(addprefix $(obj)/, $(multi-obj-m)) +multi-dtb-y := $(addprefix $(obj)/, $(multi-dtb-y)) +real-dtb-y := $(addprefix $(obj)/, $(real-dtb-y)) subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) # Finds the multi-part object the current object will be linked into. @@ -325,6 +321,9 @@ endif DTC_FLAGS += $(DTC_FLAGS_$(basetarget)) +# Set -@ if the target is a base DTB that overlay is applied onto +DTC_FLAGS += $(if $(filter $(patsubst $(obj)/%,%,$@), $(base-dtb-y)), -@) + # Generate an assembly file to wrap the output of the device tree compiler quiet_cmd_dt_S_dtb= DTB $@ cmd_dt_S_dtb= \ @@ -356,14 +355,12 @@ $(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE $(obj)/%.dtbo: $(src)/%.dts $(DTC) FORCE $(call if_changed_dep,dtc) -overlay-y := $(addprefix $(obj)/, $(overlay-y)) - quiet_cmd_fdtoverlay = DTOVL $@ cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(real-prereqs) -$(overlay-y): FORCE +$(multi-dtb-y): FORCE $(call if_changed,fdtoverlay) -$(call multi_depend, $(overlay-y), .dtb, -dtbs) +$(call multi_depend, $(multi-dtb-y), .dtb, -dtbs) DT_CHECKER ?= dt-validate DT_CHECKER_FLAGS ?= $(if $(DT_SCHEMA_FILES),,-m) -- cgit From d4452837ffbeb59e18f2499ef907579a618d623d Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 3 May 2021 03:09:57 +0900 Subject: kbuild: refactor modname-multi by using suffix-search Improve the readability slightly. Signed-off-by: Masahiro Yamada --- scripts/Makefile.lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index deac60727e48..10950559b223 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -109,7 +109,7 @@ subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) # Finds the multi-part object the current object will be linked into. # If the object belongs to two or more multi-part objects, list them all. modname-multi = $(sort $(foreach m,$(multi-obj-ym),\ - $(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=)))) + $(if $(filter $*.o, $(call suffix-search, $m, .o, -objs -y -m)),$(m:.o=)))) __modname = $(if $(modname-multi),$(modname-multi),$(basetarget)) -- cgit From 19c8d912837e45e99b2991228adfc4419ffff248 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 May 2021 19:10:56 +0900 Subject: kbuild: make distclean work against $(objtree) instead of $(srctree) This reverts the old commit [1], which seems questionable to me. It claimed 'make distclean' could not remove editor backup files, but I believe KBUILD_OUTPUT or O= was set. When O= is given, Kbuild should always work against $(objtree). If O= is not given, $(objtree) and $(srctree) are the same, therefore $(srctree) is cleaned up. [1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=dd47df980c02eb33833b2690b033c34fba2fa80d Signed-off-by: Masahiro Yamada --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cbf4b18cf51c..560408808c33 100644 --- a/Makefile +++ b/Makefile @@ -1546,7 +1546,7 @@ PHONY += distclean distclean: mrproper $(call cmd,rmfiles) - @find $(srctree) $(RCS_FIND_IGNORE) \ + @find . $(RCS_FIND_IGNORE) \ \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ -o -name '*.bak' -o -name '#*#' -o -name '*%' \ -o -name 'core' \) \ -- cgit From 7a02cec523a90fec78634c655e2470f72d2fdcbf Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 May 2021 19:10:57 +0900 Subject: kbuild: make distclean remove tag files in sub-directories 'make tags' and friends create tag files in the top directory, but people may manually create tag files in sub-directories. Signed-off-by: Masahiro Yamada --- Makefile | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 560408808c33..2cbf68dc40b7 100644 --- a/Makefile +++ b/Makefile @@ -1511,9 +1511,6 @@ MRPROPER_FILES += include/config include/generated \ signing_key.x509.signer vmlinux-gdb.py \ *.spec -# Directories & files removed with 'make distclean' -DISTCLEAN_FILES += tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS - # clean - Delete most, but leave enough to build external modules # clean: rm-files := $(CLEAN_FILES) @@ -1540,16 +1537,14 @@ mrproper: clean $(mrproper-dirs) # distclean # -distclean: rm-files := $(wildcard $(DISTCLEAN_FILES)) - PHONY += distclean distclean: mrproper - $(call cmd,rmfiles) @find . $(RCS_FIND_IGNORE) \ \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ -o -name '*.bak' -o -name '#*#' -o -name '*%' \ - -o -name 'core' \) \ + -o -name 'core' -o -name tags -o -name TAGS -o -name 'cscope*' \ + -o -name GPATH -o -name GRTAGS -o -name GSYMS -o -name GTAGS \) \ -type f -print | xargs rm -f -- cgit From 11122b860bc52a09c779c3de9415436794fb5605 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 May 2021 19:10:58 +0900 Subject: kbuild: remove the unneeded comments for external module builds The supported targets for external modules are listed in the help target a few lines below. Let's not have duplicated information in two places. Signed-off-by: Masahiro Yamada --- Makefile | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 2cbf68dc40b7..9b9a003bd88f 100644 --- a/Makefile +++ b/Makefile @@ -1711,17 +1711,7 @@ else # KBUILD_EXTMOD # When building external modules the kernel used as basis is considered # read-only, and no consistency checks are made and the make # system is not used on the basis kernel. If updates are required -# in the basis kernel ordinary make commands (without M=...) must -# be used. -# -# The following are the only valid targets when building external -# modules. -# make M=dir clean Delete all automatically generated files -# make M=dir modules Make all modules in specified dir -# make M=dir Same as 'make M=dir modules' -# make M=dir modules_install -# Install the modules built in the module directory -# Assumes install directory is already created +# in the basis kernel ordinary make commands (without M=...) must be used. # We are always building only modules. KBUILD_BUILTIN := -- cgit From 51eb95e2da41802454f48b9afeb4d96a77295035 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Tue, 4 May 2021 20:35:27 -0700 Subject: kbuild: Don't remove link-vmlinux temporary files on exit/signal Keep them around until they are cleaned up by make clean. This uses a bit more disk space, but makes it easier to debug any problems with the kernel link process. Suggested-by: Masahiro Yamada Signed-off-by: Andi Kleen Signed-off-by: Masahiro Yamada --- scripts/link-vmlinux.sh | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 7d112681f332..f4de4c97015b 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -320,20 +320,6 @@ cleanup() rm -f .vmlinux.d } -on_exit() -{ - if [ $? -ne 0 ]; then - cleanup - fi -} -trap on_exit EXIT - -on_signals() -{ - exit 1 -} -trap on_signals HUP INT QUIT TERM - # Use "make V=1" to debug this script case "${KBUILD_VERBOSE}" in *1*) -- cgit From 0ab1438bad43d95877f848b7df551bd431680270 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 6 May 2021 02:45:15 +0900 Subject: linux/kconfig.h: replace IF_ENABLED() with PTR_IF() in is included from all the kernel-space source files, including C, assembly, linker scripts. It is intended to contain a minimal set of macros to evaluate CONFIG options. IF_ENABLED() is an intruder here because (x ? y : z) is C code, which should not be included from assembly files or linker scripts. Also, is no longer self-contained because NULL is defined in . Move IF_ENABLED() out to as PTR_IF(). PTF_IF() takes the general boolean expression instead of a CONFIG option so that it fits better in . Signed-off-by: Masahiro Yamada Reviewed-by: Kees Cook --- drivers/pinctrl/pinctrl-ingenic.c | 3 +++ include/linux/kconfig.h | 6 ------ include/linux/kernel.h | 2 ++ 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c index 651a36b9dcc0..983ba9865f77 100644 --- a/drivers/pinctrl/pinctrl-ingenic.c +++ b/drivers/pinctrl/pinctrl-ingenic.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -3854,6 +3855,8 @@ static int __init ingenic_pinctrl_probe(struct platform_device *pdev) return 0; } +#define IF_ENABLED(cfg, ptr) PTR_IF(IS_ENABLED(cfg), (ptr)) + static const struct of_device_id ingenic_pinctrl_of_match[] = { { .compatible = "ingenic,jz4730-pinctrl", diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h index 24a59cb06963..cc8fa109cfa3 100644 --- a/include/linux/kconfig.h +++ b/include/linux/kconfig.h @@ -70,10 +70,4 @@ */ #define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option)) -/* - * IF_ENABLED(CONFIG_FOO, ptr) evaluates to (ptr) if CONFIG_FOO is set to 'y' - * or 'm', NULL otherwise. - */ -#define IF_ENABLED(option, ptr) (IS_ENABLED(option) ? (ptr) : NULL) - #endif /* __LINUX_KCONFIG_H */ diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 5b7ed6dc99ac..2f9d15410c93 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -48,6 +48,8 @@ */ #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) +#define PTR_IF(cond, ptr) ((cond) ? (ptr) : NULL) + #define u64_to_user_ptr(x) ( \ { \ typecheck(u64, (x)); \ -- cgit