From 67e62c746823329a4a65356ab0fe81dfc2b8784b Mon Sep 17 00:00:00 2001 From: Ruben Di Battista Date: Thu, 6 Aug 2020 12:12:30 +0200 Subject: [PATCH 01/11] drivers: usb: Fix config indentation The indentation was messing up with the scripts/build-whitelist.sh that was marking SYS_USB_EVENT_POLL_VIA_INT_QUEUE (and probably also the other indented options) erroneously as ad-hoc configure option with the following error: ``` Error: You must add new CONFIG options using Kconfig The following new ad-hoc CONFIG options were detected: CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE ``` --- drivers/usb/Kconfig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 756a4ec402..34881a12b8 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig @@ -113,14 +113,14 @@ choice ---help--- Enable a polling mechanism for USB keyboard. - config SYS_USB_EVENT_POLL - bool "Interrupt polling" +config SYS_USB_EVENT_POLL + bool "Interrupt polling" - config SYS_USB_EVENT_POLL_VIA_INT_QUEUE - bool "Poll via interrupt queue" +config SYS_USB_EVENT_POLL_VIA_INT_QUEUE + bool "Poll via interrupt queue" - config SYS_USB_EVENT_POLL_VIA_CONTROL_EP - bool "Poll via control EP" +config SYS_USB_EVENT_POLL_VIA_CONTROL_EP + bool "Poll via control EP" endchoice From a261fdce381639b93b0efed5d5202c60d92f0e37 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 19 Aug 2020 10:44:15 +0200 Subject: [PATCH 02/11] pci: kconfig: Setup proper dependency for PCIE_ROCKCHIP There is missing dependency for PCIE_ROCKCHIP which selects PHY_ROCKCHIP_PCIE which directly depends on ARCH_ROCKCHIP. WARNING: unmet direct dependencies detected for PHY_ROCKCHIP_PCIE Depends on [n]: ARCH_ROCKCHIP [=n] Selected by [y]: - PCIE_ROCKCHIP [=y] && PCI [=y] Signed-off-by: Michal Simek Reviewed-by: Tom Rini --- drivers/pci/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index 06d39df1d3..c19d09bc41 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -260,6 +260,7 @@ config PCIE_MEDIATEK config PCIE_ROCKCHIP bool "Enable Rockchip PCIe driver" + depends on ARCH_ROCKCHIP select DM_PCI select PHY_ROCKCHIP_PCIE default y if ROCKCHIP_RK3399 From 6e741cfa9392ffe3fe87d7657ea9f828bfec4abc Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 19 Aug 2020 10:44:17 +0200 Subject: [PATCH 03/11] cmd: Kconfig: Change dependency for CMD_ADC CMD_ADC selected DM_REGULATOR unconditionally without enabling DM. That's why change select to depends on to cover it. Kconfig is showing this issue as: WARNING: unmet direct dependencies detected for REGMAP Depends on [n]: DM [=n] Selected by [y]: - DM_REGULATOR_PBIAS [=y] && DM_REGULATOR [=y] Signed-off-by: Michal Simek Reviewed-by: Tom Rini [trini: Update CMD_ADC=y configs to enable DM_REGULATOR now] Signed-off-by: Tom Rini --- cmd/Kconfig | 2 +- configs/khadas-vim2_defconfig | 1 + configs/khadas-vim_defconfig | 1 + configs/libretech-ac_defconfig | 1 + configs/libretech-cc_defconfig | 1 + configs/libretech-s905d-pc_defconfig | 1 + configs/libretech-s912-pc_defconfig | 1 + configs/odroid-c2_defconfig | 1 + configs/stm32mp15_basic_defconfig | 1 + configs/stm32mp15_dhcom_basic_defconfig | 1 + configs/stm32mp15_dhcor_basic_defconfig | 1 + configs/stm32mp15_trusted_defconfig | 1 + 12 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index 30c26b5d2b..0761dbb746 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -860,7 +860,7 @@ config CMD_ARMFLASH config CMD_ADC bool "adc - Access Analog to Digital Converters info and data" select ADC - select DM_REGULATOR + depends on DM_REGULATOR help Shows ADC device info and permit printing one-shot analog converted data from a named Analog to Digital Converter. diff --git a/configs/khadas-vim2_defconfig b/configs/khadas-vim2_defconfig index b6d5dbdd2e..1435781f59 100644 --- a/configs/khadas-vim2_defconfig +++ b/configs/khadas-vim2_defconfig @@ -43,6 +43,7 @@ CONFIG_PHY=y CONFIG_MESON_GXL_USB_PHY=y CONFIG_PINCTRL=y CONFIG_PINCTRL_MESON_GXL=y +CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_RESET=y CONFIG_DEBUG_UART_ANNOUNCE=y diff --git a/configs/khadas-vim_defconfig b/configs/khadas-vim_defconfig index 2a57cfb400..d075dd134c 100644 --- a/configs/khadas-vim_defconfig +++ b/configs/khadas-vim_defconfig @@ -39,6 +39,7 @@ CONFIG_PHY=y CONFIG_MESON_GXL_USB_PHY=y CONFIG_PINCTRL=y CONFIG_PINCTRL_MESON_GXL=y +CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_RESET=y CONFIG_DEBUG_UART_ANNOUNCE=y diff --git a/configs/libretech-ac_defconfig b/configs/libretech-ac_defconfig index d5a812c3d8..e898fb147f 100644 --- a/configs/libretech-ac_defconfig +++ b/configs/libretech-ac_defconfig @@ -53,6 +53,7 @@ CONFIG_PINCTRL=y CONFIG_PINCTRL_MESON_GXL=y CONFIG_POWER_DOMAIN=y CONFIG_MESON_GX_VPU_POWER_DOMAIN=y +CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_RESET=y CONFIG_DEBUG_UART_ANNOUNCE=y diff --git a/configs/libretech-cc_defconfig b/configs/libretech-cc_defconfig index dce861b8aa..65ad7f5de4 100644 --- a/configs/libretech-cc_defconfig +++ b/configs/libretech-cc_defconfig @@ -40,6 +40,7 @@ CONFIG_PINCTRL=y CONFIG_PINCTRL_MESON_GXL=y CONFIG_POWER_DOMAIN=y CONFIG_MESON_GX_VPU_POWER_DOMAIN=y +CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_RESET=y CONFIG_DEBUG_UART_ANNOUNCE=y diff --git a/configs/libretech-s905d-pc_defconfig b/configs/libretech-s905d-pc_defconfig index 225a21f0ff..c99a6c5971 100644 --- a/configs/libretech-s905d-pc_defconfig +++ b/configs/libretech-s905d-pc_defconfig @@ -48,6 +48,7 @@ CONFIG_PINCTRL=y CONFIG_PINCTRL_MESON_GXL=y CONFIG_POWER_DOMAIN=y CONFIG_MESON_GX_VPU_POWER_DOMAIN=y +CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_RESET=y CONFIG_DEBUG_UART_ANNOUNCE=y diff --git a/configs/libretech-s912-pc_defconfig b/configs/libretech-s912-pc_defconfig index 005dc0b25e..7975c590b6 100644 --- a/configs/libretech-s912-pc_defconfig +++ b/configs/libretech-s912-pc_defconfig @@ -47,6 +47,7 @@ CONFIG_PINCTRL=y CONFIG_PINCTRL_MESON_GXL=y CONFIG_POWER_DOMAIN=y CONFIG_MESON_GX_VPU_POWER_DOMAIN=y +CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_RESET=y CONFIG_DEBUG_UART_ANNOUNCE=y diff --git a/configs/odroid-c2_defconfig b/configs/odroid-c2_defconfig index 3c53233dcc..82bae79d3d 100644 --- a/configs/odroid-c2_defconfig +++ b/configs/odroid-c2_defconfig @@ -40,6 +40,7 @@ CONFIG_PINCTRL=y CONFIG_PINCTRL_MESON_GXBB=y CONFIG_POWER_DOMAIN=y CONFIG_MESON_GX_VPU_POWER_DOMAIN=y +CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_REGULATOR_GPIO=y CONFIG_DM_RESET=y diff --git a/configs/stm32mp15_basic_defconfig b/configs/stm32mp15_basic_defconfig index 2094183295..a8c4112dbe 100644 --- a/configs/stm32mp15_basic_defconfig +++ b/configs/stm32mp15_basic_defconfig @@ -116,6 +116,7 @@ CONFIG_PINCTRL_STMFX=y CONFIG_DM_PMIC=y # CONFIG_SPL_PMIC_CHILDREN is not set CONFIG_PMIC_STPMIC1=y +CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_REGULATOR_GPIO=y CONFIG_DM_REGULATOR_STM32_VREFBUF=y diff --git a/configs/stm32mp15_dhcom_basic_defconfig b/configs/stm32mp15_dhcom_basic_defconfig index c70414e23b..7668fd01cd 100644 --- a/configs/stm32mp15_dhcom_basic_defconfig +++ b/configs/stm32mp15_dhcom_basic_defconfig @@ -114,6 +114,7 @@ CONFIG_PINCTRL_STMFX=y CONFIG_DM_PMIC=y # CONFIG_SPL_PMIC_CHILDREN is not set CONFIG_PMIC_STPMIC1=y +CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_REGULATOR_GPIO=y CONFIG_DM_REGULATOR_STM32_VREFBUF=y diff --git a/configs/stm32mp15_dhcor_basic_defconfig b/configs/stm32mp15_dhcor_basic_defconfig index 1e1aa86426..aa384517c3 100644 --- a/configs/stm32mp15_dhcor_basic_defconfig +++ b/configs/stm32mp15_dhcor_basic_defconfig @@ -108,6 +108,7 @@ CONFIG_PINCTRL_STMFX=y CONFIG_DM_PMIC=y # CONFIG_SPL_PMIC_CHILDREN is not set CONFIG_PMIC_STPMIC1=y +CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_REGULATOR_GPIO=y CONFIG_DM_REGULATOR_STM32_VREFBUF=y diff --git a/configs/stm32mp15_trusted_defconfig b/configs/stm32mp15_trusted_defconfig index 8d59d84184..0792884a9d 100644 --- a/configs/stm32mp15_trusted_defconfig +++ b/configs/stm32mp15_trusted_defconfig @@ -94,6 +94,7 @@ CONFIG_PINCONF=y CONFIG_PINCTRL_STMFX=y CONFIG_DM_PMIC=y CONFIG_PMIC_STPMIC1=y +CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_REGULATOR_GPIO=y CONFIG_DM_REGULATOR_STM32_VREFBUF=y From 7b56432c7bc548194bc7c5fa9494392e9a24048a Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 19 Aug 2020 10:44:20 +0200 Subject: [PATCH 04/11] arc: Kconfig: Add missing DM dependency ARC is selecting TIMER which depends on DM but DM is not selected and doesn't need to be enabled. Fix it by selecting DM for ARC architecture. Kconfig is showing this missing dependency by: WARNING: unmet direct dependencies detected for TIMER Depends on [n]: DM [=n] Selected by [y]: - ARC [=y] && Signed-off-by: Michal Simek Reviewed-by: Simon Glass --- arch/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/Kconfig b/arch/Kconfig index e4a0a0230c..683e384319 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -12,6 +12,7 @@ config ARC bool "ARC architecture" select ARC_TIMER select CLK + select DM select HAVE_PRIVATE_LIBGCC select SUPPORT_OF_CONTROL select TIMER From 076617847a2cfa5a7b16fd2b729091c5bf2d5b78 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 19 Aug 2020 10:44:23 +0200 Subject: [PATCH 05/11] env: Kconfig: Add missing dependency for ENV_IS_IN_EXT4 ENV_IS_IN_EXT4 also need to enable FS_EXT4 which is not covered in Kconfig. Kconfig reports this as: WARNING: unmet direct dependencies detected for EXT4_WRITE Depends on [n]: FS_EXT4 [=n] Selected by [y]: - ENV_IS_IN_EXT4 [=y] && !CHAIN_OF_TRUST [=n] Signed-off-by: Michal Simek Reviewed-by: Tom Rini --- env/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/env/Kconfig b/env/Kconfig index af4d9cbaa4..b59ba310ec 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -72,6 +72,7 @@ config ENV_IS_IN_FAT config ENV_IS_IN_EXT4 bool "Environment is in a EXT4 filesystem" depends on !CHAIN_OF_TRUST + select FS_EXT4 select EXT4_WRITE help Define this if you want to use the EXT4 file system for the environment. From 12178b51c22d07229375f25e39acb0ab7735ff81 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 20 Aug 2020 08:37:49 -0400 Subject: [PATCH 06/11] checkpatch.pl: Make fdt / initrd relocation disabling an error Entirely disabling relocation of the device tree or initrd is almost never the right answer. Doing this by default leads to hard to diagnose run-time failures. Signed-off-by: Tom Rini --- scripts/checkpatch.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 3932362dba..4bed2b0cdc 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2359,6 +2359,12 @@ sub u_boot_line { ERROR("BARRED_INCLUDE_IN_HDR", "Avoid including common.h and dm.h in header files\n" . $herecurr); } + + # Do not disable fdt / initrd relocation + if ($rawline =~ /.*(fdt|initrd)_high=0xffffffff/) { + ERROR("DISABLE_FDT_OR_INITRD_RELOC", + "fdt or initrd relocation disabled at boot time\n" . $herecurr); + } } sub process { From 4431a9889c67f76e66aa99fb9ad9e10c014e268f Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 21 Aug 2020 03:56:17 +0200 Subject: [PATCH 07/11] test: undefined reference to 'sscanf' Compiling with CONFIG_UNIT_TEST=y leads to: aarch64-linux-gnu-ld.bfd: test/lib/sscanf.c:50: undefined reference to `sscanf' Add missing build dependency. Fixes:e87dfb0526be ("lib: sscanf: add sscanf implementation") Signed-off-by: Heinrich Schuchardt --- test/lib/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lib/Makefile b/test/lib/Makefile index ada62fe46b..22236f8587 100644 --- a/test/lib/Makefile +++ b/test/lib/Makefile @@ -7,7 +7,7 @@ obj-$(CONFIG_EFI_LOADER) += efi_device_path.o obj-$(CONFIG_EFI_SECURE_BOOT) += efi_image_region.o obj-y += hexdump.o obj-y += lmb.o -obj-y += sscanf.o +obj-$(CONFIG_SSCANF) += sscanf.o obj-y += string.o obj-$(CONFIG_ERRNO_STR) += test_errno_str.o obj-$(CONFIG_UT_LIB_ASN1) += asn1.o From de95930946f5de3b5f43aaf4153a334d841d4f3c Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 20 Aug 2020 21:11:17 +0200 Subject: [PATCH 08/11] lib/rsa: correct check after allocation in fdt_add_bignum() After allocating to pointer ctx we should check that pointer and not another pointer already checked above. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- lib/rsa/rsa-sign.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c index 40ca1e1f57..1f0d81bd7a 100644 --- a/lib/rsa/rsa-sign.c +++ b/lib/rsa/rsa-sign.c @@ -708,7 +708,7 @@ static int fdt_add_bignum(void *blob, int noffset, const char *prop_name, return -ENOMEM; } ctx = BN_CTX_new(); - if (!tmp) { + if (!ctx) { fprintf(stderr, "Out of memory (bignum context)\n"); return -ENOMEM; } From 0b2b9b85d0d6d69b7b6ce7c6f4e2db91f0d43759 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Mon, 24 Aug 2020 13:17:00 +0200 Subject: [PATCH 09/11] cmd: mem: Remove already removed CONFIG_SYS_MEMTEST_SCRATCH The commit e519f03a1846 ("cmd: mem: Remove CONFIG_SYS_MEMTEST_SCRATCH mapping") removed CONFIG_SYS_MEMTEST_SCRATCH but commit 091401131085 ("command: Remove the cmd_tbl_t typedef") has added it back. That's why symbol is still in the tree that's why remove it again. Fixes: 091401131085 ("command: Remove the cmd_tbl_t typedef Signed-off-by: Michal Simek Reviewed-by: Simon Glass --- cmd/mem.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cmd/mem.c b/cmd/mem.c index 190e2b94a7..9df5eb068a 100644 --- a/cmd/mem.c +++ b/cmd/mem.c @@ -30,10 +30,6 @@ DECLARE_GLOBAL_DATA_PTR; -#ifndef CONFIG_SYS_MEMTEST_SCRATCH -#define CONFIG_SYS_MEMTEST_SCRATCH 0 -#endif - /* Create a compile-time value */ #ifdef MEM_SUPPORT_64BIT_DATA #define SUPPORT_64BIT_DATA 1 From 7f98b4eeee3278419e901e209d1ffebbc7573d0e Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Mon, 24 Aug 2020 20:14:05 +0300 Subject: [PATCH 10/11] image: don't exceed gd->ram_top in bootm_size When board_get_usable_ram_top() limits gd->ram_top, env_get_bootm_size() must not exceed that limit. Otherwise, boot_relocate_fdt() might put fdt out of the allowed RAM range. The similar commit 8ce1f10cf2b1 ("ARM: bootm: take into account gd->ram_top") exposed this bug. This fixes boot on Armada 8040 based Clearfog GT-8K where ram_top is set to 0x80000000 (2GB), but bi_dram[0].size might be up to 0xc0000000 (3GB). Note the relocated fdt address (0xbfff4000) in the console output listed below: Found /extlinux/extlinux.conf Retrieving file: /extlinux/extlinux.conf 62 bytes read in 21 ms (2 KiB/s) 1: linux Retrieving file: /extlinux/Image 13740544 bytes read in 1266 ms (10.4 MiB/s) Retrieving file: /extlinux/armada-8040-clearfog-gt-8k.dtb 33368 bytes read in 31 ms (1 MiB/s) Booting using the fdt blob at 0x4f00000 Loading Device Tree to 00000000bfff4000, end 00000000bffff257 ... "Synchronous Abort" handler, esr 0x96000045 elr: 000000000006e1cc lr : 0000000000068fd8 (reloc) elr: 000000007ffa91cc lr : 000000007ffa3fd8 x0 : ffffffffffffffff x1 : 00000000bfffc258 x2 : 0000000000000000 x3 : ffffffffffff7da7 x4 : 0000000004f08258 x5 : 00000000bfff4000 x6 : 00000000bfff4000 x7 : 000000000000000f x8 : 000000007fb23bf8 x9 : 0000000000000008 x10: 00000000bffff257 x11: 00000000bffff257 x12: 0000000000000000 x13: fffffffffffff000 x14: 00000000bfff4000 x15: 0000000000000021 x16: 000000007ff7bc38 x17: 0000000000000000 x18: 000000007fb2add0 x19: 00000000bfff4000 x20: 0000000004f00000 x21: 000000000000b258 x22: 0000000058820000 x23: 0000000000000010 x24: 000000007ffe3c40 x25: 000000007fb23cb8 x26: 00000000c0000000 x27: 0000000000000000 x28: 000000007fc3fd50 x29: 000000007fb23bd0 Code: 54000061 aa0603e0 d65f03c0 38606882 (38206822) Resetting CPU ... Thanks to Patrice CHOTARD who directed me to the right way. Signed-off-by: Baruch Siach --- common/image.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/image.c b/common/image.c index 9d7d5c17d1..da8bccd400 100644 --- a/common/image.c +++ b/common/image.c @@ -694,6 +694,9 @@ phys_size_t env_get_bootm_size(void) size = gd->bd->bi_memsize; #endif + if (start + size > gd->ram_top) + size = gd->ram_top - start; + s = env_get("bootm_low"); if (s) tmp = (phys_size_t)simple_strtoull(s, NULL, 16); From 2ed1b242ab2f9ee7541ae0a655de67832a3eebc1 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Tue, 25 Aug 2020 17:28:39 +0200 Subject: [PATCH 11/11] scripts/setlocalversion: sync with linux 5.8 The linux changes since v3.16 are 78283edf2c01 kbuild: setlocalversion: print error to STDERR b24413180f56 License cleanup: add SPDX GPL-2.0 license identifier to files with no license 6147b1cf1965 scripts/setlocalversion: git: Make -dirty check more robust 8ef14c2c41d9 Revert "scripts/setlocalversion: git: Make -dirty check more robust" ff64dd485730 scripts/setlocalversion: Improve -dirty check with git-status --no-optional-locks 7a82e3fa28f1 scripts/setlocalversion: clear local variable to make it work for sh 991b78fbd223 scripts: setlocalversion: fix a bashism 3c96bdd0ebfa scripts: setlocalversion: replace backquote to dollar parenthesis and it's ff64dd485730 that is the motivation for this sync. It fixes false positive "-dirty" added to the version string when building with Yocto (https://lists.openembedded.org/g/openembedded-core/message/137702). There has been one U-Boot specific patch since this was synced with linux 3.16: 81630a3b38c2 (scripts: setlocalversion: safely extract variables from auto.conf using awk). Keep these changes applied. Signed-off-by: Rasmus Villemoes [trini: Re-add 81630a3b38c2 and reword message] Signed-off-by: Tom Rini --- scripts/setlocalversion | 43 +++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 8564bedd1a..c1c0435267 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -1,4 +1,5 @@ #!/bin/sh +# SPDX-License-Identifier: GPL-2.0 # # This scripts adds local version information from the version # control systems git, mercurial (hg) and subversion (svn). @@ -44,11 +45,11 @@ scm_version() # Check for git and a git repo. if test -z "$(git rev-parse --show-cdup 2>/dev/null)" && - head=`git rev-parse --verify --short HEAD 2>/dev/null`; then + head=$(git rev-parse --verify --short HEAD 2>/dev/null); then # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore # it, because this version is defined in the top level Makefile. - if [ -z "`git describe --exact-match 2>/dev/null`" ]; then + if [ -z "$(git describe --exact-match 2>/dev/null)" ]; then # If only the short version is requested, don't bother # running further git commands @@ -58,7 +59,7 @@ scm_version() fi # If we are past a tagged commit (like # "v2.6.30-rc5-302-g72357d5"), we pretty print it. - if atag="`git describe 2>/dev/null`"; then + if atag="$(git describe 2>/dev/null)"; then echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}' # If we don't have a tag at all we print -g{commitish}. @@ -69,11 +70,19 @@ scm_version() # Is this git on svn? if git config --get svn-remote.svn.url >/dev/null; then - printf -- '-svn%s' "`git svn find-rev $head`" + printf -- '-svn%s' "$(git svn find-rev $head)" fi - # Check for uncommitted changes - if git diff-index --name-only HEAD | grep -qv "^scripts/package"; then + # Check for uncommitted changes. + # First, with git-status, but --no-optional-locks is only + # supported in git >= 2.14, so fall back to git-diff-index if + # it fails. Note that git-diff-index does not refresh the + # index, so it may give misleading results. See + # git-update-index(1), git-diff-index(1), and git-status(1). + if { + git --no-optional-locks status -uno --porcelain 2>/dev/null || + git diff-index --name-only HEAD + } | grep -qvE '^(.. )?scripts/package'; then printf '%s' -dirty fi @@ -82,15 +91,15 @@ scm_version() fi # Check for mercurial and a mercurial repo. - if test -d .hg && hgid=`hg id 2>/dev/null`; then + if test -d .hg && hgid=$(hg id 2>/dev/null); then # Do we have an tagged version? If so, latesttagdistance == 1 - if [ "`hg log -r . --template '{latesttagdistance}'`" == "1" ]; then - id=`hg log -r . --template '{latesttag}'` + if [ "$(hg log -r . --template '{latesttagdistance}')" = "1" ]; then + id=$(hg log -r . --template '{latesttag}') printf '%s%s' -hg "$id" else - tag=`printf '%s' "$hgid" | cut -d' ' -f2` + tag=$(printf '%s' "$hgid" | cut -d' ' -f2) if [ -z "$tag" -o "$tag" = tip ]; then - id=`printf '%s' "$hgid" | sed 's/[+ ].*//'` + id=$(printf '%s' "$hgid" | sed 's/[+ ].*//') printf '%s%s' -hg "$id" fi fi @@ -106,8 +115,8 @@ 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 - rev=`echo $rev | awk '{print $NF}'` + if rev=$(LANG= LC_ALL= LC_MESSAGES=C svn info 2>/dev/null | grep '^Last Changed Rev'); then + rev=$(echo $rev | awk '{print $NF}') printf -- '-svn%s' "$rev" # All done with svn @@ -117,7 +126,7 @@ scm_version() collect_files() { - local file res + local file res= for file; do case "$file" in @@ -142,12 +151,12 @@ fi if test -e include/config/auto.conf; then # We are interested only in CONFIG_LOCALVERSION and - # CONFIG_LOCALVERSION_AUTO, so extract these in a safe - # way (i.e. w/o sourcing auto.conf) + # CONFIG_LOCALVERSION_AUTO, so extract these in a safe + # way (i.e. w/o sourcing auto.conf) CONFIG_LOCALVERSION=`cat include/config/auto.conf | awk -F '=' '/^CONFIG_LOCALVERSION=/ {print $2}'` CONFIG_LOCALVERSION_AUTO=`cat include/config/auto.conf | awk -F '=' '/^CONFIG_LOCALVERSION_AUTO=/ {print $2}'` else - echo "Error: kernelrelease not valid - run 'make prepare' to update it" + echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2 exit 1 fi