From d39a9871815405277a760307e58bd29973ef57b6 Mon Sep 17 00:00:00 2001 From: Robert Karszniewicz Date: Mon, 10 Aug 2020 14:20:08 +0200 Subject: bootm: add global.bootm.root_dev env var for booting via PARTUUID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduces a new env var which specifies which device is the rootfs device to be used in Linux, passed to Linux via bootargs, identified by the rootfs partition's PARTUUID. global.bootm.root_dev supplements global.bootm.appendroot, in that it overrides appendroot's naïve default, which picks the partition that the kernel resides on (global.bootm.image). Example: detect mmc2 global.bootm.image='/mnt/mmc2.0/zImage' global.bootm.appendroot=1 global.bootm.root_dev=/dev/mmc2.1 boot mmc Signed-off-by: Robert Karszniewicz Signed-off-by: Sascha Hauer --- common/bootm.c | 25 +++++++++++++++++++++++-- include/bootm.h | 2 ++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/common/bootm.c b/common/bootm.c index 7f22ca5ced..5dc00e713d 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -65,6 +65,7 @@ void bootm_data_init_defaults(struct bootm_data *data) getenv_ul("global.bootm.image.loadaddr", &data->os_address); getenv_ul("global.bootm.initrd.loadaddr", &data->initrd_address); data->initrd_file = getenv_nonempty("global.bootm.initrd"); + data->root_dev = getenv_nonempty("global.bootm.root_dev"); data->verify = bootm_get_verify_mode(); data->appendroot = bootm_appendroot; data->provide_machine_id = bootm_provide_machine_id; @@ -711,7 +712,25 @@ int bootm_boot(struct bootm_data *bootm_data) if (bootm_data->appendroot) { char *rootarg; - rootarg = path_get_linux_rootarg(data->os_file); + if (bootm_data->root_dev) { + const char *root_dev_name = devpath_to_name(bootm_data->root_dev); + const struct cdev *root_cdev = cdev_by_name(root_dev_name); + + if (root_cdev && root_cdev->partuuid[0] != 0) { + rootarg = basprintf("root=PARTUUID=%s", root_cdev->partuuid); + } else { + rootarg = ERR_PTR(-EINVAL); + + if (!root_cdev) + pr_err("no cdev found for %s, cannot set root= option\n", + root_dev_name); + else if (!root_cdev->partuuid[0]) + pr_err("%s doesn't have a PARTUUID, cannot set root= option\n", + root_dev_name); + } + } else { + rootarg = path_get_linux_rootarg(data->os_file); + } if (!IS_ERR(rootarg)) { printf("Adding \"%s\" to Kernel commandline\n", rootarg); globalvar_add_simple("linux.bootargs.bootm.appendroot", @@ -802,6 +821,7 @@ static int bootm_init(void) globalvar_add_simple("bootm.image", NULL); globalvar_add_simple("bootm.image.loadaddr", NULL); globalvar_add_simple("bootm.oftree", NULL); + globalvar_add_simple("bootm.root_dev", NULL); globalvar_add_simple("bootm.tee", NULL); globalvar_add_simple_bool("bootm.appendroot", &bootm_appendroot); globalvar_add_simple_bool("bootm.provide_machine_id", &bootm_provide_machine_id); @@ -831,5 +851,6 @@ BAREBOX_MAGICVAR_NAMED(global_bootm_oftree, global.bootm.oftree, "bootm default BAREBOX_MAGICVAR_NAMED(global_bootm_tee, global.bootm.tee, "bootm default tee image"); BAREBOX_MAGICVAR_NAMED(global_bootm_verify, global.bootm.verify, "bootm default verify level"); BAREBOX_MAGICVAR_NAMED(global_bootm_verbose, global.bootm.verbose, "bootm default verbosity level (0=quiet)"); -BAREBOX_MAGICVAR_NAMED(global_bootm_appendroot, global.bootm.appendroot, "Add root= option to Kernel to mount rootfs from the device the Kernel comes from"); +BAREBOX_MAGICVAR_NAMED(global_bootm_appendroot, global.bootm.appendroot, "Add root= option to Kernel to mount rootfs from the device the Kernel comes from (default, device can be overridden via global.bootm.root_dev)"); +BAREBOX_MAGICVAR_NAMED(global_bootm_root_dev, global.bootm.root_dev, "bootm default root device (overrides default device in global.bootm.appendroot)"); BAREBOX_MAGICVAR_NAMED(global_bootm_provide_machine_id, global.bootm.provide_machine_id, "If true, add systemd.machine_id= with value of global.machine_id to Kernel"); diff --git a/include/bootm.h b/include/bootm.h index ef5148f31e..51e9b3d71a 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -18,6 +18,7 @@ struct bootm_data { const char *initrd_file; const char *oftree_file; const char *tee_file; + const char *root_dev; int verbose; enum bootm_verify verify; bool force; @@ -25,6 +26,7 @@ struct bootm_data { /* * appendroot - if true, try to add a suitable root= Kernel option to * mount the rootfs from the same device as the Kernel comes from. + * The default rootfs device can be overridden with root_dev. */ bool appendroot; /* -- cgit v1.2.3 From b78bb8f25e7e3fc8b7306ad65c2ff5c5780897e0 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 17 Aug 2020 06:53:31 +0200 Subject: video: ipuv3: parallel-display: support of_graph binding "fsl,imx-parallel-display"-compatible devices are supposed to support two bindings to query the connected LCD's parameters: - A display timings sub node - A of_graph pointing to a panel or a bridge So far only the first was supported. Mimic what LDB is already doing, so we support both. Unlike LDB, if both are specified, the display timings node takes precedence. This is to maintain backwards compatibility. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- drivers/video/imx-ipu-v3/imx-pd.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/drivers/video/imx-ipu-v3/imx-pd.c b/drivers/video/imx-ipu-v3/imx-pd.c index 601be35880..fa6314c044 100644 --- a/drivers/video/imx-ipu-v3/imx-pd.c +++ b/drivers/video/imx-ipu-v3/imx-pd.c @@ -27,6 +27,8 @@ #include "imx-ipu-v3.h" +#define IMX_PD_OUTPUT_PORT 1 + struct imx_pd { struct device_d *dev; struct display_timings *timings; @@ -39,7 +41,6 @@ static int imx_pd_ioctl(struct vpl *vpl, unsigned int port, { struct imx_pd *imx_pd = container_of(vpl, struct imx_pd, vpl); struct ipu_di_mode *mode; - struct display_timings *timings; switch (cmd) { case IMX_IPU_VPL_DI_MODE: @@ -50,15 +51,21 @@ static int imx_pd_ioctl(struct vpl *vpl, unsigned int port, return 0; case VPL_GET_VIDEOMODES: - timings = data; - - timings->num_modes = imx_pd->timings->num_modes; - timings->native_mode = imx_pd->timings->native_mode; - timings->modes = imx_pd->timings->modes; - timings->edid = NULL; - return 0; + if (imx_pd->timings) { + struct display_timings *timings = data; + + timings->num_modes = imx_pd->timings->num_modes; + timings->native_mode = imx_pd->timings->native_mode; + timings->modes = imx_pd->timings->modes; + timings->edid = NULL; + return 0; + } + break; } + if (!imx_pd->timings) + return vpl_ioctl(vpl, IMX_PD_OUTPUT_PORT, cmd, data); + return 0; } @@ -66,6 +73,7 @@ static int imx_pd_probe(struct device_d *dev) { struct device_node *node = dev->device_node; struct imx_pd *imx_pd; + struct device_node *port; const char *fmt; int ret; @@ -88,8 +96,11 @@ static int imx_pd_probe(struct device_d *dev) imx_pd->timings = of_get_display_timings(node); if (!imx_pd->timings) { - dev_err(dev, "No display timings panel found\n"); - return -EINVAL; + port = of_graph_get_port_by_id(node, IMX_PD_OUTPUT_PORT); + if (!port) { + dev_err(dev, "Neither display timings in nor remote panel found in node\n"); + return -EINVAL; + } } imx_pd->vpl.node = node; -- cgit v1.2.3 From b4ea941373b8b243e7f4ee44184dad48214d56da Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 17 Aug 2020 06:53:32 +0200 Subject: video: simple-panel: don't error out on unhandled ioctl command Video devices propagate ioctls down the pipeline by calling vpl_ioctl themselves. This also happens when propagating VPL_PREPARE. simple-panel doesn't have anything special to do in VPL_PREPARE, so it returned -ENOSYS so far. This leads vpl_ioctl to fail, which in turn is propagated back through the pipeline. For devices with multiple endpoints, vpl_ioctl passes the ioctl to each one of them. An early exit by a simple-panel can thus cause other endpoints to not prepare themselves leading to display issues. Fix this by having the simple panel ignore ioctls that aren't relevant to it. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- drivers/video/simple-panel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/simple-panel.c b/drivers/video/simple-panel.c index 1d05153d16..2f904a7b2b 100644 --- a/drivers/video/simple-panel.c +++ b/drivers/video/simple-panel.c @@ -135,7 +135,7 @@ static int simple_panel_ioctl(struct vpl *vpl, unsigned int port, case VPL_GET_VIDEOMODES: return simple_panel_get_modes(panel, ptr); default: - return -ENOSYS; + return 0; } } -- cgit v1.2.3 From 4cb36b107a3af4af338fc94e5abb7a92348d415b Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Mon, 24 Aug 2020 09:00:48 +0200 Subject: treewide: s/filed/failed/ Fix typos. Signed-off-by: Sascha Hauer --- drivers/remoteproc/imx_rproc.c | 8 ++++---- drivers/remoteproc/remoteproc_core.c | 2 +- drivers/watchdog/efi_wdt.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index c5cba3711a..370bebe6e2 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -172,7 +172,7 @@ static int imx_rproc_start(struct rproc *rproc) ret = regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, dcfg->src_start); if (ret) - dev_err(dev, "Filed to enable M4!\n"); + dev_err(dev, "Failed to enable M4!\n"); return ret; } @@ -187,7 +187,7 @@ static int imx_rproc_stop(struct rproc *rproc) ret = regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, dcfg->src_stop); if (ret) - dev_err(dev, "Filed to stop M4!\n"); + dev_err(dev, "Failed to stop M4!\n"); return ret; } @@ -210,7 +210,7 @@ static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 da, } } - dev_warn(priv->dev, "Translation filed: da = 0x%llx len = 0x%x\n", + dev_warn(priv->dev, "Translation failed: da = 0x%llx len = 0x%x\n", da, len); return -ENOENT; } @@ -353,7 +353,7 @@ static int imx_rproc_probe(struct device_d *dev) ret = imx_rproc_addr_init(priv, dev); if (ret) { - dev_err(dev, "filed on imx_rproc_addr_init\n"); + dev_err(dev, "failed on imx_rproc_addr_init\n"); goto err_put_rproc; } diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 8a28c1bafc..a81787bc6c 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -143,7 +143,7 @@ int rproc_add(struct rproc *rproc) ret = firmwaremgr_register(fh); if (ret) - dev_err(dev, "filed to register firmware handler %s\n", rproc->name); + dev_err(dev, "failed to register firmware handler %s\n", rproc->name); else dev_info(dev, "%s is available\n", rproc->name); diff --git a/drivers/watchdog/efi_wdt.c b/drivers/watchdog/efi_wdt.c index ea1ede1381..1512b1d99a 100644 --- a/drivers/watchdog/efi_wdt.c +++ b/drivers/watchdog/efi_wdt.c @@ -24,7 +24,7 @@ static int efi_wdt_set_timeout(struct watchdog *wd, unsigned timeout) efiret = BS->set_watchdog_timer(timeout, 0, 0, NULL); if (EFI_ERROR(efiret)) { - dev_err(priv->dev, "filed to set EFI watchdog: %lx\n", efiret); + dev_err(priv->dev, "failed to set EFI watchdog: %lx\n", efiret); return -EINVAL; } -- cgit v1.2.3 From 62f92623b980d034e186bfb7dcb9b6138f953c19 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Mon, 24 Aug 2020 09:02:27 +0200 Subject: treewide: s/filed/field/ Fix typos. Signed-off-by: Sascha Hauer --- drivers/clk/mvebu/armada-38x.c | 2 +- drivers/clk/mvebu/armada-xp.c | 2 +- include/linux/mtd/bbm.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/clk/mvebu/armada-38x.c b/drivers/clk/mvebu/armada-38x.c index 627de7de6c..80865965e1 100644 --- a/drivers/clk/mvebu/armada-38x.c +++ b/drivers/clk/mvebu/armada-38x.c @@ -17,7 +17,7 @@ /* * Core Clocks * - * Armada XP Sample At Reset is a 64 bit bitfiled split in two + * Armada XP Sample At Reset is a 64 bit bitfield split in two * register of 32 bits */ diff --git a/drivers/clk/mvebu/armada-xp.c b/drivers/clk/mvebu/armada-xp.c index d79f846d3f..f0276d32f5 100644 --- a/drivers/clk/mvebu/armada-xp.c +++ b/drivers/clk/mvebu/armada-xp.c @@ -16,7 +16,7 @@ /* * Core Clocks * - * Armada XP Sample At Reset is a 64 bit bitfiled split in two + * Armada XP Sample At Reset is a 64 bit bitfield split in two * register of 32 bits */ diff --git a/include/linux/mtd/bbm.h b/include/linux/mtd/bbm.h index 36bb6a503f..1e39883a2d 100644 --- a/include/linux/mtd/bbm.h +++ b/include/linux/mtd/bbm.h @@ -159,7 +159,7 @@ struct bbm_info { int (*isbad_bbt)(struct mtd_info *mtd, loff_t ofs, int allowbbt); - /* TODO Add more NAND specific fileds */ + /* TODO Add more NAND specific fields */ struct nand_bbt_descr *badblock_pattern; void *priv; -- cgit v1.2.3 From a38c18e8504ff602832d585fb5575d470fdfd157 Mon Sep 17 00:00:00 2001 From: Roland Hieber Date: Mon, 24 Aug 2020 00:30:53 +0200 Subject: common: remove negative dependency on SANDBOX for IMD_TARGET This dependency was added in commit b3d5c43cb8a2d492355a (2016-04-07, Antony Pavlov: "common: add dependency !SANDBOX on imd target tool"), but it seems to compile fine four years down the line. Signed-off-by: Roland Hieber Signed-off-by: Sascha Hauer --- common/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/common/Kconfig b/common/Kconfig index b350f5c355..140b0f95c1 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -699,7 +699,6 @@ config IMD config IMD_TARGET bool "build bareboximd target tool" depends on IMD - depends on !SANDBOX config KERNEL_INSTALL_TARGET bool -- cgit v1.2.3 From 3aae70c626187fbf3ce1ca4307ae8241826a6d3b Mon Sep 17 00:00:00 2001 From: Roland Hieber Date: Mon, 24 Aug 2020 00:39:27 +0200 Subject: sandbox: add a minimal defconfig to build only the host tools For distro packaging, make it possible to build all host tools in one go (and a very minimal barebox image as an unimportant side artifact). Signed-off-by: Roland Hieber Signed-off-by: Sascha Hauer --- arch/sandbox/configs/hosttools_defconfig | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 arch/sandbox/configs/hosttools_defconfig diff --git a/arch/sandbox/configs/hosttools_defconfig b/arch/sandbox/configs/hosttools_defconfig new file mode 100644 index 0000000000..72ec0fc462 --- /dev/null +++ b/arch/sandbox/configs/hosttools_defconfig @@ -0,0 +1,7 @@ +CONFIG_IMD=y +CONFIG_COMPILE_HOST_TOOLS=y +CONFIG_ARCH_IMX_USBLOADER=y +CONFIG_MVEBU_HOSTTOOLS=y +CONFIG_MXS_HOSTTOOLS=y +CONFIG_OMAP3_USB_LOADER=y +CONFIG_OMAP4_HOSTTOOL_USBBOOT=y -- cgit v1.2.3 From 788546fdd86c3321c6e3ffb53774ec935b3a87a7 Mon Sep 17 00:00:00 2001 From: Thorsten Scherer Date: Fri, 11 Sep 2020 19:25:34 +0200 Subject: Documentation: user: fix referenced filename Adjust filename and path of nfsroot.txt according to Linux commit f9a9349 ("Documentation: nfsroot.txt: convert to ReST") Signed-off-by: Sascha Hauer --- Documentation/user/booting-linux.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/user/booting-linux.rst b/Documentation/user/booting-linux.rst index 983b56deef..60babb513c 100644 --- a/Documentation/user/booting-linux.rst +++ b/Documentation/user/booting-linux.rst @@ -274,7 +274,7 @@ In any case, make sure that the specified mountpoint is exported by your NFS server. For more information about booting with ``nfsroot``, see -`Documentation/filesystems/nfs/nfsroot.txt `__ +`Documentation/admin-guide/nfs/nfsroot.rst `__ in the Linux kernel documentation. If the preconfigured paths or names are not suitable, they can be adjusted in -- cgit v1.2.3 From b5edf4f6f07b8f0f129c70e6ceaf6ed60d6a7c5f Mon Sep 17 00:00:00 2001 From: Albert Schwarzkopf Date: Wed, 9 Sep 2020 12:54:46 +0200 Subject: common: bootm: Add missing check of fit_open_image() return code Check the return code of fit_open_image() inside bootm_load_initrd(). Without this check, the code works with undefined values of "initrd_size" and "initrd" should fit_open_image() fail. Signed-off-by: Albert Schwarzkopf Signed-off-by: Sascha Hauer --- common/bootm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/bootm.c b/common/bootm.c index 5dc00e713d..60b8bf10a8 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -233,7 +233,11 @@ int bootm_load_initrd(struct image_data *data, unsigned long load_address) ret = fit_open_image(data->os_fit, data->fit_config, "ramdisk", &initrd, &initrd_size); - + if (ret) { + pr_err("Cannot open ramdisk image in FIT image: %s\n", + strerror(-ret)); + return ret; + } data->initrd_res = request_sdram_region("initrd", load_address, initrd_size); -- cgit v1.2.3 From 3724dc9c8dff40e1c775951eb23aea7feb0c7703 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Thu, 3 Sep 2020 12:24:43 +0200 Subject: mfd: stpmic1: warn if reset reason detection fails stpmic1_set_reset_reason returns an error code, but so far we didn't check it. Fix this. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- drivers/watchdog/stpmic1_wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/watchdog/stpmic1_wdt.c b/drivers/watchdog/stpmic1_wdt.c index 458c5c16a3..12280f1447 100644 --- a/drivers/watchdog/stpmic1_wdt.c +++ b/drivers/watchdog/stpmic1_wdt.c @@ -200,7 +200,7 @@ static int stpmic1_wdt_probe(struct device_d *dev) if (ret) dev_warn(dev, "Cannot register poweroff handler\n"); - stpmic1_set_reset_reason(wdt->regmap); + ret = stpmic1_set_reset_reason(wdt->regmap); if (ret) dev_warn(dev, "Cannot query reset reason\n"); -- cgit v1.2.3 From 5089c7cd6c25aff16058565d244dac9bc57c9543 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Thu, 3 Sep 2020 12:24:44 +0200 Subject: ARM: stm32mp: enable mmc_extcsd in defconfig The documentation suggests use of mmc_extcsd for configuring the boot ack bit needed to boot from eMMC, thus have it enabled in the defconfig. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- arch/arm/configs/stm32mp_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/configs/stm32mp_defconfig b/arch/arm/configs/stm32mp_defconfig index c98908debc..92bdf5b040 100644 --- a/arch/arm/configs/stm32mp_defconfig +++ b/arch/arm/configs/stm32mp_defconfig @@ -37,6 +37,7 @@ CONFIG_CMD_MEMINFO=y CONFIG_CMD_ARM_MMUINFO=y CONFIG_CMD_REGULATOR=y CONFIG_CMD_MMC=y +CONFIG_CMD_MMC_EXTCSD=y # CONFIG_CMD_BOOTU is not set CONFIG_CMD_GO=y CONFIG_CMD_RESET=y -- cgit v1.2.3 From 4669b5eacd48cd9bbb4e1d9d69e64491378b6cfa Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 28 Aug 2020 12:30:14 +0900 Subject: kconfig: update to Linux 5.9-rc2 The previous sync was Linux 5.7-rc2. Resync scripts/kconfig/ and scripts/Kconfig.include with Linux 5.9-rc2. Highlights: - fix and improve 'make xconfig' - remove '---help---' keyword - forbid nested 'choice' blocks Signed-off-by: Masahiro Yamada Signed-off-by: Sascha Hauer --- scripts/Kconfig.include | 5 +- scripts/kconfig/.gitignore | 2 +- scripts/kconfig/Makefile | 24 +- scripts/kconfig/images.c | 30 +- scripts/kconfig/images.h | 30 +- scripts/kconfig/lexer.l | 4 +- scripts/kconfig/menu.c | 3 +- scripts/kconfig/parser.y | 30 +- scripts/kconfig/qconf.cc | 629 +++++++++++---------- scripts/kconfig/qconf.h | 89 +-- scripts/kconfig/streamline_config.pl | 21 + scripts/kconfig/symbol.c | 16 +- scripts/kconfig/tests/rand_nested_choice/Kconfig | 35 -- .../kconfig/tests/rand_nested_choice/__init__.py | 17 - .../tests/rand_nested_choice/expected_stdout0 | 2 - .../tests/rand_nested_choice/expected_stdout1 | 4 - .../tests/rand_nested_choice/expected_stdout2 | 5 - 17 files changed, 458 insertions(+), 488 deletions(-) delete mode 100644 scripts/kconfig/tests/rand_nested_choice/Kconfig delete mode 100644 scripts/kconfig/tests/rand_nested_choice/__init__.py delete mode 100644 scripts/kconfig/tests/rand_nested_choice/expected_stdout0 delete mode 100644 scripts/kconfig/tests/rand_nested_choice/expected_stdout1 delete mode 100644 scripts/kconfig/tests/rand_nested_choice/expected_stdout2 diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include index 496d11c92c..a5fe72c504 100644 --- a/scripts/Kconfig.include +++ b/scripts/Kconfig.include @@ -25,7 +25,7 @@ failure = $(if-success,$(1),n,y) # $(cc-option,) # Return y if the compiler supports , n otherwise -cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -S -x c /dev/null -o /dev/null) +cc-option = $(success,mkdir .tmp_$$$$; trap "rm -rf .tmp_$$$$" EXIT; $(CC) -Werror $(CLANG_FLAGS) $(1) -c -x c /dev/null -o .tmp_$$$$/tmp.o) # $(ld-option,) # Return y if the linker supports , n otherwise @@ -42,9 +42,6 @@ $(error-if,$(failure,command -v $(LD)),linker '$(LD)' not found) # Fail if the linker is gold as it's not capable of linking the kernel proper $(error-if,$(success, $(LD) -v | grep -q gold), gold linker '$(LD)' not supported) -# gcc version including patch level -gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh $(CC)) - # machine bit flags # $(m32-flag): -m32 if the compiler supports it, or an empty string otherwise. # $(m64-flag): -m64 if the compiler supports it, or an empty string otherwise. diff --git a/scripts/kconfig/.gitignore b/scripts/kconfig/.gitignore index 12a67fdab5..c3d537cd02 100644 --- a/scripts/kconfig/.gitignore +++ b/scripts/kconfig/.gitignore @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -*.moc +/qconf-moc.cc *conf-cfg # diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index c9d0a4a8ef..52b59bf9ef 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -96,11 +96,13 @@ configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/c PHONY += kvmconfig kvmconfig: kvm_guest.config - @: + @echo >&2 "WARNING: 'make $@' will be removed after Linux 5.10" + @echo >&2 " Please use 'make $<' instead." PHONY += xenconfig xenconfig: xen.config - @: + @echo >&2 "WARNING: 'make $@' will be removed after Linux 5.10" + @echo >&2 " Please use 'make $<' instead." PHONY += tinyconfig tinyconfig: @@ -123,7 +125,9 @@ help: @echo ' gconfig - Update current config utilising a GTK+ based front-end' @echo ' oldconfig - Update current config utilising a provided .config as base' @echo ' localmodconfig - Update current config disabling modules not loaded' + @echo ' except those preserved by LMC_KEEP environment variable' @echo ' localyesconfig - Update current config converting local mods to core' + @echo ' except those preserved by LMC_KEEP environment variable' @echo ' defconfig - New config with default from ARCH supplied defconfig' @echo ' savedefconfig - Save current config as ./defconfig (minimal config)' @echo ' allnoconfig - New config where all options are answered with no' @@ -137,9 +141,6 @@ help: @echo ' helpnewconfig - List new options and help text' @echo ' olddefconfig - Same as oldconfig but sets new symbols to their' @echo ' default value without prompting' - @echo ' kvmconfig - Enable additional options for kvm guest kernel support' - @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel' - @echo ' support' @echo ' tinyconfig - Configure the tiniest possible kernel' @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)' @@ -180,19 +181,22 @@ $(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg # qconf: Used for the xconfig target based on Qt hostprogs += qconf -qconf-cxxobjs := qconf.o +qconf-cxxobjs := qconf.o qconf-moc.o qconf-objs := images.o $(common-objs) HOSTLDLIBS_qconf = $(shell . $(obj)/qconf-cfg && echo $$libs) HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/qconf-cfg && echo $$cflags) +HOSTCXXFLAGS_qconf-moc.o = $(shell . $(obj)/qconf-cfg && echo $$cflags) -$(obj)/qconf.o: $(obj)/qconf-cfg $(obj)/qconf.moc +$(obj)/qconf.o: $(obj)/qconf-cfg quiet_cmd_moc = MOC $@ - cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) -i $< -o $@ + cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) $< -o $@ -$(obj)/%.moc: $(src)/%.h $(obj)/qconf-cfg - $(call cmd,moc) +$(obj)/qconf-moc.cc: $(src)/qconf.h $(obj)/qconf-cfg FORCE + $(call if_changed,moc) + +targets += qconf-moc.cc # gconf: Used for the gconfig target based on GTK+ hostprogs += gconf diff --git a/scripts/kconfig/images.c b/scripts/kconfig/images.c index b4fa0e4a63..2f9afffa5d 100644 --- a/scripts/kconfig/images.c +++ b/scripts/kconfig/images.c @@ -5,7 +5,7 @@ #include "images.h" -const char *xpm_load[] = { +const char * const xpm_load[] = { "22 22 5 1", ". c None", "# c #000000", @@ -35,7 +35,7 @@ const char *xpm_load[] = { "###############.......", "......................"}; -const char *xpm_save[] = { +const char * const xpm_save[] = { "22 22 5 1", ". c None", "# c #000000", @@ -65,7 +65,7 @@ const char *xpm_save[] = { "..##################..", "......................"}; -const char *xpm_back[] = { +const char * const xpm_back[] = { "22 22 3 1", ". c None", "# c #000083", @@ -93,7 +93,7 @@ const char *xpm_back[] = { "......................", "......................"}; -const char *xpm_tree_view[] = { +const char * const xpm_tree_view[] = { "22 22 2 1", ". c None", "# c #000000", @@ -120,7 +120,7 @@ const char *xpm_tree_view[] = { "......................", "......................"}; -const char *xpm_single_view[] = { +const char * const xpm_single_view[] = { "22 22 2 1", ". c None", "# c #000000", @@ -147,7 +147,7 @@ const char *xpm_single_view[] = { "......................", "......................"}; -const char *xpm_split_view[] = { +const char * const xpm_split_view[] = { "22 22 2 1", ". c None", "# c #000000", @@ -174,7 +174,7 @@ const char *xpm_split_view[] = { "......................", "......................"}; -const char *xpm_symbol_no[] = { +const char * const xpm_symbol_no[] = { "12 12 2 1", " c white", ". c black", @@ -191,7 +191,7 @@ const char *xpm_symbol_no[] = { " .......... ", " "}; -const char *xpm_symbol_mod[] = { +const char * const xpm_symbol_mod[] = { "12 12 2 1", " c white", ". c black", @@ -208,7 +208,7 @@ const char *xpm_symbol_mod[] = { " .......... ", " "}; -const char *xpm_symbol_yes[] = { +const char * const xpm_symbol_yes[] = { "12 12 2 1", " c white", ". c black", @@ -225,7 +225,7 @@ const char *xpm_symbol_yes[] = { " .......... ", " "}; -const char *xpm_choice_no[] = { +const char * const xpm_choice_no[] = { "12 12 2 1", " c white", ". c black", @@ -242,7 +242,7 @@ const char *xpm_choice_no[] = { " .... ", " "}; -const char *xpm_choice_yes[] = { +const char * const xpm_choice_yes[] = { "12 12 2 1", " c white", ". c black", @@ -259,7 +259,7 @@ const char *xpm_choice_yes[] = { " .... ", " "}; -const char *xpm_menu[] = { +const char * const xpm_menu[] = { "12 12 2 1", " c white", ". c black", @@ -276,7 +276,7 @@ const char *xpm_menu[] = { " .......... ", " "}; -const char *xpm_menu_inv[] = { +const char * const xpm_menu_inv[] = { "12 12 2 1", " c white", ". c black", @@ -293,7 +293,7 @@ const char *xpm_menu_inv[] = { " .......... ", " "}; -const char *xpm_menuback[] = { +const char * const xpm_menuback[] = { "12 12 2 1", " c white", ". c black", @@ -310,7 +310,7 @@ const char *xpm_menuback[] = { " .......... ", " "}; -const char *xpm_void[] = { +const char * const xpm_void[] = { "12 12 2 1", " c white", ". c black", diff --git a/scripts/kconfig/images.h b/scripts/kconfig/images.h index d8ff614bd0..7212dec200 100644 --- a/scripts/kconfig/images.h +++ b/scripts/kconfig/images.h @@ -10,21 +10,21 @@ extern "C" { #endif -extern const char *xpm_load[]; -extern const char *xpm_save[]; -extern const char *xpm_back[]; -extern const char *xpm_tree_view[]; -extern const char *xpm_single_view[]; -extern const char *xpm_split_view[]; -extern const char *xpm_symbol_no[]; -extern const char *xpm_symbol_mod[]; -extern const char *xpm_symbol_yes[]; -extern const char *xpm_choice_no[]; -extern const char *xpm_choice_yes[]; -extern const char *xpm_menu[]; -extern const char *xpm_menu_inv[]; -extern const char *xpm_menuback[]; -extern const char *xpm_void[]; +extern const char * const xpm_load[]; +extern const char * const xpm_save[]; +extern const char * const xpm_back[]; +extern const char * const xpm_tree_view[]; +extern const char * const xpm_single_view[]; +extern const char * const xpm_split_view[]; +extern const char * const xpm_symbol_no[]; +extern const char * const xpm_symbol_mod[]; +extern const char * const xpm_symbol_yes[]; +extern const char * const xpm_choice_no[]; +extern const char * const xpm_choice_yes[]; +extern const char * const xpm_menu[]; +extern const char * const xpm_menu_inv[]; +extern const char * const xpm_menuback[]; +extern const char * const xpm_void[]; #ifdef __cplusplus } diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l index 6354c905b0..240109f965 100644 --- a/scripts/kconfig/lexer.l +++ b/scripts/kconfig/lexer.l @@ -36,7 +36,7 @@ struct buffer { YY_BUFFER_STATE state; }; -struct buffer *current_buf; +static struct buffer *current_buf; static int last_ts, first_ts; @@ -105,7 +105,7 @@ n [A-Za-z0-9_-] "endchoice" return T_ENDCHOICE; "endif" return T_ENDIF; "endmenu" return T_ENDMENU; -"help"|"---help---" return T_HELP; +"help" return T_HELP; "hex" return T_HEX; "if" return T_IF; "imply" return T_IMPLY; diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index e436ba44c9..a5fbd6ccc0 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -65,7 +65,8 @@ void menu_add_entry(struct symbol *sym) struct menu *menu_add_menu(void) { last_entry_ptr = ¤t_entry->list; - return current_menu = current_entry; + current_menu = current_entry; + return current_menu; } void menu_end_menu(void) diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index 708b6c4b13..190f1117f3 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -119,20 +119,24 @@ mainmenu_stmt: T_MAINMENU T_WORD_QUOTE T_EOL stmt_list: /* empty */ - | stmt_list common_stmt + | stmt_list assignment_stmt | stmt_list choice_stmt + | stmt_list comment_stmt + | stmt_list config_stmt + | stmt_list if_stmt | stmt_list menu_stmt + | stmt_list menuconfig_stmt + | stmt_list source_stmt | stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); } | stmt_list error T_EOL { zconf_error("invalid statement"); } ; -common_stmt: - if_stmt - | comment_stmt - | config_stmt - | menuconfig_stmt - | source_stmt - | assignment_stmt +stmt_list_in_choice: + /* empty */ + | stmt_list_in_choice comment_stmt + | stmt_list_in_choice config_stmt + | stmt_list_in_choice if_stmt_in_choice + | stmt_list_in_choice error T_EOL { zconf_error("invalid statement"); } ; /* config/menuconfig entry */ @@ -254,7 +258,7 @@ choice_end: end } }; -choice_stmt: choice_entry choice_block choice_end +choice_stmt: choice_entry stmt_list_in_choice choice_end ; choice_option_list: @@ -305,11 +309,6 @@ default: | T_DEF_BOOL { $$ = S_BOOLEAN; } | T_DEF_TRISTATE { $$ = S_TRISTATE; } -choice_block: - /* empty */ - | choice_block common_stmt -; - /* if entry */ if_entry: T_IF expr T_EOL @@ -331,6 +330,9 @@ if_end: end if_stmt: if_entry stmt_list if_end ; +if_stmt_in_choice: if_entry stmt_list_in_choice if_end +; + /* menu entry */ menu: T_MENU T_WORD_QUOTE T_EOL diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index c0ac8f7b5f..8638785328 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -4,34 +4,25 @@ * Copyright (C) 2015 Boris Barbulovski */ -#include - -#include -#include -#include #include +#include +#include +#include +#include #include +#include +#include +#include #include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include #include #include "lkc.h" #include "qconf.h" -#include "qconf.moc" #include "images.h" @@ -40,11 +31,6 @@ static ConfigSettings *configSettings; QAction *ConfigMainWindow::saveAction; -static inline QString qgettext(const char* str) -{ - return QString::fromLocal8Bit(str); -} - ConfigSettings::ConfigSettings() : QSettings("kernel.org", "qconf") { @@ -88,6 +74,13 @@ bool ConfigSettings::writeSizes(const QString& key, const QList& value) return true; } +QIcon ConfigItem::symbolYesIcon; +QIcon ConfigItem::symbolModIcon; +QIcon ConfigItem::symbolNoIcon; +QIcon ConfigItem::choiceYesIcon; +QIcon ConfigItem::choiceNoIcon; +QIcon ConfigItem::menuIcon; +QIcon ConfigItem::menubackIcon; /* * set the new data @@ -111,14 +104,14 @@ void ConfigItem::updateMenu(void) list = listView(); if (goParent) { - setPixmap(promptColIdx, list->menuBackPix); + setIcon(promptColIdx, menubackIcon); prompt = ".."; goto set_prompt; } sym = menu->sym; prop = menu->prompt; - prompt = qgettext(menu_get_prompt(menu)); + prompt = menu_get_prompt(menu); if (prop) switch (prop->type) { case P_MENU: @@ -128,15 +121,15 @@ void ConfigItem::updateMenu(void) */ if (sym && list->rootEntry == menu) break; - setPixmap(promptColIdx, list->menuPix); + setIcon(promptColIdx, menuIcon); } else { if (sym) break; - setPixmap(promptColIdx, QIcon()); + setIcon(promptColIdx, QIcon()); } goto set_prompt; case P_COMMENT: - setPixmap(promptColIdx, QIcon()); + setIcon(promptColIdx, QIcon()); goto set_prompt; default: ; @@ -144,7 +137,7 @@ void ConfigItem::updateMenu(void) if (!sym) goto set_prompt; - setText(nameColIdx, QString::fromLocal8Bit(sym->name)); + setText(nameColIdx, sym->name); type = sym_get_type(sym); switch (type) { @@ -153,7 +146,7 @@ void ConfigItem::updateMenu(void) char ch; if (!sym_is_changeable(sym) && list->optMode == normalOpt) { - setPixmap(promptColIdx, QIcon()); + setIcon(promptColIdx, QIcon()); setText(noColIdx, QString()); setText(modColIdx, QString()); setText(yesColIdx, QString()); @@ -163,22 +156,22 @@ void ConfigItem::updateMenu(void) switch (expr) { case yes: if (sym_is_choice_value(sym) && type == S_BOOLEAN) - setPixmap(promptColIdx, list->choiceYesPix); + setIcon(promptColIdx, choiceYesIcon); else - setPixmap(promptColIdx, list->symbolYesPix); + setIcon(promptColIdx, symbolYesIcon); setText(yesColIdx, "Y"); ch = 'Y'; break; case mod: - setPixmap(promptColIdx, list->symbolModPix); + setIcon(promptColIdx, symbolModIcon); setText(modColIdx, "M"); ch = 'M'; break; default: if (sym_is_choice_value(sym) && type == S_BOOLEAN) - setPixmap(promptColIdx, list->choiceNoPix); + setIcon(promptColIdx, choiceNoIcon); else - setPixmap(promptColIdx, list->symbolNoPix); + setIcon(promptColIdx, symbolNoIcon); setText(noColIdx, "N"); ch = 'N'; break; @@ -274,7 +267,7 @@ void ConfigLineEdit::show(ConfigItem* i) { item = i; if (sym_get_string_value(item->menu->sym)) - setText(QString::fromLocal8Bit(sym_get_string_value(item->menu->sym))); + setText(sym_get_string_value(item->menu->sym)); else setText(QString()); Parent::show(); @@ -289,7 +282,7 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e) case Qt::Key_Return: case Qt::Key_Enter: sym_set_string_value(item->menu->sym, text().toLatin1()); - parent()->updateList(item); + parent()->updateList(); break; default: Parent::keyPressEvent(e); @@ -303,9 +296,6 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e) ConfigList::ConfigList(ConfigView* p, const char *name) : Parent(p), updateAll(false), - symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), - choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), - menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void), showName(false), showRange(false), showData(false), mode(singleMode), optMode(normalOpt), rootEntry(0), headerPopup(0) { @@ -316,10 +306,7 @@ ConfigList::ConfigList(ConfigView* p, const char *name) setVerticalScrollMode(ScrollPerPixel); setHorizontalScrollMode(ScrollPerPixel); - if (mode == symbolMode) - setHeaderLabels(QStringList() << "Item" << "Name" << "N" << "M" << "Y" << "Value"); - else - setHeaderLabels(QStringList() << "Option" << "Name" << "N" << "M" << "Y" << "Value"); + setHeaderLabels(QStringList() << "Option" << "Name" << "N" << "M" << "Y" << "Value"); connect(this, SIGNAL(itemSelectionChanged(void)), SLOT(updateSelection(void))); @@ -334,7 +321,7 @@ ConfigList::ConfigList(ConfigView* p, const char *name) connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); } - addColumn(promptColIdx); + showColumn(promptColIdx); reinit(); } @@ -352,21 +339,33 @@ bool ConfigList::menuSkip(struct menu *menu) void ConfigList::reinit(void) { - removeColumn(dataColIdx); - removeColumn(yesColIdx); - removeColumn(modColIdx); - removeColumn(noColIdx); - removeColumn(nameColIdx); + hideColumn(dataColIdx); + hideColumn(yesColIdx); + hideColumn(modColIdx); + hideColumn(noColIdx); + hideColumn(nameColIdx); if (showName) - addColumn(nameColIdx); + showColumn(nameColIdx); if (showRange) { - addColumn(noColIdx); - addColumn(modColIdx); - addColumn(yesColIdx); + showColumn(noColIdx); + showColumn(modColIdx); + showColumn(yesColIdx); } if (showData) - addColumn(dataColIdx); + showColumn(dataColIdx); + + updateListAll(); +} + +void ConfigList::setOptionMode(QAction *action) +{ + if (action == showNormalAction) + optMode = normalOpt; + else if (action == showAllAction) + optMode = allOpt; + else + optMode = promptOpt; updateListAll(); } @@ -400,11 +399,6 @@ void ConfigList::updateSelection(void) struct menu *menu; enum prop_type type; - if (mode == symbolMode) - setHeaderLabels(QStringList() << "Item" << "Name" << "N" << "M" << "Y" << "Value"); - else - setHeaderLabels(QStringList() << "Option" << "Name" << "N" << "M" << "Y" << "Value"); - if (selectedItems().count() == 0) return; @@ -421,15 +415,15 @@ void ConfigList::updateSelection(void) emit menuSelected(menu); } -void ConfigList::updateList(ConfigItem* item) +void ConfigList::updateList() { ConfigItem* last = 0; + ConfigItem *item; if (!rootEntry) { if (mode != listMode) goto update; QTreeWidgetItemIterator it(this); - ConfigItem* item; while (*it) { item = (ConfigItem*)(*it); @@ -451,7 +445,7 @@ void ConfigList::updateList(ConfigItem* item) } if ((mode == singleMode || (mode == symbolMode && !(rootEntry->flags & MENU_ROOT))) && rootEntry->sym && rootEntry->prompt) { - item = last ? last->nextSibling() : firstChild(); + item = last ? last->nextSibling() : nullptr; if (!item) item = new ConfigItem(this, last, rootEntry, true); else @@ -463,7 +457,7 @@ void ConfigList::updateList(ConfigItem* item) return; } update: - updateMenuList(this, rootEntry); + updateMenuList(rootEntry); update(); resizeColumnToContents(0); } @@ -488,7 +482,7 @@ void ConfigList::setValue(ConfigItem* item, tristate val) return; if (oldval == no && item->menu->list) item->setExpanded(true); - parent()->updateList(item); + parent()->updateList(); break; } } @@ -522,7 +516,7 @@ void ConfigList::changeValue(ConfigItem* item) item->setExpanded(true); } if (oldexpr != newexpr) - parent()->updateList(item); + parent()->updateList(); break; case S_INT: case S_HEX: @@ -541,11 +535,11 @@ void ConfigList::setRootMenu(struct menu *menu) type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN; if (type != P_MENU) return; - updateMenuList(this, 0); + updateMenuList(0); rootEntry = menu; updateListAll(); if (currentItem()) { - currentItem()->setSelected(hasFocus()); + setSelected(currentItem(), hasFocus()); scrollToItem(currentItem()); } } @@ -645,7 +639,7 @@ hide: } } -void ConfigList::updateMenuList(ConfigList *parent, struct menu* menu) +void ConfigList::updateMenuList(struct menu *menu) { struct menu* child; ConfigItem* item; @@ -654,19 +648,19 @@ void ConfigList::updateMenuList(ConfigList *parent, struct menu* menu) enum prop_type type; if (!menu) { - while (parent->topLevelItemCount() > 0) + while (topLevelItemCount() > 0) { - delete parent->takeTopLevelItem(0); + delete takeTopLevelItem(0); } return; } - last = (ConfigItem*)parent->topLevelItem(0); + last = (ConfigItem *)topLevelItem(0); if (last && !last->goParent) last = 0; for (child = menu->list; child; child = child->next) { - item = last ? last->nextSibling() : (ConfigItem*)parent->topLevelItem(0); + item = last ? last->nextSibling() : (ConfigItem *)topLevelItem(0); type = child->prompt ? child->prompt->type : P_UNKNOWN; switch (mode) { @@ -687,7 +681,7 @@ void ConfigList::updateMenuList(ConfigList *parent, struct menu* menu) if (!child->sym && !child->list && !child->prompt) continue; if (!item || item->menu != child) - item = new ConfigItem(parent, last, child, visible); + item = new ConfigItem(this, last, child, visible); else item->testUpdateMenu(visible); @@ -700,7 +694,7 @@ void ConfigList::updateMenuList(ConfigList *parent, struct menu* menu) } hide: if (item && item->menu == child) { - last = (ConfigItem*)parent->topLevelItem(0); + last = (ConfigItem *)topLevelItem(0); if (last == item) last = 0; else while (last->nextSibling() != item) @@ -791,7 +785,7 @@ void ConfigList::mouseReleaseEvent(QMouseEvent* e) idx = header()->logicalIndexAt(x); switch (idx) { case promptColIdx: - icon = item->pixmap(promptColIdx); + icon = item->icon(promptColIdx); if (!icon.isNull()) { int off = header()->sectionPosition(0) + visualRect(indexAt(p)).x() + 4; // 4 is Hardcoded image offset. There might be a way to do it properly. if (x >= off && x < off + icon.availableSizes().first().width()) { @@ -802,7 +796,8 @@ void ConfigList::mouseReleaseEvent(QMouseEvent* e) break; ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; if (ptype == P_MENU && rootEntry != menu && - mode != fullMode && mode != menuMode) + mode != fullMode && mode != menuMode && + mode != listMode) emit menuSelected(menu); else changeValue(item); @@ -852,7 +847,7 @@ void ConfigList::mouseDoubleClickEvent(QMouseEvent* e) if (!menu) goto skip; ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; - if (ptype == P_MENU) { + if (ptype == P_MENU && mode != listMode) { if (mode == singleMode) emit itemSelected(menu); else if (mode == symbolMode) @@ -873,7 +868,7 @@ void ConfigList::focusInEvent(QFocusEvent *e) ConfigItem* item = (ConfigItem *)currentItem(); if (item) { - item->setSelected(true); + setSelected(item, true); menu = item->menu; } emit gotFocus(menu); @@ -881,46 +876,46 @@ void ConfigList::focusInEvent(QFocusEvent *e) void ConfigList::contextMenuEvent(QContextMenuEvent *e) { - if (e->y() <= header()->geometry().bottom()) { - if (!headerPopup) { - QAction *action; - - headerPopup = new QMenu(this); - action = new QAction("Show Name", this); - action->setCheckable(true); - connect(action, SIGNAL(toggled(bool)), - parent(), SLOT(setShowName(bool))); - connect(parent(), SIGNAL(showNameChanged(bool)), - action, SLOT(setOn(bool))); - action->setChecked(showName); - headerPopup->addAction(action); - action = new QAction("Show Range", this); - action->setCheckable(true); - connect(action, SIGNAL(toggled(bool)), - parent(), SLOT(setShowRange(bool))); - connect(parent(), SIGNAL(showRangeChanged(bool)), - action, SLOT(setOn(bool))); - action->setChecked(showRange); - headerPopup->addAction(action); - action = new QAction("Show Data", this); - action->setCheckable(true); - connect(action, SIGNAL(toggled(bool)), - parent(), SLOT(setShowData(bool))); - connect(parent(), SIGNAL(showDataChanged(bool)), - action, SLOT(setOn(bool))); - action->setChecked(showData); - headerPopup->addAction(action); - } - headerPopup->exec(e->globalPos()); - e->accept(); - } else - e->ignore(); + if (!headerPopup) { + QAction *action; + + headerPopup = new QMenu(this); + action = new QAction("Show Name", this); + action->setCheckable(true); + connect(action, SIGNAL(toggled(bool)), + parent(), SLOT(setShowName(bool))); + connect(parent(), SIGNAL(showNameChanged(bool)), + action, SLOT(setChecked(bool))); + action->setChecked(showName); + headerPopup->addAction(action); + + action = new QAction("Show Range", this); + action->setCheckable(true); + connect(action, SIGNAL(toggled(bool)), + parent(), SLOT(setShowRange(bool))); + connect(parent(), SIGNAL(showRangeChanged(bool)), + action, SLOT(setChecked(bool))); + action->setChecked(showRange); + headerPopup->addAction(action); + + action = new QAction("Show Data", this); + action->setCheckable(true); + connect(action, SIGNAL(toggled(bool)), + parent(), SLOT(setShowData(bool))); + connect(parent(), SIGNAL(showDataChanged(bool)), + action, SLOT(setChecked(bool))); + action->setChecked(showData); + headerPopup->addAction(action); + } + + headerPopup->exec(e->globalPos()); + e->accept(); } ConfigView*ConfigView::viewList; -QAction *ConfigView::showNormalAction; -QAction *ConfigView::showAllAction; -QAction *ConfigView::showPromptAction; +QAction *ConfigList::showNormalAction; +QAction *ConfigList::showAllAction; +QAction *ConfigList::showPromptAction; ConfigView::ConfigView(QWidget* parent, const char *name) : Parent(parent) @@ -951,18 +946,6 @@ ConfigView::~ConfigView(void) } } -void ConfigView::setOptionMode(QAction *act) -{ - if (act == showNormalAction) - list->optMode = normalOpt; - else if (act == showAllAction) - list->optMode = allOpt; - else - list->optMode = promptOpt; - - list->updateListAll(); -} - void ConfigView::setShowName(bool b) { if (list->showName != b) { @@ -1001,12 +984,12 @@ void ConfigList::setAllOpen(bool open) } } -void ConfigView::updateList(ConfigItem* item) +void ConfigView::updateList() { ConfigView* v; for (v = viewList; v; v = v->nextView) - v->list->updateList(item); + v->list->updateList(); } void ConfigView::updateListAll(void) @@ -1021,7 +1004,7 @@ ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name) : Parent(parent), sym(0), _menu(0) { setObjectName(name); - + setOpenLinks(false); if (!objectName().isEmpty()) { configSettings->beginGroup(objectName()); @@ -1029,6 +1012,16 @@ ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name) configSettings->endGroup(); connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); } + + contextMenu = createStandardContextMenu(); + QAction *action = new QAction("Show Debug Info", contextMenu); + + action->setCheckable(true); + connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); + connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setChecked(bool))); + action->setChecked(showDebug()); + contextMenu->addSeparator(); + contextMenu->addAction(action); } void ConfigInfoView::saveSettings(void) @@ -1083,108 +1076,114 @@ void ConfigInfoView::symbolInfo(void) void ConfigInfoView::menuInfo(void) { struct symbol* sym; - QString head, debug, help; + QString info; + QTextStream stream(&info); sym = _menu->sym; if (sym) { if (_menu->prompt) { - head += ""; - head += print_filter(_menu->prompt->text); - head += ""; + stream << ""; + stream << print_filter(_menu->prompt->text); + stream << ""; if (sym->name) { - head += " ("; + stream << " ("; if (showDebug()) - head += QString().sprintf("", sym); - head += print_filter(sym->name); + stream << "name << "\">"; + stream << print_filter(sym->name); if (showDebug()) - head += ""; - head += ")"; + stream << ""; + stream << ")"; } } else if (sym->name) { - head += ""; + stream << ""; if (showDebug()) - head += QString().sprintf("", sym); - head += print_filter(sym->name); + stream << "name << "\">"; + stream << print_filter(sym->name); if (showDebug()) - head += ""; - head += ""; + stream << ""; + stream << ""; } - head += "

"; + stream << "

"; if (showDebug()) - debug = debug_info(sym); + stream << debug_info(sym); - struct gstr help_gstr = str_new(); - menu_get_ext_help(_menu, &help_gstr); - help = print_filter(str_get(&help_gstr)); - str_free(&help_gstr); } else if (_menu->prompt) { - head += ""; - head += print_filter(_menu->prompt->text); - head += "

"; + stream << ""; + stream << print_filter(_menu->prompt->text); + stream << "

"; if (showDebug()) { if (_menu->prompt->visible.expr) { - debug += "  dep: "; - expr_print(_menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); - debug += "

"; + stream << "  dep: "; + expr_print(_menu->prompt->visible.expr, + expr_print_help, &stream, E_NONE); + stream << "

"; } } } if (showDebug()) - debug += QString().sprintf("defined at %s:%d

", _menu->file->name, _menu->lineno); + stream << "defined at " << _menu->file->name << ":" + << _menu->lineno << "

"; - setText(head + debug + help); + setText(info); } QString ConfigInfoView::debug_info(struct symbol *sym) { QString debug; + QTextStream stream(&debug); - debug += "type: "; - debug += print_filter(sym_type_name(sym->type)); + stream << "type: "; + stream << print_filter(sym_type_name(sym->type)); if (sym_is_choice(sym)) - debug += " (choice)"; + stream << " (choice)"; debug += "
"; if (sym->rev_dep.expr) { - debug += "reverse dep: "; - expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE); - debug += "
"; + stream << "reverse dep: "; + expr_print(sym->rev_dep.expr, expr_print_help, &stream, E_NONE); + stream << "
"; } for (struct property *prop = sym->prop; prop; prop = prop->next) { switch (prop->type) { case P_PROMPT: case P_MENU: - debug += QString().sprintf("prompt: ", prop->menu); - debug += print_filter(prop->text); - debug += "
"; + stream << "prompt: name << "\">"; + stream << print_filter(prop->text); + stream << "
"; break; case P_DEFAULT: case P_SELECT: case P_RANGE: - debug += prop_get_type_name(prop->type); - debug += ": "; - expr_print(prop->expr, expr_print_help, &debug, E_NONE); - debug += "
"; + case P_COMMENT: + case P_IMPLY: + case P_SYMBOL: + stream << prop_get_type_name(prop->type); + stream << ": "; + expr_print(prop->expr, expr_print_help, + &stream, E_NONE); + stream << "
"; break; case P_CHOICE: if (sym_is_choice(sym)) { - debug += "choice: "; - expr_print(prop->expr, expr_print_help, &debug, E_NONE); - debug += "
"; + stream << "choice: "; + expr_print(prop->expr, expr_print_help, + &stream, E_NONE); + stream << "
"; } break; default: - debug += "unknown property: "; - debug += prop_get_type_name(prop->type); - debug += "
"; + stream << "unknown property: "; + stream << prop_get_type_name(prop->type); + stream << "
"; } if (prop->visible.expr) { - debug += "    dep: "; - expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE); - debug += "
"; + stream << "    dep: "; + expr_print(prop->visible.expr, expr_print_help, + &stream, E_NONE); + stream << "
"; } } - debug += "
"; + stream << "
"; return debug; } @@ -1222,46 +1221,81 @@ QString ConfigInfoView::print_filter(const QString &str) void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char *str) { - QString* text = reinterpret_cast(data); - QString str2 = print_filter(str); + QTextStream *stream = reinterpret_cast(data); if (sym && sym->name && !(sym->flags & SYMBOL_CONST)) { - *text += QString().sprintf("", sym); - *text += str2; - *text += ""; - } else - *text += str2; + *stream << "name << "\">"; + *stream << print_filter(str); + *stream << ""; + } else { + *stream << print_filter(str); + } } -QMenu* ConfigInfoView::createStandardContextMenu(const QPoint & pos) +void ConfigInfoView::clicked(const QUrl &url) { - QMenu* popup = Parent::createStandardContextMenu(pos); - QAction* action = new QAction("Show Debug Info", popup); + QByteArray str = url.toEncoded(); + const std::size_t count = str.size(); + char *data = new char[count + 1]; + struct symbol **result; + struct menu *m = NULL; - action->setCheckable(true); - connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); - connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool))); - action->setChecked(showDebug()); - popup->addSeparator(); - popup->addAction(action); - return popup; + if (count < 1) { + delete[] data; + return; + } + + memcpy(data, str.constData(), count); + data[count] = '\0'; + + /* Seek for exact match */ + data[0] = '^'; + strcat(data, "$"); + result = sym_re_search(data); + if (!result) { + delete[] data; + return; + } + + sym = *result; + + /* Seek for the menu which holds the symbol */ + for (struct property *prop = sym->prop; prop; prop = prop->next) { + if (prop->type != P_PROMPT && prop->type != P_MENU) + continue; + m = prop->menu; + break; + } + + if (!m) { + /* Symbol is not visible as a menu */ + symbolInfo(); + emit showDebugChanged(true); + } else { + emit menuSelected(m); + } + + free(result); + delete data; } -void ConfigInfoView::contextMenuEvent(QContextMenuEvent *e) +void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event) { - Parent::contextMenuEvent(e); + contextMenu->popup(event->globalPos()); + event->accept(); } -ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *name) +ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow *parent) : Parent(parent), result(NULL) { - setObjectName(name); + setObjectName("search"); setWindowTitle("Search Config"); QVBoxLayout* layout1 = new QVBoxLayout(this); layout1->setContentsMargins(11, 11, 11, 11); layout1->setSpacing(6); - QHBoxLayout* layout2 = new QHBoxLayout(0); + + QHBoxLayout* layout2 = new QHBoxLayout(); layout2->setContentsMargins(0, 0, 0, 0); layout2->setSpacing(6); layout2->addWidget(new QLabel("Find:", this)); @@ -1276,9 +1310,9 @@ ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *nam split = new QSplitter(this); split->setOrientation(Qt::Vertical); - list = new ConfigView(split, name); + list = new ConfigView(split, "search"); list->list->mode = listMode; - info = new ConfigInfoView(split, name); + info = new ConfigInfoView(split, "search"); connect(list->list, SIGNAL(menuChanged(struct menu *)), info, SLOT(setInfo(struct menu *))); connect(list->list, SIGNAL(menuChanged(struct menu *)), @@ -1286,25 +1320,23 @@ ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *nam layout1->addWidget(split); - if (name) { - QVariant x, y; - int width, height; - bool ok; + QVariant x, y; + int width, height; + bool ok; - configSettings->beginGroup(name); - width = configSettings->value("/window width", parent->width() / 2).toInt(); - height = configSettings->value("/window height", parent->height() / 2).toInt(); - resize(width, height); - x = configSettings->value("/window x"); - y = configSettings->value("/window y"); - if ((x.isValid())&&(y.isValid())) - move(x.toInt(), y.toInt()); - QList sizes = configSettings->readSizes("/split", &ok); - if (ok) - split->setSizes(sizes); - configSettings->endGroup(); - connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); - } + configSettings->beginGroup("search"); + width = configSettings->value("/window width", parent->width() / 2).toInt(); + height = configSettings->value("/window height", parent->height() / 2).toInt(); + resize(width, height); + x = configSettings->value("/window x"); + y = configSettings->value("/window y"); + if (x.isValid() && y.isValid()) + move(x.toInt(), y.toInt()); + QList sizes = configSettings->readSizes("/split", &ok); + if (ok) + split->setSizes(sizes); + configSettings->endGroup(); + connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); } void ConfigSearchWindow::saveSettings(void) @@ -1346,7 +1378,6 @@ void ConfigSearchWindow::search(void) ConfigMainWindow::ConfigMainWindow(void) : searchWindow(0) { - QMenuBar* menu; bool ok = true; QVariant x, y; int width, height; @@ -1367,6 +1398,15 @@ ConfigMainWindow::ConfigMainWindow(void) if ((x.isValid())&&(y.isValid())) move(x.toInt(), y.toInt()); + // set up icons + ConfigItem::symbolYesIcon = QIcon(QPixmap(xpm_symbol_yes)); + ConfigItem::symbolModIcon = QIcon(QPixmap(xpm_symbol_mod)); + ConfigItem::symbolNoIcon = QIcon(QPixmap(xpm_symbol_no)); + ConfigItem::choiceYesIcon = QIcon(QPixmap(xpm_choice_yes)); + ConfigItem::choiceNoIcon = QIcon(QPixmap(xpm_choice_no)); + ConfigItem::menuIcon = QIcon(QPixmap(xpm_menu)); + ConfigItem::menubackIcon = QIcon(QPixmap(xpm_menuback)); + QWidget *widget = new QWidget(this); QVBoxLayout *layout = new QVBoxLayout(widget); setCentralWidget(widget); @@ -1397,23 +1437,23 @@ ConfigMainWindow::ConfigMainWindow(void) setTabOrder(configList, helpText); configList->setFocus(); - menu = menuBar(); - toolBar = new QToolBar("Tools", this); - addToolBar(toolBar); - backAction = new QAction(QPixmap(xpm_back), "Back", this); - connect(backAction, SIGNAL(triggered(bool)), SLOT(goBack())); - backAction->setEnabled(false); + connect(backAction, SIGNAL(triggered(bool)), SLOT(goBack())); + QAction *quitAction = new QAction("&Quit", this); quitAction->setShortcut(Qt::CTRL + Qt::Key_Q); - connect(quitAction, SIGNAL(triggered(bool)), SLOT(close())); + connect(quitAction, SIGNAL(triggered(bool)), SLOT(close())); + QAction *loadAction = new QAction(QPixmap(xpm_load), "&Load", this); loadAction->setShortcut(Qt::CTRL + Qt::Key_L); - connect(loadAction, SIGNAL(triggered(bool)), SLOT(loadConfig())); + connect(loadAction, SIGNAL(triggered(bool)), SLOT(loadConfig())); + saveAction = new QAction(QPixmap(xpm_save), "&Save", this); saveAction->setShortcut(Qt::CTRL + Qt::Key_S); - connect(saveAction, SIGNAL(triggered(bool)), SLOT(saveConfig())); + connect(saveAction, SIGNAL(triggered(bool)), SLOT(saveConfig())); + conf_set_changed_callback(conf_changed); + // Set saveAction's initial state conf_changed(); configname = xstrdup(conf_get_configname()); @@ -1446,17 +1486,17 @@ ConfigMainWindow::ConfigMainWindow(void) QActionGroup *optGroup = new QActionGroup(this); optGroup->setExclusive(true); - connect(optGroup, SIGNAL(triggered(QAction*)), configView, + connect(optGroup, SIGNAL(triggered(QAction*)), configList, SLOT(setOptionMode(QAction *))); - connect(optGroup, SIGNAL(triggered(QAction *)), menuView, + connect(optGroup, SIGNAL(triggered(QAction *)), menuList, SLOT(setOptionMode(QAction *))); - configView->showNormalAction = new QAction("Show Normal Options", optGroup); - configView->showAllAction = new QAction("Show All Options", optGroup); - configView->showPromptAction = new QAction("Show Prompt Options", optGroup); - configView->showNormalAction->setCheckable(true); - configView->showAllAction->setCheckable(true); - configView->showPromptAction->setCheckable(true); + ConfigList::showNormalAction = new QAction("Show Normal Options", optGroup); + ConfigList::showNormalAction->setCheckable(true); + ConfigList::showAllAction = new QAction("Show All Options", optGroup); + ConfigList::showAllAction->setCheckable(true); + ConfigList::showPromptAction = new QAction("Show Prompt Options", optGroup); + ConfigList::showPromptAction->setCheckable(true); QAction *showDebugAction = new QAction("Show Debug Info", this); showDebugAction->setCheckable(true); @@ -1469,6 +1509,7 @@ ConfigMainWindow::ConfigMainWindow(void) connect(showAboutAction, SIGNAL(triggered(bool)), SLOT(showAbout())); // init tool bar + QToolBar *toolBar = addToolBar("Tools"); toolBar->addAction(backAction); toolBar->addSeparator(); toolBar->addAction(loadAction); @@ -1478,33 +1519,35 @@ ConfigMainWindow::ConfigMainWindow(void) toolBar->addAction(splitViewAction); toolBar->addAction(fullViewAction); - // create config menu - QMenu* config = menu->addMenu("&File"); - config->addAction(loadAction); - config->addAction(saveAction); - config->addAction(saveAsAction); - config->addSeparator(); - config->addAction(quitAction); + // create file menu + QMenu *menu = menuBar()->addMenu("&File"); + menu->addAction(loadAction); + menu->addAction(saveAction); + menu->addAction(saveAsAction); + menu->addSeparator(); + menu->addAction(quitAction); // create edit menu - QMenu* editMenu = menu->addMenu("&Edit"); - editMenu->addAction(searchAction); + menu = menuBar()->addMenu("&Edit"); + menu->addAction(searchAction); // create options menu - QMenu* optionMenu = menu->addMenu("&Option"); - optionMenu->addAction(showNameAction); - optionMenu->addAction(showRangeAction); - optionMenu->addAction(showDataAction); - optionMenu->addSeparator(); - optionMenu->addActions(optGroup->actions()); - optionMenu->addSeparator(); - optionMenu->addAction(showDebugAction); + menu = menuBar()->addMenu("&Option"); + menu->addAction(showNameAction); + menu->addAction(showRangeAction); + menu->addAction(showDataAction); + menu->addSeparator(); + menu->addActions(optGroup->actions()); + menu->addSeparator(); + menu->addAction(showDebugAction); // create help menu - menu->addSeparator(); - QMenu* helpMenu = menu->addMenu("&Help"); - helpMenu->addAction(showIntroAction); - helpMenu->addAction(showAboutAction); + menu = menuBar()->addMenu("&Help"); + menu->addAction(showIntroAction); + menu->addAction(showAboutAction); + + connect (helpText, SIGNAL (anchorClicked (const QUrl &)), + helpText, SLOT (clicked (const QUrl &)) ); connect(configList, SIGNAL(menuChanged(struct menu *)), helpText, SLOT(setInfo(struct menu *))); @@ -1604,28 +1647,18 @@ void ConfigMainWindow::saveConfigAs(void) void ConfigMainWindow::searchConfig(void) { if (!searchWindow) - searchWindow = new ConfigSearchWindow(this, "search"); + searchWindow = new ConfigSearchWindow(this); searchWindow->show(); } void ConfigMainWindow::changeItens(struct menu *menu) { configList->setRootMenu(menu); - - if (configList->rootEntry->parent == &rootmenu) - backAction->setEnabled(false); - else - backAction->setEnabled(true); } void ConfigMainWindow::changeMenu(struct menu *menu) { menuList->setRootMenu(menu); - - if (menuList->rootEntry->parent == &rootmenu) - backAction->setEnabled(false); - else - backAction->setEnabled(true); } void ConfigMainWindow::setMenuLink(struct menu *menu) @@ -1645,22 +1678,26 @@ void ConfigMainWindow::setMenuLink(struct menu *menu) return; list->setRootMenu(parent); break; - case symbolMode: + case menuMode: if (menu->flags & MENU_ROOT) { - configList->setRootMenu(menu); + menuList->setRootMenu(menu); configList->clearSelection(); - list = menuList; - } else { list = configList; + } else { parent = menu_get_parent_menu(menu->parent); if (!parent) return; - item = menuList->findConfigItem(parent); + + /* Select the config view */ + item = configList->findConfigItem(parent); if (item) { - item->setSelected(true); - menuList->scrollToItem(item); + configList->setSelected(item, true); + configList->scrollToItem(item); } - list->setRootMenu(parent); + + menuList->setRootMenu(parent); + menuList->clearSelection(); + list = menuList; } break; case fullMode: @@ -1673,9 +1710,10 @@ void ConfigMainWindow::setMenuLink(struct menu *menu) if (list) { item = list->findConfigItem(menu); if (item) { - item->setSelected(true); + list->setSelected(item, true); list->scrollToItem(item); list->setFocus(); + helpText->setInfo(menu); } } } @@ -1688,25 +1726,10 @@ void ConfigMainWindow::listFocusChanged(void) void ConfigMainWindow::goBack(void) { - ConfigItem* item, *oldSelection; - - configList->setParentMenu(); if (configList->rootEntry == &rootmenu) - backAction->setEnabled(false); - - if (menuList->selectedItems().count() == 0) return; - item = (ConfigItem*)menuList->selectedItems().first(); - oldSelection = item; - while (item) { - if (item->menu == configList->rootEntry) { - oldSelection->setSelected(false); - item->setSelected(true); - break; - } - item = (ConfigItem*)item->parent(); - } + configList->setParentMenu(); } void ConfigMainWindow::showSingleView(void) @@ -1718,6 +1741,8 @@ void ConfigMainWindow::showSingleView(void) fullViewAction->setEnabled(true); fullViewAction->setChecked(false); + backAction->setEnabled(true); + menuView->hide(); menuList->setRootMenu(0); configList->mode = singleMode; @@ -1737,6 +1762,8 @@ void ConfigMainWindow::showSplitView(void) fullViewAction->setEnabled(true); fullViewAction->setChecked(false); + backAction->setEnabled(false); + configList->mode = menuMode; if (configList->rootEntry == &rootmenu) configList->updateListAll(); @@ -1760,6 +1787,8 @@ void ConfigMainWindow::showFullView(void) fullViewAction->setEnabled(false); fullViewAction->setChecked(true); + backAction->setEnabled(false); + menuView->hide(); menuList->setRootMenu(0); configList->mode = fullMode; diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index c879d79ce8..f97376a812 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h @@ -3,17 +3,17 @@ * Copyright (C) 2002 Roman Zippel */ -#include -#include -#include +#include +#include #include -#include +#include +#include #include #include -#include #include -#include -#include +#include +#include + #include "expr.h" class ConfigView; @@ -30,7 +30,7 @@ public: }; enum colIdx { - promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr + promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx }; enum listMode { singleMode, menuMode, symbolMode, fullMode, listMode @@ -45,11 +45,17 @@ class ConfigList : public QTreeWidget { public: ConfigList(ConfigView* p, const char *name = 0); void reinit(void); + ConfigItem* findConfigItem(struct menu *); ConfigView* parent(void) const { return (ConfigView*)Parent::parent(); } - ConfigItem* findConfigItem(struct menu *); + void setSelected(QTreeWidgetItem *item, bool enable) { + for (int i = 0; i < selectedItems().size(); i++) + selectedItems().at(i)->setSelected(false); + + item->setSelected(enable); + } protected: void keyPressEvent(QKeyEvent *e); @@ -63,11 +69,13 @@ protected: public slots: void setRootMenu(struct menu *menu); - void updateList(ConfigItem *item); + void updateList(); void setValue(ConfigItem* item, tristate val); void changeValue(ConfigItem* item); void updateSelection(void); void saveSettings(void); + void setOptionMode(QAction *action); + signals: void menuChanged(struct menu *menu); void menuSelected(struct menu *menu); @@ -79,39 +87,19 @@ public: void updateListAll(void) { updateAll = true; - updateList(NULL); + updateList(); updateAll = false; } - ConfigList* listView() - { - return this; - } - ConfigItem* firstChild() const - { - return (ConfigItem *)children().first(); - } - void addColumn(colIdx idx) - { - showColumn(idx); - } - void removeColumn(colIdx idx) - { - hideColumn(idx); - } void setAllOpen(bool open); void setParentMenu(void); bool menuSkip(struct menu *); void updateMenuList(ConfigItem *parent, struct menu*); - void updateMenuList(ConfigList *parent, struct menu*); + void updateMenuList(struct menu *menu); bool updateAll; - QPixmap symbolYesPix, symbolModPix, symbolNoPix; - QPixmap choiceYesPix, choiceNoPix; - QPixmap menuPix, menuInvPix, menuBackPix, voidPix; - bool showName, showRange, showData; enum listMode mode; enum optionMode optMode; @@ -119,6 +107,8 @@ public: QPalette disabledColorGroup; QPalette inactivedColorGroup; QMenu* headerPopup; + + static QAction *showNormalAction, *showAllAction, *showPromptAction; }; class ConfigItem : public QTreeWidgetItem { @@ -166,28 +156,16 @@ public: return ret; } - void setText(colIdx idx, const QString& text) - { - Parent::setText(idx, text); - } - QString text(colIdx idx) const - { - return Parent::text(idx); - } - void setPixmap(colIdx idx, const QIcon &icon) - { - Parent::setIcon(idx, icon); - } - const QIcon pixmap(colIdx idx) const - { - return icon(idx); - } // TODO: Implement paintCell ConfigItem* nextItem; struct menu *menu; bool visible; bool goParent; + + static QIcon symbolYesIcon, symbolModIcon, symbolNoIcon; + static QIcon choiceYesIcon, choiceNoIcon; + static QIcon menuIcon, menubackIcon; }; class ConfigLineEdit : public QLineEdit { @@ -212,7 +190,7 @@ class ConfigView : public QWidget { public: ConfigView(QWidget* parent, const char *name = 0); ~ConfigView(void); - static void updateList(ConfigItem* item); + static void updateList(); static void updateListAll(void); bool showName(void) const { return list->showName; } @@ -222,7 +200,6 @@ public slots: void setShowName(bool); void setShowRange(bool); void setShowData(bool); - void setOptionMode(QAction *); signals: void showNameChanged(bool); void showRangeChanged(bool); @@ -233,15 +210,12 @@ public: static ConfigView* viewList; ConfigView* nextView; - - static QAction *showNormalAction; - static QAction *showAllAction; - static QAction *showPromptAction; }; class ConfigInfoView : public QTextBrowser { Q_OBJECT typedef class QTextBrowser Parent; + QMenu *contextMenu; public: ConfigInfoView(QWidget* parent, const char *name = 0); bool showDebug(void) const { return _showDebug; } @@ -250,6 +224,7 @@ public slots: void setInfo(struct menu *menu); void saveSettings(void); void setShowDebug(bool); + void clicked (const QUrl &url); signals: void showDebugChanged(bool); @@ -261,8 +236,7 @@ protected: QString debug_info(struct symbol *sym); static QString print_filter(const QString &str); static void expr_print_help(void *data, struct symbol *sym, const char *str); - QMenu *createStandardContextMenu(const QPoint & pos); - void contextMenuEvent(QContextMenuEvent *e); + void contextMenuEvent(QContextMenuEvent *event); struct symbol *sym; struct menu *_menu; @@ -273,7 +247,7 @@ class ConfigSearchWindow : public QDialog { Q_OBJECT typedef class QDialog Parent; public: - ConfigSearchWindow(ConfigMainWindow* parent, const char *name = 0); + ConfigSearchWindow(ConfigMainWindow *parent); public slots: void saveSettings(void); @@ -323,7 +297,6 @@ protected: ConfigView *configView; ConfigList *configList; ConfigInfoView *helpText; - QToolBar *toolBar; QAction *backAction; QAction *singleViewAction; QAction *splitViewAction; diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index e2f8504f5a..19857d18d8 100755 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl @@ -143,6 +143,7 @@ my %depends; my %selects; my %prompts; my %objects; +my %config2kfile; my $var; my $iflevel = 0; my @ifdeps; @@ -201,6 +202,7 @@ sub read_kconfig { if (/^\s*(menu)?config\s+(\S+)\s*$/) { $state = "NEW"; $config = $2; + $config2kfile{"CONFIG_$config"} = $kconfig; # Add depends for 'if' nesting for (my $i = 0; $i < $iflevel; $i++) { @@ -591,6 +593,20 @@ while ($repeat) { } my %setconfigs; +my @preserved_kconfigs = split(/:/,$ENV{LMC_KEEP}); + +sub in_preserved_kconfigs { + my $kconfig = $config2kfile{$_[0]}; + if (!defined($kconfig)) { + return 0; + } + foreach my $excl (@preserved_kconfigs) { + if($kconfig =~ /^$excl/) { + return 1; + } + } + return 0; +} # Finally, read the .config file and turn off any module enabled that # we could not find a reason to keep enabled. @@ -644,6 +660,11 @@ foreach my $line (@config_file) { } if (/^(CONFIG.*)=(m|y)/) { + if (in_preserved_kconfigs($1)) { + dprint "Preserve config $1"; + print; + next; + } if (defined($configs{$1})) { if ($localyesconfig) { $setconfigs{$1} = 'y'; diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 3dc81397d0..ffa3ec65cc 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -15,15 +15,21 @@ struct symbol symbol_yes = { .name = "y", .curr = { "y", yes }, .flags = SYMBOL_CONST|SYMBOL_VALID, -}, symbol_mod = { +}; + +struct symbol symbol_mod = { .name = "m", .curr = { "m", mod }, .flags = SYMBOL_CONST|SYMBOL_VALID, -}, symbol_no = { +}; + +struct symbol symbol_no = { .name = "n", .curr = { "n", no }, .flags = SYMBOL_CONST|SYMBOL_VALID, -}, symbol_empty = { +}; + +static struct symbol symbol_empty = { .name = "", .curr = { "", no }, .flags = SYMBOL_VALID, @@ -31,7 +37,7 @@ struct symbol symbol_yes = { struct symbol *sym_defconfig_list; struct symbol *modules_sym; -tristate modules_val; +static tristate modules_val; enum symbol_type sym_get_type(struct symbol *sym) { @@ -831,7 +837,7 @@ struct symbol *sym_lookup(const char *name, int flags) memset(symbol, 0, sizeof(*symbol)); symbol->name = new_name; symbol->type = S_UNKNOWN; - symbol->flags |= flags; + symbol->flags = flags; symbol->next = symbol_hash[hash]; symbol_hash[hash] = symbol; diff --git a/scripts/kconfig/tests/rand_nested_choice/Kconfig b/scripts/kconfig/tests/rand_nested_choice/Kconfig deleted file mode 100644 index 8350de7f73..0000000000 --- a/scripts/kconfig/tests/rand_nested_choice/Kconfig +++ /dev/null @@ -1,35 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -choice - prompt "choice" - -config A - bool "A" - -config B - bool "B" - -if B -choice - prompt "sub choice" - -config C - bool "C" - -config D - bool "D" - -if D -choice - prompt "subsub choice" - -config E - bool "E" - -endchoice -endif # D - -endchoice -endif # B - -endchoice diff --git a/scripts/kconfig/tests/rand_nested_choice/__init__.py b/scripts/kconfig/tests/rand_nested_choice/__init__.py deleted file mode 100644 index 9e4b2db535..0000000000 --- a/scripts/kconfig/tests/rand_nested_choice/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -""" -Set random values recursively in nested choices. - -Kconfig can create a choice-in-choice structure by using 'if' statement. -randconfig should correctly set random choice values. - -Related Linux commit: 3b9a19e08960e5cdad5253998637653e592a3c29 -""" - - -def test(conf): - for i in range(20): - assert conf.randconfig() == 0 - assert (conf.config_contains('expected_stdout0') or - conf.config_contains('expected_stdout1') or - conf.config_contains('expected_stdout2')) diff --git a/scripts/kconfig/tests/rand_nested_choice/expected_stdout0 b/scripts/kconfig/tests/rand_nested_choice/expected_stdout0 deleted file mode 100644 index 05450f3d4e..0000000000 --- a/scripts/kconfig/tests/rand_nested_choice/expected_stdout0 +++ /dev/null @@ -1,2 +0,0 @@ -CONFIG_A=y -# CONFIG_B is not set diff --git a/scripts/kconfig/tests/rand_nested_choice/expected_stdout1 b/scripts/kconfig/tests/rand_nested_choice/expected_stdout1 deleted file mode 100644 index 37ab295841..0000000000 --- a/scripts/kconfig/tests/rand_nested_choice/expected_stdout1 +++ /dev/null @@ -1,4 +0,0 @@ -# CONFIG_A is not set -CONFIG_B=y -CONFIG_C=y -# CONFIG_D is not set diff --git a/scripts/kconfig/tests/rand_nested_choice/expected_stdout2 b/scripts/kconfig/tests/rand_nested_choice/expected_stdout2 deleted file mode 100644 index 849ff47e98..0000000000 --- a/scripts/kconfig/tests/rand_nested_choice/expected_stdout2 +++ /dev/null @@ -1,5 +0,0 @@ -# CONFIG_A is not set -CONFIG_B=y -# CONFIG_C is not set -CONFIG_D=y -CONFIG_E=y -- cgit v1.2.3 From 156a61d16e3661739749b90bdf5a243f8a26c8dc Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Fri, 28 Aug 2020 19:31:15 +0200 Subject: Documentation: boards: stm32mp: document eMMC boot configuration In order to boot from eMMC on the STM32MP15x, the boot_ack bit in the ext_csd register must be set. Document this and while at it, fix a misformatted code block in the same section. Signed-off-by: Ahmad Fatoum Signed-off-by: Bastian Krause Signed-off-by: Sascha Hauer --- Documentation/boards/stm32mp.rst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Documentation/boards/stm32mp.rst b/Documentation/boards/stm32mp.rst index 7c657eb990..b235c39927 100644 --- a/Documentation/boards/stm32mp.rst +++ b/Documentation/boards/stm32mp.rst @@ -64,7 +64,7 @@ An appropriate image for a SD-Card can be generated with following } For eMMC, the boot partitions are used as the FSBL partitions and so the user -partitions may look like this: +partitions may look like this:: image @STM32MP_BOARD@.img { partition ssbl { @@ -80,6 +80,17 @@ partitions may look like this: The fsbl1 and fsbl2 can be flashed by writing to barebox ``/dev/mmcX.boot0`` and ``/dev/mmcX.boot1`` respectively or from a booted operating system. +Additionally, the eMMC's ``ext_csd`` register must be modified to activate the +boot acknowledge signal (``BOOT_ACK``) and to select a boot partition. + +Assuming ``CONFIG_CMD_MMC_EXTCSD`` is enabled and the board shall boot from +``/dev/mmc1.boot1``:: + + mmc_extcsd /dev/mmc1 -i 179 -v 0x50 + +The STM32MP1 BootROM does *not* support booting from eMMC without fast boot +acknowledge. + Boot source selection --------------------- -- cgit v1.2.3 From 6555866bd1f1024456075235d9ba434606a31297 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Wed, 8 Jul 2020 09:47:39 +0200 Subject: lib: lzo: drop unused compression code The code doesn't compile and went unused since being added 10 years ago. Remove it. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- lib/lzo/Kconfig | 4 - lib/lzo/Makefile | 3 - lib/lzo/lzo1x_compress.c | 279 ----------------------------------------------- 3 files changed, 286 deletions(-) delete mode 100644 lib/lzo/lzo1x_compress.c diff --git a/lib/lzo/Kconfig b/lib/lzo/Kconfig index 9276b2128a..17b0083236 100644 --- a/lib/lzo/Kconfig +++ b/lib/lzo/Kconfig @@ -1,7 +1,3 @@ config LZO_DECOMPRESS bool "include lzo uncompression support" select UNCOMPRESS - -config LZO_COMPRESS - bool - diff --git a/lib/lzo/Makefile b/lib/lzo/Makefile index f2191f4a3d..0e576a1c10 100644 --- a/lib/lzo/Makefile +++ b/lib/lzo/Makefile @@ -1,4 +1 @@ - -obj-$(CONFIG_LZO_COMPRESS) += lzo1x_compress.o obj-$(CONFIG_LZO_DECOMPRESS) += lzo1x_decompress_safe.o - diff --git a/lib/lzo/lzo1x_compress.c b/lib/lzo/lzo1x_compress.c deleted file mode 100644 index 236eb21167..0000000000 --- a/lib/lzo/lzo1x_compress.c +++ /dev/null @@ -1,279 +0,0 @@ -/* - * LZO1X Compressor from LZO - * - * Copyright (C) 1996-2012 Markus F.X.J. Oberhumer - * - * The full LZO package can be found at: - * http://www.oberhumer.com/opensource/lzo/ - * - * Changed for Linux kernel use by: - * Nitin Gupta - * Richard Purdie - */ - -#include -#include -#include -#include -#include "lzodefs.h" - -static noinline size_t -lzo1x_1_do_compress(const unsigned char *in, size_t in_len, - unsigned char *out, size_t *out_len, - size_t ti, void *wrkmem) -{ - const unsigned char *ip; - unsigned char *op; - const unsigned char * const in_end = in + in_len; - const unsigned char * const ip_end = in + in_len - 20; - const unsigned char *ii; - lzo_dict_t * const dict = (lzo_dict_t *) wrkmem; - - op = out; - ip = in; - ii = ip; - ip += ti < 4 ? 4 - ti : 0; - - for (;;) { - const unsigned char *m_pos; - size_t t, m_len, m_off; - u32 dv; -literal: - ip += 1 + ((ip - ii) >> 5); -next: - if (unlikely(ip >= ip_end)) - break; - dv = get_unaligned_le32(ip); - t = ((dv * 0x1824429d) >> (32 - D_BITS)) & D_MASK; - m_pos = in + dict[t]; - dict[t] = (lzo_dict_t) (ip - in); - if (unlikely(dv != get_unaligned_le32(m_pos))) - goto literal; - - ii -= ti; - ti = 0; - t = ip - ii; - if (t != 0) { - if (t <= 3) { - op[-2] |= t; - COPY4(op, ii); - op += t; - } else if (t <= 16) { - *op++ = (t - 3); - COPY8(op, ii); - COPY8(op + 8, ii + 8); - op += t; - } else { - if (t <= 18) { - *op++ = (t - 3); - } else { - size_t tt = t - 18; - *op++ = 0; - while (unlikely(tt > 255)) { - tt -= 255; - *op++ = 0; - } - *op++ = tt; - } - do { - COPY8(op, ii); - COPY8(op + 8, ii + 8); - op += 16; - ii += 16; - t -= 16; - } while (t >= 16); - if (t > 0) do { - *op++ = *ii++; - } while (--t > 0); - } - } - - m_len = 4; - { -#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && defined(LZO_USE_CTZ64) - u64 v; - v = get_unaligned((const u64 *) (ip + m_len)) ^ - get_unaligned((const u64 *) (m_pos + m_len)); - if (unlikely(v == 0)) { - do { - m_len += 8; - v = get_unaligned((const u64 *) (ip + m_len)) ^ - get_unaligned((const u64 *) (m_pos + m_len)); - if (unlikely(ip + m_len >= ip_end)) - goto m_len_done; - } while (v == 0); - } -# if defined(__LITTLE_ENDIAN) - m_len += (unsigned) __builtin_ctzll(v) / 8; -# elif defined(__BIG_ENDIAN) - m_len += (unsigned) __builtin_clzll(v) / 8; -# else -# error "missing endian definition" -# endif -#elif defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && defined(LZO_USE_CTZ32) - u32 v; - v = get_unaligned((const u32 *) (ip + m_len)) ^ - get_unaligned((const u32 *) (m_pos + m_len)); - if (unlikely(v == 0)) { - do { - m_len += 4; - v = get_unaligned((const u32 *) (ip + m_len)) ^ - get_unaligned((const u32 *) (m_pos + m_len)); - if (v != 0) - break; - m_len += 4; - v = get_unaligned((const u32 *) (ip + m_len)) ^ - get_unaligned((const u32 *) (m_pos + m_len)); - if (unlikely(ip + m_len >= ip_end)) - goto m_len_done; - } while (v == 0); - } -# if defined(__LITTLE_ENDIAN) - m_len += (unsigned) __builtin_ctz(v) / 8; -# elif defined(__BIG_ENDIAN) - m_len += (unsigned) __builtin_clz(v) / 8; -# else -# error "missing endian definition" -# endif -#else - if (unlikely(ip[m_len] == m_pos[m_len])) { - do { - m_len += 1; - if (ip[m_len] != m_pos[m_len]) - break; - m_len += 1; - if (ip[m_len] != m_pos[m_len]) - break; - m_len += 1; - if (ip[m_len] != m_pos[m_len]) - break; - m_len += 1; - if (ip[m_len] != m_pos[m_len]) - break; - m_len += 1; - if (ip[m_len] != m_pos[m_len]) - break; - m_len += 1; - if (ip[m_len] != m_pos[m_len]) - break; - m_len += 1; - if (ip[m_len] != m_pos[m_len]) - break; - m_len += 1; - if (unlikely(ip + m_len >= ip_end)) - goto m_len_done; - } while (ip[m_len] == m_pos[m_len]); - } -#endif - } -m_len_done: - - m_off = ip - m_pos; - ip += m_len; - ii = ip; - if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET) { - m_off -= 1; - *op++ = (((m_len - 1) << 5) | ((m_off & 7) << 2)); - *op++ = (m_off >> 3); - } else if (m_off <= M3_MAX_OFFSET) { - m_off -= 1; - if (m_len <= M3_MAX_LEN) - *op++ = (M3_MARKER | (m_len - 2)); - else { - m_len -= M3_MAX_LEN; - *op++ = M3_MARKER | 0; - while (unlikely(m_len > 255)) { - m_len -= 255; - *op++ = 0; - } - *op++ = (m_len); - } - *op++ = (m_off << 2); - *op++ = (m_off >> 6); - } else { - m_off -= 0x4000; - if (m_len <= M4_MAX_LEN) - *op++ = (M4_MARKER | ((m_off >> 11) & 8) - | (m_len - 2)); - else { - m_len -= M4_MAX_LEN; - *op++ = (M4_MARKER | ((m_off >> 11) & 8)); - while (unlikely(m_len > 255)) { - m_len -= 255; - *op++ = 0; - } - *op++ = (m_len); - } - *op++ = (m_off << 2); - *op++ = (m_off >> 6); - } - goto next; - } - *out_len = op - out; - return in_end - (ii - ti); -} - -int lzo1x_1_compress(const unsigned char *in, size_t in_len, - unsigned char *out, size_t *out_len, - void *wrkmem) -{ - const unsigned char *ip = in; - unsigned char *op = out; - size_t l = in_len; - size_t t = 0; - - while (l > 20) { - size_t ll = l <= (M4_MAX_OFFSET + 1) ? l : (M4_MAX_OFFSET + 1); - uintptr_t ll_end = (uintptr_t) ip + ll; - if ((ll_end + ((t + ll) >> 5)) <= ll_end) - break; - BUILD_BUG_ON(D_SIZE * sizeof(lzo_dict_t) > LZO1X_1_MEM_COMPRESS); - memset(wrkmem, 0, D_SIZE * sizeof(lzo_dict_t)); - t = lzo1x_1_do_compress(ip, ll, op, out_len, t, wrkmem); - ip += ll; - op += *out_len; - l -= ll; - } - t += l; - - if (t > 0) { - const unsigned char *ii = in + in_len - t; - - if (op == out && t <= 238) { - *op++ = (17 + t); - } else if (t <= 3) { - op[-2] |= t; - } else if (t <= 18) { - *op++ = (t - 3); - } else { - size_t tt = t - 18; - *op++ = 0; - while (tt > 255) { - tt -= 255; - *op++ = 0; - } - *op++ = tt; - } - if (t >= 16) do { - COPY8(op, ii); - COPY8(op + 8, ii + 8); - op += 16; - ii += 16; - t -= 16; - } while (t >= 16); - if (t > 0) do { - *op++ = *ii++; - } while (--t > 0); - } - - *op++ = M4_MARKER | 1; - *op++ = 0; - *op++ = 0; - - *out_len = op - out; - return LZO_E_OK; -} -EXPORT_SYMBOL_GPL(lzo1x_1_compress); - -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("LZO1X-1 Compressor"); -- cgit v1.2.3 From 2ed55f746c4223b5d7dfcddb2aa3029dc8e7439b Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Sep 2020 12:05:47 +0200 Subject: sandbox: hostfile: error out if file couldn't be opened The file descriptor is mandatory for doing anything useful. Error out if we don't have one. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- arch/sandbox/board/hostfile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c index 5f0d7e0a4b..56023b4ad4 100644 --- a/arch/sandbox/board/hostfile.c +++ b/arch/sandbox/board/hostfile.c @@ -91,6 +91,9 @@ static int hf_probe(struct device_d *dev) if (!priv->fd) priv->fd = linux_open(priv->filename, true); + if (priv->fd < 0) + return priv->fd; + priv->cdev.name = dev->device_node->name; priv->cdev.dev = dev; priv->cdev.ops = &hf_fops; -- cgit v1.2.3 From 5fb2a0e8342424665a01d510ee64d742f586f877 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Sep 2020 12:05:48 +0200 Subject: sandbox: add_image: support mmaping block devices on 32-bit hosts BLKGETSIZE64 writes 64-bit to the address pointed at by the ioctl argument. As hf->size is a 32-bit size_t on 32-bit systems, on such systems, the adjacent member might be corrupted. Fix this. Fixes: 8d6da6462b12 ("sandbox: add_image: mmap block devices") Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- arch/sandbox/board/dtb.c | 2 +- arch/sandbox/board/hostfile.c | 1 + arch/sandbox/dts/sandbox-state-example.dtsi | 2 +- arch/sandbox/dts/skeleton.dtsi | 4 ++-- arch/sandbox/mach-sandbox/include/mach/hostfile.h | 2 +- arch/sandbox/os/common.c | 10 +++++++--- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/arch/sandbox/board/dtb.c b/arch/sandbox/board/dtb.c index 74ecbadf42..d11bde0249 100644 --- a/arch/sandbox/board/dtb.c +++ b/arch/sandbox/board/dtb.c @@ -46,7 +46,7 @@ static int of_sandbox_init(void) if (ret) return ret; - ret = of_property_write_u32(root, "#size-cells", 1); + ret = of_property_write_u32(root, "#size-cells", 2); if (ret) return ret; } diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c index 56023b4ad4..07287fc0b4 100644 --- a/arch/sandbox/board/hostfile.c +++ b/arch/sandbox/board/hostfile.c @@ -134,6 +134,7 @@ static int of_hostfile_fixup(struct device_node *root, void *ctx) uint32_t reg[] = { hf->base >> 32, hf->base, + hf->size >> 32, hf->size }; int ret; diff --git a/arch/sandbox/dts/sandbox-state-example.dtsi b/arch/sandbox/dts/sandbox-state-example.dtsi index fc17bd0788..98640f6677 100644 --- a/arch/sandbox/dts/sandbox-state-example.dtsi +++ b/arch/sandbox/dts/sandbox-state-example.dtsi @@ -6,7 +6,7 @@ disk { compatible = "barebox,hostfile"; barebox,filename = "disk"; - reg = <0x0 0x0 0x100000>; + reg = <0x0 0x0 0x0 0x100000>; partitions { compatible = "fixed-partitions"; diff --git a/arch/sandbox/dts/skeleton.dtsi b/arch/sandbox/dts/skeleton.dtsi index 38ead821bb..8ba7663eb5 100644 --- a/arch/sandbox/dts/skeleton.dtsi +++ b/arch/sandbox/dts/skeleton.dtsi @@ -6,8 +6,8 @@ / { #address-cells = <2>; - #size-cells = <1>; + #size-cells = <2>; chosen { }; aliases { }; - memory { device_type = "memory"; reg = <0 0 0>; }; + memory { device_type = "memory"; reg = <0 0 0 0>; }; }; diff --git a/arch/sandbox/mach-sandbox/include/mach/hostfile.h b/arch/sandbox/mach-sandbox/include/mach/hostfile.h index 54f690be5f..e2f44c4f7b 100644 --- a/arch/sandbox/mach-sandbox/include/mach/hostfile.h +++ b/arch/sandbox/mach-sandbox/include/mach/hostfile.h @@ -4,7 +4,7 @@ struct hf_info { int fd; unsigned long long base; - size_t size; + unsigned long long size; const char *devname; const char *filename; }; diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c index 69fadb3b47..9f26f8fa6e 100644 --- a/arch/sandbox/os/common.c +++ b/arch/sandbox/os/common.c @@ -267,9 +267,13 @@ static int add_image(char *str, char *devname_template, int *devname_number) goto err_out; } } - hf->base = (unsigned long)mmap(NULL, hf->size, - PROT_READ | (readonly ? 0 : PROT_WRITE), - MAP_SHARED, fd, 0); + if (hf->size <= SIZE_MAX) + hf->base = (unsigned long)mmap(NULL, hf->size, + PROT_READ | (readonly ? 0 : PROT_WRITE), + MAP_SHARED, fd, 0); + else + printf("warning: %s: contiguous map failed\n", filename); + if (hf->base == (unsigned long)MAP_FAILED) printf("warning: mmapping %s failed: %s\n", filename, strerror(errno)); -- cgit v1.2.3 From ddcd3d43c1132e5754fa91398dd2138a35660c43 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Sep 2020 12:05:49 +0200 Subject: sandbox: support escaping commas in --image filenames Some tools like afl-fuzz generate file names containing commas. Allow escaping the commas in the file names, so they can be passed to barebox. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- arch/sandbox/os/common.c | 10 ++++++---- include/linux/string.h | 1 + lib/string.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c index 9f26f8fa6e..437fe3ecdf 100644 --- a/arch/sandbox/os/common.c +++ b/arch/sandbox/os/common.c @@ -212,6 +212,8 @@ int linux_execve(const char * filename, char *const argv[], char *const envp[]) extern void start_barebox(void); extern void mem_malloc_init(void *start, void *end); +extern char * strsep_unescaped(char **s, const char *ct); + static int add_image(char *str, char *devname_template, int *devname_number) { struct hf_info *hf = malloc(sizeof(struct hf_info)); @@ -225,15 +227,15 @@ static int add_image(char *str, char *devname_template, int *devname_number) if (!hf) return -1; - filename = strtok(str, ","); - while ((opt = strtok(NULL, ","))) { + filename = strsep_unescaped(&str, ","); + while ((opt = strsep_unescaped(&str, ","))) { if (!strcmp(opt, "ro")) readonly = 1; } /* parses: "devname=filename" */ - devname = strtok(filename, "="); - filename = strtok(NULL, "="); + devname = strsep_unescaped(&filename, "="); + filename = strsep_unescaped(&filename, "="); if (!filename) { filename = devname; snprintf(tmp, sizeof(tmp), diff --git a/include/linux/string.h b/include/linux/string.h index fd42f5020a..763ef500e5 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -12,6 +12,7 @@ extern char * ___strtok; extern char * strpbrk(const char *,const char *); extern char * strtok(char *,const char *); extern char * strsep(char **,const char *); +extern char * strsep_unescaped(char **,const char *); extern __kernel_size_t strspn(const char *,const char *); diff --git a/lib/string.c b/lib/string.c index 7548fd3581..50f8e2f87c 100644 --- a/lib/string.c +++ b/lib/string.c @@ -455,6 +455,49 @@ char * strsep(char **s, const char *ct) #endif EXPORT_SYMBOL(strsep); +/** + * strsep_unescaped - Split a string into tokens, while ignoring escaped delimiters + * @s: The string to be searched + * @ct: The delimiter characters to search for + * + * strsep_unescaped() behaves like strsep unless it meets an escaped delimiter. + * In that case, it shifts the string back in memory to overwrite the escape's + * backslash then continues the search until an unescaped delimiter is found. + */ +char *strsep_unescaped(char **s, const char *ct) +{ + char *sbegin = *s, *hay; + const char *needle; + size_t shift = 0; + + if (sbegin == NULL) + return NULL; + + for (hay = sbegin; *hay != '\0'; ++hay) { + *hay = hay[shift]; + + if (*hay == '\\') { + *hay = hay[++shift]; + if (*hay != '\\') + continue; + } + + for (needle = ct; *needle != '\0'; ++needle) { + if (*hay == *needle) + goto match; + } + } + + *s = NULL; + return sbegin; + +match: + *hay = '\0'; + *s = &hay[shift + 1]; + + return sbegin; +} + #ifndef __HAVE_ARCH_STRSWAB /** * strswab - swap adjacent even and odd bytes in %NUL-terminated string -- cgit v1.2.3 From 5487aa192da08801c18d2e46560f0522be080e83 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Sep 2020 12:05:50 +0200 Subject: readkey: fix buffer overflow handling longer escape sequences My terminal emulator uses "\e[5;5~" (six bytes) to represent a Ctrl+PageUp, this overflows the esc buffer, which is only 5 bytes long as both UBSan and ASAN report. We have a check that should've avoided it, but it has an off-by one, which corrupts memory on sizes >= 4. Fix it. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- lib/readkey.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/readkey.c b/lib/readkey.c index fd72951046..c26e9d51ab 100644 --- a/lib/readkey.c +++ b/lib/readkey.c @@ -61,7 +61,7 @@ int read_key(void) esc[i] = getchar(); if (esc[i++] == '~') break; - if (i == ARRAY_SIZE(esc)) + if (i == ARRAY_SIZE(esc) - 1) return -1; } } -- cgit v1.2.3 From dc7f1fce6747fe0320441b95609c95e590bcc18d Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Sep 2020 12:05:51 +0200 Subject: sandbox: fix SANDBOX_UNWIND dependency to be KASAN only gcc v9.3.0's libubsan does not export a __sanitizer_print_stack_trace symbol. Play it safe and avoid possible linker errors by having the optional SANDBOX_UNWIND depend only on CONFIG_KASAN. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- arch/sandbox/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig index 40e04919d2..c4d0ab4dbc 100644 --- a/arch/sandbox/Kconfig +++ b/arch/sandbox/Kconfig @@ -22,7 +22,7 @@ config SANDBOX_UNWIND bool default y select ARCH_HAS_STACK_DUMP - depends on UBSAN || KASAN + depends on KASAN config PHYS_ADDR_T_64BIT bool -- cgit v1.2.3 From 67f77f924295bb68786a47e81b8e059328896c98 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Sep 2020 12:05:53 +0200 Subject: common: ubsan: replace pr_err with printf The pr_print family of functions also writes to the barebox log buffer, which we don't require for printing UBSan errors, which is a debugging aid. This also improves UBSan coverage as now undefined behavior within pr_print may be reported as well. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- lib/ubsan.c | 88 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/lib/ubsan.c b/lib/ubsan.c index 41a5731dda..085d470cf7 100644 --- a/lib/ubsan.c +++ b/lib/ubsan.c @@ -60,8 +60,8 @@ static bool was_reported(struct source_location *location) static void print_source_location(const char *prefix, struct source_location *loc) { - pr_err("%s %s:%d:%d\n", prefix, loc->file_name, - loc->line & LINE_MASK, loc->column & COLUMN_MASK); + printf("%s %s:%d:%d\n", prefix, loc->file_name, + loc->line & LINE_MASK, loc->column & COLUMN_MASK); } static bool suppress_report(struct source_location *loc) @@ -157,16 +157,16 @@ static void ubsan_prologue(struct source_location *location, { in_ubsan++; - pr_err("========================================" - "========================================\n"); + printf("========================================" + "========================================\n"); print_source_location("UBSAN: Undefined behaviour in", location); } static void ubsan_epilogue(unsigned long *flags) { dump_stack(); - pr_err("========================================" - "========================================\n"); + printf("========================================" + "========================================\n"); in_ubsan--; } @@ -186,13 +186,13 @@ static void handle_overflow(struct overflow_data *data, void *lhs, val_to_string(lhs_val_str, sizeof(lhs_val_str), type, lhs); val_to_string(rhs_val_str, sizeof(rhs_val_str), type, rhs); - pr_err("%s integer overflow:\n", - type_is_signed(type) ? "signed" : "unsigned"); - pr_err("%s %c %s cannot be represented in type %s\n", - lhs_val_str, - op, - rhs_val_str, - type->type_name); + printf("%s integer overflow:\n", + type_is_signed(type) ? "signed" : "unsigned"); + printf("%s %c %s cannot be represented in type %s\n", + lhs_val_str, + op, + rhs_val_str, + type->type_name); ubsan_epilogue(&flags); } @@ -232,8 +232,8 @@ void __ubsan_handle_negate_overflow(struct overflow_data *data, val_to_string(old_val_str, sizeof(old_val_str), data->type, old_val); - pr_err("negation of %s cannot be represented in type %s:\n", - old_val_str, data->type->type_name); + printf("negation of %s cannot be represented in type %s:\n", + old_val_str, data->type->type_name); ubsan_epilogue(&flags); } @@ -254,10 +254,10 @@ void __ubsan_handle_divrem_overflow(struct overflow_data *data, val_to_string(rhs_val_str, sizeof(rhs_val_str), data->type, rhs); if (type_is_signed(data->type) && get_signed_val(data->type, rhs) == -1) - pr_err("division of %s by -1 cannot be represented in type %s\n", - rhs_val_str, data->type->type_name); + printf("division of %s by -1 cannot be represented in type %s\n", + rhs_val_str, data->type->type_name); else - pr_err("division by zero\n"); + printf("division by zero\n"); ubsan_epilogue(&flags); } @@ -272,9 +272,9 @@ static void handle_null_ptr_deref(struct type_mismatch_data_common *data) ubsan_prologue(data->location, &flags); - pr_err("%s null pointer of type %s\n", - type_check_kinds[data->type_check_kind], - data->type->type_name); + printf("%s null pointer of type %s\n", + type_check_kinds[data->type_check_kind], + data->type->type_name); ubsan_epilogue(&flags); } @@ -289,10 +289,10 @@ static void handle_misaligned_access(struct type_mismatch_data_common *data, ubsan_prologue(data->location, &flags); - pr_err("%s misaligned address %p for type %s\n", - type_check_kinds[data->type_check_kind], - (void *)ptr, data->type->type_name); - pr_err("which requires %ld byte alignment\n", data->alignment); + printf("%s misaligned address %p for type %s\n", + type_check_kinds[data->type_check_kind], + (void *)ptr, data->type->type_name); + printf("which requires %ld byte alignment\n", data->alignment); ubsan_epilogue(&flags); } @@ -306,10 +306,10 @@ static void handle_object_size_mismatch(struct type_mismatch_data_common *data, return; ubsan_prologue(data->location, &flags); - pr_err("%s address %p with insufficient space\n", + printf("%s address %p with insufficient space\n", type_check_kinds[data->type_check_kind], (void *) ptr); - pr_err("for an object of type %s\n", data->type->type_name); + printf("for an object of type %s\n", data->type->type_name); ubsan_epilogue(&flags); } @@ -364,8 +364,8 @@ void __ubsan_handle_out_of_bounds(struct out_of_bounds_data *data, void *index) ubsan_prologue(&data->location, &flags); val_to_string(index_str, sizeof(index_str), data->index_type, index); - pr_err("index %s is out of range for type %s\n", index_str, - data->array_type->type_name); + printf("index %s is out of range for type %s\n", index_str, + data->array_type->type_name); ubsan_epilogue(&flags); } EXPORT_SYMBOL(__ubsan_handle_out_of_bounds); @@ -408,22 +408,22 @@ void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data, val_to_string(lhs_str, sizeof(lhs_str), lhs_type, lhs); if (val_is_negative(rhs_type, rhs)) - pr_err("shift exponent %s is negative\n", rhs_str); + printf("shift exponent %s is negative\n", rhs_str); else if (get_unsigned_val(rhs_type, rhs) >= - type_bit_width(lhs_type)) - pr_err("shift exponent %s is too large for %u-bit type %s\n", - rhs_str, - type_bit_width(lhs_type), - lhs_type->type_name); + type_bit_width(lhs_type)) + printf("shift exponent %s is too large for %u-bit type %s\n", + rhs_str, + type_bit_width(lhs_type), + lhs_type->type_name); else if (val_is_negative(lhs_type, lhs)) - pr_err("left shift of negative value %s\n", - lhs_str); + printf("left shift of negative value %s\n", + lhs_str); else - pr_err("left shift of %s by %s places cannot be" - " represented in type %s\n", - lhs_str, rhs_str, - lhs_type->type_name); + printf("left shift of %s by %s places cannot be" + " represented in type %s\n", + lhs_str, rhs_str, + lhs_type->type_name); ubsan_epilogue(&flags); } @@ -435,7 +435,7 @@ void __ubsan_handle_builtin_unreachable(struct unreachable_data *data) unsigned long flags; ubsan_prologue(&data->location, &flags); - pr_err("calling __builtin_unreachable()\n"); + printf("calling __builtin_unreachable()\n"); ubsan_epilogue(&flags); panic("can't return from __builtin_unreachable()"); } @@ -454,8 +454,8 @@ void __ubsan_handle_load_invalid_value(struct invalid_value_data *data, val_to_string(val_str, sizeof(val_str), data->type, val); - pr_err("load of value %s is not a valid value for type %s\n", - val_str, data->type->type_name); + printf("load of value %s is not a valid value for type %s\n", + val_str, data->type->type_name); ubsan_epilogue(&flags); } -- cgit v1.2.3 From 74d78a1e4a47c322d348823b2836614b531cda8b Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Sep 2020 15:37:44 +0200 Subject: lib: string: retire deprecated strtok() in favor of reentrant strsep() With the recent changes to ARCH=sandbox, there are no remaining in-tree users for strtok() anymore. Out-of-tree users are better served by using the reentrant strsep(), which has existed in-tree for as long. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- include/linux/string.h | 2 -- lib/string.c | 35 +++-------------------------------- 2 files changed, 3 insertions(+), 34 deletions(-) diff --git a/include/linux/string.h b/include/linux/string.h index 763ef500e5..2b699957e8 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -8,9 +8,7 @@ extern "C" { #endif -extern char * ___strtok; extern char * strpbrk(const char *,const char *); -extern char * strtok(char *,const char *); extern char * strsep(char **,const char *); extern char * strsep_unescaped(char **,const char *); extern __kernel_size_t strspn(const char *,const char *); diff --git a/lib/string.c b/lib/string.c index 50f8e2f87c..733b567300 100644 --- a/lib/string.c +++ b/lib/string.c @@ -13,6 +13,9 @@ * * Fri Jun 25 1999, Ingo Oeser * - Added strsep() which will replace strtok() soon (because strsep() is * reentrant and should be faster). Use only strsep() in new code, please. + * * Mon Sep 14 2020, Ahmad Fatoum + * - Kissed strtok() goodbye + * */ #include @@ -20,8 +23,6 @@ #include #include -char * ___strtok; - #ifndef __HAVE_ARCH_STRNICMP /** * strnicmp - Case insensitive, length-limited string comparison @@ -396,36 +397,6 @@ char * strpbrk(const char * cs,const char * ct) #endif EXPORT_SYMBOL(strpbrk); -#ifndef __HAVE_ARCH_STRTOK -/** - * strtok - Split a string into tokens - * @s: The string to be searched - * @ct: The characters to search for - * - * WARNING: strtok is deprecated, use strsep instead. - */ -char * strtok(char * s, const char * ct) -{ - char *sbegin, *send; - - sbegin = s ? s : ___strtok; - if (!sbegin) { - return NULL; - } - sbegin += strspn(sbegin,ct); - if (*sbegin == '\0') { - ___strtok = NULL; - return( NULL ); - } - send = strpbrk( sbegin, ct); - if (send && *send != '\0') - *send++ = '\0'; - ___strtok = send; - return (sbegin); -} -#endif -EXPORT_SYMBOL(strtok); - #ifndef __HAVE_ARCH_STRSEP /** * strsep - Split a string into tokens -- cgit v1.2.3 From b81ff979a72b427ce4fc4c00c8aab2a302af41a8 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Sep 2020 15:37:45 +0200 Subject: ls: don't print . and .. on recursive ls They are already omitted on normal ls and they don't really add a new information, so drop them for the recursive case as well. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- commands/ls.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/commands/ls.c b/commands/ls.c index 6a5475d094..59163f678d 100644 --- a/commands/ls.c +++ b/commands/ls.c @@ -75,8 +75,13 @@ int ls(const char *path, ulong flags) if (!dir) return -errno; - while ((d = readdir(dir))) + while ((d = readdir(dir))) { + if (!strcmp(d->d_name, ".")) + continue; + if (!strcmp(d->d_name, "..")) + continue; string_list_add_sorted(&sl, d->d_name); + } closedir(dir); @@ -99,10 +104,6 @@ int ls(const char *path, ulong flags) goto out; string_list_for_each_entry(entry, &sl) { - if (!strcmp(entry->str, ".")) - continue; - if (!strcmp(entry->str, "..")) - continue; sprintf(tmp, "%s/%s", path, entry->str); ret = lstat(tmp, &s); -- cgit v1.2.3 From 7d8af896c7c660a8608abe5efa82b52e9d9f097c Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Sep 2020 15:37:46 +0200 Subject: sandbox: implement simple, ^C-interruptible, restart handler Typing reset in sandbox results in hang() while the terminal is not cooked and ^C is ineffective. Only way to terminate barebox then is via kill. Reinstate cooked mode on reset, so ^C termination is possible. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- arch/sandbox/board/poweroff.c | 12 ++++++++++++ arch/sandbox/mach-sandbox/include/mach/linux.h | 1 + arch/sandbox/os/common.c | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/arch/sandbox/board/poweroff.c b/arch/sandbox/board/poweroff.c index 6b5a6dff15..5072b756e1 100644 --- a/arch/sandbox/board/poweroff.c +++ b/arch/sandbox/board/poweroff.c @@ -1,6 +1,7 @@ #include #include #include +#include #include static void sandbox_poweroff(struct poweroff_handler *poweroff) @@ -8,9 +9,20 @@ static void sandbox_poweroff(struct poweroff_handler *poweroff) linux_exit(); } +static void sandbox_rst_hang(struct restart_handler *rst) +{ + linux_hang(); +} + +static struct restart_handler rst_hang = { + .name = "hang", + .restart = sandbox_rst_hang +}; + static int poweroff_register_feature(void) { poweroff_handler_register_fn(sandbox_poweroff); + restart_handler_register(&rst_hang); return 0; } diff --git a/arch/sandbox/mach-sandbox/include/mach/linux.h b/arch/sandbox/mach-sandbox/include/mach/linux.h index 9759a376ec..f0a3a7b510 100644 --- a/arch/sandbox/mach-sandbox/include/mach/linux.h +++ b/arch/sandbox/mach-sandbox/include/mach/linux.h @@ -17,6 +17,7 @@ ssize_t linux_write(int fd, const void *buf, size_t count); off_t linux_lseek(int fildes, off_t offset); int linux_tstc(int fd); void __attribute__((noreturn)) linux_exit(void); +void linux_hang(void); int linux_execve(const char * filename, char *const argv[], char *const envp[]); diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c index 437fe3ecdf..bbab3bd231 100644 --- a/arch/sandbox/os/common.c +++ b/arch/sandbox/os/common.c @@ -122,6 +122,12 @@ void __attribute__((noreturn)) linux_exit(void) exit(0); } +void linux_hang(void) +{ + cookmode(); + /* falls through to generic hang() */ +} + int linux_open(const char *filename, int readwrite) { return open(filename, readwrite ? O_RDWR : O_RDONLY); -- cgit v1.2.3 From 3b39a4d550ac3756a6a9fb520a92f6f62c1b6b45 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Mon, 14 Sep 2020 15:00:05 +0200 Subject: arm/cpu/*.S: Replace license and copyright boilerplate by SPDX identfiers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since commit ed2f892a1ba7 ("arm/cpu: Replace license and copyright boilerplate by SPDX identfiers") my script learned to detect .S files, too. Signed-off-by: Uwe Kleine-König Signed-off-by: Sascha Hauer --- arch/arm/cpu/smccc-call.S | 16 +++------------- arch/arm/cpu/smccc-call_64.S | 16 +++------------- 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/arch/arm/cpu/smccc-call.S b/arch/arm/cpu/smccc-call.S index b6bdc8b3b5..9875e1f947 100644 --- a/arch/arm/cpu/smccc-call.S +++ b/arch/arm/cpu/smccc-call.S @@ -1,16 +1,6 @@ -/* - * Copyright (c) 2015, Linaro Limited - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* SPDX-FileCopyrightText: 2015 Linaro Limited */ + #include #include diff --git a/arch/arm/cpu/smccc-call_64.S b/arch/arm/cpu/smccc-call_64.S index 44888fb594..c2959050d2 100644 --- a/arch/arm/cpu/smccc-call_64.S +++ b/arch/arm/cpu/smccc-call_64.S @@ -1,16 +1,6 @@ -/* - * Copyright (c) 2015, Linaro Limited - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License Version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* SPDX-FileCopyrightText: 2015 Linaro Limited */ + #include #include #include -- cgit v1.2.3 From 65ca0db25b6aca3df1ff0adf1a9469e83983614f Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 15 Sep 2020 08:05:27 +0200 Subject: scripts: Make locally used functions static Signed-off-by: Sascha Hauer --- scripts/imx/imx-usb-loader.c | 2 +- scripts/kwbimage.c | 4 ++-- scripts/mkublheader.c | 2 +- scripts/mxsimage.c | 2 +- scripts/omap4_usbboot.c | 14 +++++++------- scripts/pblimage.c | 2 +- scripts/socfpga_mkimage.c | 2 +- scripts/tegra/t114/nvbctlib_t114.c | 12 ++++++------ scripts/tegra/t124/nvbctlib_t124.c | 12 ++++++------ scripts/tegra/t20/nvbctlib_t20.c | 12 ++++++------ scripts/tegra/t30/nvbctlib_t30.c | 12 ++++++------ 11 files changed, 38 insertions(+), 38 deletions(-) diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c index 8447ca2a8f..28f342633d 100644 --- a/scripts/imx/imx-usb-loader.c +++ b/scripts/imx/imx-usb-loader.c @@ -562,7 +562,7 @@ static int transfer(int report, unsigned char *p, unsigned cnt, int *last_trans) return err; } -int do_status(void) +static int do_status(void) { int last_trans; unsigned char tmp[64]; diff --git a/scripts/kwbimage.c b/scripts/kwbimage.c index 6ba4abaa30..26eb07fa81 100644 --- a/scripts/kwbimage.c +++ b/scripts/kwbimage.c @@ -231,7 +231,7 @@ static const char *image_boot_mode_name(unsigned int id) return NULL; } -int image_boot_mode_id(const char *boot_mode_name) +static int image_boot_mode_id(const char *boot_mode_name) { int i; for (i = 0; boot_modes[i].name; i++) @@ -250,7 +250,7 @@ static const char *image_nand_ecc_mode_name(unsigned int id) return NULL; } -int image_nand_ecc_mode_id(const char *nand_ecc_mode_name) +static int image_nand_ecc_mode_id(const char *nand_ecc_mode_name) { int i; for (i = 0; nand_ecc_modes[i].name; i++) diff --git a/scripts/mkublheader.c b/scripts/mkublheader.c index 5464a80611..496ba0b500 100644 --- a/scripts/mkublheader.c +++ b/scripts/mkublheader.c @@ -45,7 +45,7 @@ struct ubl_header uint32_t ldAddr; /* Address where image is copied to */ }; -void usage(char *prgname) +static void usage(char *prgname) { printf( "Usage : %s [OPTION] FILE > HEADER\n" "\n" diff --git a/scripts/mxsimage.c b/scripts/mxsimage.c index 8a63d76939..aa25440862 100644 --- a/scripts/mxsimage.c +++ b/scripts/mxsimage.c @@ -442,7 +442,7 @@ int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *ctx) } #endif -uint32_t pbl_crc32(uint32_t in_crc, const char *buf, uint32_t len) +static uint32_t pbl_crc32(uint32_t in_crc, const char *buf, uint32_t len) { uint32_t crc32_val; int i; diff --git a/scripts/omap4_usbboot.c b/scripts/omap4_usbboot.c index 329668d1dd..44236259dc 100644 --- a/scripts/omap4_usbboot.c +++ b/scripts/omap4_usbboot.c @@ -43,21 +43,21 @@ #define host_print(fmt, arg...) printf(HFORMAT fmt TFORMAT, \ HOST_FORMAT, ##arg, TARGET_FORMAT) -int usb_write(void *h, void const *data, int len) +static int usb_write(void *h, void const *data, int len) { int actual; return libusb_bulk_transfer(h, 0x01, (void *)data, len, &actual, 5000) ? 0 : actual; } -int usb_read(void *h, void *data, int len) +static int usb_read(void *h, void *data, int len) { int actual; return libusb_bulk_transfer(h, 0x81, data, len, &actual, 5000) ? 0 : actual; } -void panic(struct termios *t_restore) +static void panic(struct termios *t_restore) { tcsetattr(STDIN_FILENO, TCSANOW, t_restore); printf(HFORMAT, HOST_FORMAT); @@ -70,7 +70,7 @@ struct thread_vars { struct termios t_restore; }; -void *listenerTask(void *argument) +static void *listenerTask(void *argument) { struct thread_vars *vars = argument; int c; @@ -88,7 +88,7 @@ void *listenerTask(void *argument) return NULL; } -int read_asic_id(struct libusb_device_handle *usb) +static int read_asic_id(struct libusb_device_handle *usb) { #define LINEWIDTH 16 const uint32_t msg_getid = 0xF0030003; @@ -189,7 +189,7 @@ struct file_data { void *data; }; -int process_file(struct libusb_device_handle *usb, const char *rootfs, +static int process_file(struct libusb_device_handle *usb, const char *rootfs, struct file_data *fd_vector, struct termios *t_restore) { uint32_t i, j, pos, size; @@ -339,7 +339,7 @@ open_ok: return ret; } -int usb_boot(struct libusb_device_handle *usb, +static int usb_boot(struct libusb_device_handle *usb, void *data, unsigned sz, const char *rootfs) { const uint32_t msg_boot = 0xF0030002; diff --git a/scripts/pblimage.c b/scripts/pblimage.c index 235af8aa11..3c3625cdd5 100644 --- a/scripts/pblimage.c +++ b/scripts/pblimage.c @@ -100,7 +100,7 @@ static void make_crc_table(void) crc_table_valid = 1; } -uint32_t pbl_crc32(uint32_t in_crc, const char *buf, uint32_t len) +static uint32_t pbl_crc32(uint32_t in_crc, const char *buf, uint32_t len) { uint32_t crc32_val; int i; diff --git a/scripts/socfpga_mkimage.c b/scripts/socfpga_mkimage.c index 03150cce8d..73dfbeae3a 100644 --- a/scripts/socfpga_mkimage.c +++ b/scripts/socfpga_mkimage.c @@ -147,7 +147,7 @@ static const uint32_t crc_table[256] = { 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 }; -uint32_t crc32(uint32_t crc, void *_buf, int length) +static uint32_t crc32(uint32_t crc, void *_buf, int length) { uint8_t *buf = _buf; diff --git a/scripts/tegra/t114/nvbctlib_t114.c b/scripts/tegra/t114/nvbctlib_t114.c index 063882a905..3bda785f57 100644 --- a/scripts/tegra/t114/nvbctlib_t114.c +++ b/scripts/tegra/t114/nvbctlib_t114.c @@ -827,7 +827,7 @@ t114_set_sdram_param(build_image_context *context, return 0; } -int +static int t114_getbl_param(u_int32_t set, parse_token id, u_int32_t *data, @@ -862,7 +862,7 @@ t114_getbl_param(u_int32_t set, return 0; } -int +static int t114_setbl_param(u_int32_t set, parse_token id, u_int32_t *data, @@ -897,7 +897,7 @@ t114_setbl_param(u_int32_t set, return 0; } -int +static int t114_bct_get_value(parse_token id, u_int32_t *data, u_int8_t *bct) { nvboot_config_table *bct_ptr = (nvboot_config_table *)bct; @@ -981,7 +981,7 @@ t114_bct_get_value(parse_token id, u_int32_t *data, u_int8_t *bct) return 0; } -int +static int t114_bct_set_value(parse_token id, u_int32_t data, u_int8_t *bct) { nvboot_config_table *bct_ptr = (nvboot_config_table *)bct; @@ -1009,7 +1009,7 @@ t114_bct_set_value(parse_token id, u_int32_t data, u_int8_t *bct) return 0; } -int +static int t114_bct_set_data(parse_token id, u_int8_t *data, u_int32_t length, @@ -1034,7 +1034,7 @@ t114_bct_set_data(parse_token id, return 0; } -void t114_init_bad_block_table(build_image_context *context) +static void t114_init_bad_block_table(build_image_context *context) { u_int32_t bytes_per_entry; nvboot_badblock_table *table; diff --git a/scripts/tegra/t124/nvbctlib_t124.c b/scripts/tegra/t124/nvbctlib_t124.c index ab2d925570..55b840926e 100644 --- a/scripts/tegra/t124/nvbctlib_t124.c +++ b/scripts/tegra/t124/nvbctlib_t124.c @@ -828,7 +828,7 @@ t124_set_sdram_param(build_image_context *context, return 0; } -int +static int t124_getbl_param(u_int32_t set, parse_token id, u_int32_t *data, @@ -863,7 +863,7 @@ t124_getbl_param(u_int32_t set, return 0; } -int +static int t124_setbl_param(u_int32_t set, parse_token id, u_int32_t *data, @@ -898,7 +898,7 @@ t124_setbl_param(u_int32_t set, return 0; } -int +static int t124_bct_get_value(parse_token id, u_int32_t *data, u_int8_t *bct) { nvboot_config_table *bct_ptr = (nvboot_config_table *)bct; @@ -982,7 +982,7 @@ t124_bct_get_value(parse_token id, u_int32_t *data, u_int8_t *bct) return 0; } -int +static int t124_bct_set_value(parse_token id, u_int32_t data, u_int8_t *bct) { nvboot_config_table *bct_ptr = (nvboot_config_table *)bct; @@ -1010,7 +1010,7 @@ t124_bct_set_value(parse_token id, u_int32_t data, u_int8_t *bct) return 0; } -int +static int t124_bct_set_data(parse_token id, u_int8_t *data, u_int32_t length, @@ -1036,7 +1036,7 @@ t124_bct_set_data(parse_token id, return 0; } -void t124_init_bad_block_table(build_image_context *context) +static void t124_init_bad_block_table(build_image_context *context) { u_int32_t bytes_per_entry; nvboot_badblock_table *table; diff --git a/scripts/tegra/t20/nvbctlib_t20.c b/scripts/tegra/t20/nvbctlib_t20.c index 5386b285d6..42ad146755 100644 --- a/scripts/tegra/t20/nvbctlib_t20.c +++ b/scripts/tegra/t20/nvbctlib_t20.c @@ -416,7 +416,7 @@ t20_get_sdram_param(build_image_context *context, return 0; } -int +static int t20_getbl_param(u_int32_t set, parse_token id, u_int32_t *data, @@ -451,7 +451,7 @@ t20_getbl_param(u_int32_t set, return 0; } -int +static int t20_setbl_param(u_int32_t set, parse_token id, u_int32_t *data, @@ -486,7 +486,7 @@ t20_setbl_param(u_int32_t set, return 0; } -int +static int t20_bct_get_value(parse_token id, u_int32_t *data, u_int8_t *bct) { nvboot_config_table *bct_ptr = (nvboot_config_table *)bct; @@ -565,7 +565,7 @@ t20_bct_get_value(parse_token id, u_int32_t *data, u_int8_t *bct) return 0; } -int +static int t20_bct_set_value(parse_token id, u_int32_t data, u_int8_t *bct) { nvboot_config_table *bct_ptr = (nvboot_config_table *)bct; @@ -593,7 +593,7 @@ t20_bct_set_value(parse_token id, u_int32_t data, u_int8_t *bct) return 0; } -int +static int t20_bct_set_data(parse_token id, u_int8_t *data, u_int32_t length, @@ -615,7 +615,7 @@ t20_bct_set_data(parse_token id, return 0; } -void t20_init_bad_block_table(build_image_context *context) +static void t20_init_bad_block_table(build_image_context *context) { u_int32_t bytes_per_entry; nvboot_badblock_table *table; diff --git a/scripts/tegra/t30/nvbctlib_t30.c b/scripts/tegra/t30/nvbctlib_t30.c index e55b0dfb98..04e8974fbf 100644 --- a/scripts/tegra/t30/nvbctlib_t30.c +++ b/scripts/tegra/t30/nvbctlib_t30.c @@ -623,7 +623,7 @@ t30_set_sdram_param(build_image_context *context, return 0; } -int +static int t30_getbl_param(u_int32_t set, parse_token id, u_int32_t *data, @@ -658,7 +658,7 @@ t30_getbl_param(u_int32_t set, return 0; } -int +static int t30_setbl_param(u_int32_t set, parse_token id, u_int32_t *data, @@ -693,7 +693,7 @@ t30_setbl_param(u_int32_t set, return 0; } -int +static int t30_bct_get_value(parse_token id, u_int32_t *data, u_int8_t *bct) { nvboot_config_table *bct_ptr = (nvboot_config_table *)bct; @@ -772,7 +772,7 @@ t30_bct_get_value(parse_token id, u_int32_t *data, u_int8_t *bct) return 0; } -int +static int t30_bct_set_value(parse_token id, u_int32_t data, u_int8_t *bct) { nvboot_config_table *bct_ptr = (nvboot_config_table *)bct; @@ -800,7 +800,7 @@ t30_bct_set_value(parse_token id, u_int32_t data, u_int8_t *bct) return 0; } -int +static int t30_bct_set_data(parse_token id, u_int8_t *data, u_int32_t length, @@ -822,7 +822,7 @@ t30_bct_set_data(parse_token id, return 0; } -void t30_init_bad_block_table(build_image_context *context) +static void t30_init_bad_block_table(build_image_context *context) { u_int32_t bytes_per_entry; nvboot_badblock_table *table; -- cgit v1.2.3 From 242d9e7531fbc394214d2a54d3ff56a5690f397a Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Sep 2020 15:37:47 +0200 Subject: sandbox: implement actual sandbox reset via exec(2) On Linux, /proc/self/exe is a symlink to the originally exec(2)d executable. We can exec that with the original argv to simulate a reset. This is useful for shorter development cycles on sandbox and in future, could be used to test barebox behavior around resets (e.g. reset reason can be passed through via libc environment). We leave the original hanging reset in place though, because: - Many boards have multiple reset providers and incoming patches will allow users to select a specific one. Having this on sandbox as well makes testing easier. - /proc/self/exe is Linux-specific and wouldn't work when being run on e.g. BSDs or macOS Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- arch/sandbox/Kconfig | 7 ++++ arch/sandbox/Makefile | 2 +- arch/sandbox/board/poweroff.c | 13 +++++++ arch/sandbox/mach-sandbox/include/mach/linux.h | 1 + arch/sandbox/os/common.c | 49 +++++++++++++++++++++----- arch/sandbox/os/tap.c | 2 +- 6 files changed, 63 insertions(+), 11 deletions(-) diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig index c4d0ab4dbc..b5213c662b 100644 --- a/arch/sandbox/Kconfig +++ b/arch/sandbox/Kconfig @@ -24,6 +24,13 @@ config SANDBOX_UNWIND select ARCH_HAS_STACK_DUMP depends on KASAN +config SANDBOX_REEXEC + prompt "exec(2) reset handler" + def_bool y + help + The normal reset handler hangs barebox. On Linux, barebox + instead can exec itself to simulate a reset. + config PHYS_ADDR_T_64BIT bool diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile index 27021222dc..eb678b72db 100644 --- a/arch/sandbox/Makefile +++ b/arch/sandbox/Makefile @@ -25,7 +25,7 @@ KBUILD_CFLAGS += -Dmalloc=barebox_malloc -Dcalloc=barebox_calloc \ -Dglob=barebox_glob -Dglobfree=barebox_globfree \ -Dioctl=barebox_ioctl -Dfstat=barebox_fstat \ -Dopendir=barebox_opendir -Dreaddir=barebox_readdir \ - -Dclosedir=barebox_closedir \ + -Dclosedir=barebox_closedir -Dreadlink=barebox_readlink \ -Doptarg=barebox_optarg -Doptind=barebox_optind machdirs := $(patsubst %,arch/sandbox/mach-%/,$(machine-y)) diff --git a/arch/sandbox/board/poweroff.c b/arch/sandbox/board/poweroff.c index 5072b756e1..8ce739af72 100644 --- a/arch/sandbox/board/poweroff.c +++ b/arch/sandbox/board/poweroff.c @@ -19,11 +19,24 @@ static struct restart_handler rst_hang = { .restart = sandbox_rst_hang }; +static void sandbox_rst_reexec(struct restart_handler *rst) +{ + linux_reexec(); +} + +static struct restart_handler rst_reexec = { + .name = "reexec", .priority = 200, + .restart = sandbox_rst_reexec, +}; + static int poweroff_register_feature(void) { poweroff_handler_register_fn(sandbox_poweroff); restart_handler_register(&rst_hang); + if (IS_ENABLED(CONFIG_SANDBOX_REEXEC)) + restart_handler_register(&rst_reexec); + return 0; } coredevice_initcall(poweroff_register_feature); diff --git a/arch/sandbox/mach-sandbox/include/mach/linux.h b/arch/sandbox/mach-sandbox/include/mach/linux.h index f0a3a7b510..1ab48e52a0 100644 --- a/arch/sandbox/mach-sandbox/include/mach/linux.h +++ b/arch/sandbox/mach-sandbox/include/mach/linux.h @@ -18,6 +18,7 @@ off_t linux_lseek(int fildes, off_t offset); int linux_tstc(int fd); void __attribute__((noreturn)) linux_exit(void); void linux_hang(void); +void linux_reexec(void); int linux_execve(const char * filename, char *const argv[], char *const envp[]); diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c index bbab3bd231..9d59418136 100644 --- a/arch/sandbox/os/common.c +++ b/arch/sandbox/os/common.c @@ -44,6 +44,8 @@ #include #include +#define DELETED_OFFSET (sizeof(" (deleted)") - 1) + void __sanitizer_set_death_callback(void (*callback)(void)); int sdl_xres; @@ -122,6 +124,31 @@ void __attribute__((noreturn)) linux_exit(void) exit(0); } +static char **saved_argv; + +void linux_reexec(void) +{ + char buf[4097]; + ssize_t ret; + + cookmode(); + + /* we must follow the symlink, so we can exec an updated executable */ + ret = readlink("/proc/self/exe", buf, sizeof(buf) - 1); + if (0 < ret && ret < sizeof(buf) - 1) { + buf[ret] = '\0'; + execv(buf, saved_argv); + if (!strcmp(&buf[ret - DELETED_OFFSET], " (deleted)")) { + printf("barebox image on disk changed. Loading new.\n"); + buf[ret - DELETED_OFFSET] = '\0'; + execv(buf, saved_argv); + } + } + + printf("exec(%s) failed: %d\n", buf, errno); + /* falls through to generic hang() */ +} + void linux_hang(void) { cookmode(); @@ -130,7 +157,7 @@ void linux_hang(void) int linux_open(const char *filename, int readwrite) { - return open(filename, readwrite ? O_RDWR : O_RDONLY); + return open(filename, (readwrite ? O_RDWR : O_RDONLY) | O_CLOEXEC); } int linux_read(int fd, void *buf, size_t count) @@ -220,10 +247,10 @@ extern void mem_malloc_init(void *start, void *end); extern char * strsep_unescaped(char **s, const char *ct); -static int add_image(char *str, char *devname_template, int *devname_number) +static int add_image(const char *_str, char *devname_template, int *devname_number) { struct hf_info *hf = malloc(sizeof(struct hf_info)); - char *filename, *devname; + char *str, *filename, *devname; char tmp[16]; int readonly = 0; struct stat s; @@ -233,6 +260,8 @@ static int add_image(char *str, char *devname_template, int *devname_number) if (!hf) return -1; + str = strdup(_str); + filename = strsep_unescaped(&str, ","); while ((opt = strsep_unescaped(&str, ","))) { if (!strcmp(opt, "ro")) @@ -252,7 +281,7 @@ static int add_image(char *str, char *devname_template, int *devname_number) printf("add %s backed by file %s%s\n", devname, filename, readonly ? "(ro)" : ""); - fd = open(filename, readonly ? O_RDONLY : O_RDWR); + fd = open(filename, (readonly ? O_RDONLY : O_RDWR) | O_CLOEXEC); hf->fd = fd; hf->filename = filename; @@ -303,7 +332,7 @@ static int add_dtb(const char *file) void *dtb = NULL; int fd; - fd = open(file, O_RDONLY); + fd = open(file, O_RDONLY | O_CLOEXEC); if (fd < 0) { perror("open"); goto err_out; @@ -363,6 +392,8 @@ int main(int argc, char *argv[]) __sanitizer_set_death_callback(cookmode); #endif + saved_argv = argv; + while (1) { option_index = 0; opt = getopt_long(argc, argv, optstring, @@ -434,7 +465,7 @@ int main(int argc, char *argv[]) exit(1); break; case 'O': - fd = open(optarg, O_WRONLY); + fd = open(optarg, O_WRONLY | O_CLOEXEC); if (fd < 0) { perror("open"); exit(1); @@ -443,7 +474,7 @@ int main(int argc, char *argv[]) barebox_register_console(-1, fd); break; case 'I': - fd = open(optarg, O_RDWR); + fd = open(optarg, O_RDWR | O_CLOEXEC); if (fd < 0) { perror("open"); exit(1); @@ -459,7 +490,7 @@ int main(int argc, char *argv[]) } /* open stdout file */ - fd = open(aux + 1, O_WRONLY); + fd = open(aux + 1, O_WRONLY | O_CLOEXEC); if (fd < 0) { perror("open stdout"); exit(1); @@ -467,7 +498,7 @@ int main(int argc, char *argv[]) /* open stdin file */ aux = strndup(optarg, aux - optarg); - fd2 = open(aux, O_RDWR); + fd2 = open(aux, O_RDWR | O_CLOEXEC); if (fd2 < 0) { perror("open stdin"); exit(1); diff --git a/arch/sandbox/os/tap.c b/arch/sandbox/os/tap.c index 72b7fbb5ac..83b97ffd49 100644 --- a/arch/sandbox/os/tap.c +++ b/arch/sandbox/os/tap.c @@ -30,7 +30,7 @@ int tap_alloc(const char *dev) struct ifreq ifr; int fd, err; - if ((fd = open("/dev/net/tun", O_RDWR)) < 0) { + if ((fd = open("/dev/net/tun", O_RDWR | O_CLOEXEC)) < 0) { perror("could not open /dev/net/tun"); return -1; } -- cgit v1.2.3 From c8773d5c22a2d6ded9bb3060842f1f62bc5dd945 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Sep 2020 19:17:08 +0200 Subject: ls: align file size correctly on non-ARM 64-bit platforms CONFIG_CPU_64 is ARM-specific. Use the generic CONFIG_64BIT instead for aligning the file size. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- commands/ls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/ls.c b/commands/ls.c index 59163f678d..bedf2e1c42 100644 --- a/commands/ls.c +++ b/commands/ls.c @@ -15,7 +15,7 @@ /* * SIZELEN = strlen(itoa(MAX_LFS_FILESIZE)) + 1; */ -#ifdef CONFIG_CPU_64 +#ifdef CONFIG_64BIT #define SIZELEN 20 #else #define SIZELEN 14 -- cgit v1.2.3 From a1f6b4dbcdfd85c82e7ccd1e6be82264d16019ee Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Sep 2020 15:37:48 +0200 Subject: sandbox: hostfile: support registering images as barebox block devices While we can mount file systems on cdevs in barebox, partition table parsing only works for block devices. Allow for --image=argument,blkdev to try to mount an image as block device. This will fail for files that aren't of a multiple of the 512 byte block size. Host OS block devices are suitable for use as barebox block devices always, so that's the default unless overridden with a ,cdev suffix. The initcall level has been changed to occur after fs initcall level. This is required, because we can't have automounts without / mounted. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- arch/sandbox/Kconfig | 3 + arch/sandbox/board/hostfile.c | 116 +++++++++++++++++----- arch/sandbox/mach-sandbox/include/mach/hostfile.h | 1 + arch/sandbox/os/common.c | 15 ++- 4 files changed, 109 insertions(+), 26 deletions(-) diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig index b5213c662b..26011720df 100644 --- a/arch/sandbox/Kconfig +++ b/arch/sandbox/Kconfig @@ -7,6 +7,9 @@ config SANDBOX select ARCH_HAS_UBSAN_SANITIZE_ALL select HAVE_ARCH_KASAN select HAS_DMA + select BLOCK + select BLOCK_WRITE + select PARTITION_DISK default y config ARCH_TEXT_BASE diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c index 07287fc0b4..63530bd25e 100644 --- a/arch/sandbox/board/hostfile.c +++ b/arch/sandbox/board/hostfile.c @@ -16,6 +16,8 @@ #include #include +#include +#include #include #include #include @@ -27,14 +29,16 @@ #include struct hf_priv { - struct cdev cdev; + union { + struct block_device blk; + struct cdev cdev; + }; const char *filename; int fd; }; -static ssize_t hf_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags) +static ssize_t hf_read(struct hf_priv *priv, void *buf, size_t count, loff_t offset, ulong flags) { - struct hf_priv *priv= cdev->priv; int fd = priv->fd; if (linux_lseek(fd, offset) != offset) @@ -43,9 +47,8 @@ static ssize_t hf_read(struct cdev *cdev, void *buf, size_t count, loff_t offset return linux_read(fd, buf, count); } -static ssize_t hf_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags) +static ssize_t hf_write(struct hf_priv *priv, const void *buf, size_t count, loff_t offset, ulong flags) { - struct hf_priv *priv = cdev->priv; int fd = priv->fd; if (linux_lseek(fd, offset) != offset) @@ -54,6 +57,40 @@ static ssize_t hf_write(struct cdev *cdev, const void *buf, size_t count, loff_t return linux_write(fd, buf, count); } +static ssize_t hf_cdev_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags) +{ + return hf_read(cdev->priv, buf, count, offset, flags); +} + +static ssize_t hf_cdev_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags) +{ + return hf_write(cdev->priv, buf, count, offset, flags); +} + +static struct cdev_operations hf_cdev_ops = { + .read = hf_cdev_read, + .write = hf_cdev_write, +}; + +static int hf_blk_read(struct block_device *blk, void *buf, int block, int num_blocks) +{ + ssize_t ret = hf_read(container_of(blk, struct hf_priv, blk), buf, + num_blocks << SECTOR_SHIFT, block << SECTOR_SHIFT, 0); + return ret > 0 ? 0 : ret; +} + +static int hf_blk_write(struct block_device *blk, const void *buf, int block, int num_blocks) +{ + ssize_t ret = hf_write(container_of(blk, struct hf_priv, blk), buf, + num_blocks << SECTOR_SHIFT, block << SECTOR_SHIFT, 0); + return ret > 0 ? 0 : ret; +} + +static struct block_device_ops hf_blk_ops = { + .read = hf_blk_read, + .write = hf_blk_write, +}; + static void hf_info(struct device_d *dev) { struct hf_priv *priv = dev->priv; @@ -61,29 +98,28 @@ static void hf_info(struct device_d *dev) printf("file: %s\n", priv->filename); } -static struct cdev_operations hf_fops = { - .read = hf_read, - .write = hf_write, -}; - static int hf_probe(struct device_d *dev) { + struct device_node *np = dev->device_node; struct hf_priv *priv = xzalloc(sizeof(*priv)); struct resource *res; + struct cdev *cdev; + bool is_blockdev; + resource_size_t size; int err; res = dev_get_resource(dev, IORESOURCE_MEM, 0); if (IS_ERR(res)) return PTR_ERR(res); - priv->cdev.size = resource_size(res); + size = resource_size(res); - if (!dev->device_node) + if (!np) return -ENODEV; - of_property_read_u32(dev->device_node, "barebox,fd", &priv->fd); + of_property_read_u32(np, "barebox,fd", &priv->fd); - err = of_property_read_string(dev->device_node, "barebox,filename", + err = of_property_read_string(np, "barebox,filename", &priv->filename); if (err) return err; @@ -94,20 +130,47 @@ static int hf_probe(struct device_d *dev) if (priv->fd < 0) return priv->fd; - priv->cdev.name = dev->device_node->name; - priv->cdev.dev = dev; - priv->cdev.ops = &hf_fops; - priv->cdev.priv = priv; - dev->info = hf_info; dev->priv = priv; - err = devfs_create(&priv->cdev); - if (err) - return err; + is_blockdev = of_property_read_bool(np, "barebox,blockdev"); + + cdev = is_blockdev ? &priv->blk.cdev : &priv->cdev; + + cdev->device_node = np; - of_parse_partitions(&priv->cdev, dev->device_node); - of_partitions_register_fixup(&priv->cdev); + if (is_blockdev) { + cdev->name = np->name; + priv->blk.dev = dev; + priv->blk.ops = &hf_blk_ops; + priv->blk.blockbits = SECTOR_SHIFT; + priv->blk.num_blocks = size / SECTOR_SIZE; + + err = blockdevice_register(&priv->blk); + if (err) + return err; + + err = parse_partition_table(&priv->blk); + if (err) + dev_warn(dev, "No partition table found\n"); + + dev_info(dev, "registered as block device\n"); + } else { + cdev->name = np->name; + cdev->dev = dev; + cdev->ops = &hf_cdev_ops; + cdev->size = size; + cdev->priv = priv; + + err = devfs_create(cdev); + if (err) + return err; + + dev_info(dev, "registered as character device\n"); + } + + of_parse_partitions(cdev, np); + of_partitions_register_fixup(cdev); return 0; } @@ -125,7 +188,7 @@ static struct driver_d hf_drv = { .of_compatible = DRV_OF_COMPAT(hostfile_dt_ids), .probe = hf_probe, }; -coredevice_platform_driver(hf_drv); +device_platform_driver(hf_drv); static int of_hostfile_fixup(struct device_node *root, void *ctx) { @@ -155,6 +218,9 @@ static int of_hostfile_fixup(struct device_node *root, void *ctx) ret = of_property_write_string(node, "barebox,filename", hf->filename); + if (hf->is_blockdev) + ret = of_property_write_bool(node, "barebox,blockdev", true); + return ret; } diff --git a/arch/sandbox/mach-sandbox/include/mach/hostfile.h b/arch/sandbox/mach-sandbox/include/mach/hostfile.h index e2f44c4f7b..c3f9af97c4 100644 --- a/arch/sandbox/mach-sandbox/include/mach/hostfile.h +++ b/arch/sandbox/mach-sandbox/include/mach/hostfile.h @@ -7,6 +7,7 @@ struct hf_info { unsigned long long size; const char *devname; const char *filename; + unsigned int is_blockdev:1; }; int barebox_register_filedev(struct hf_info *hf); diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c index 9d59418136..d0addef5af 100644 --- a/arch/sandbox/os/common.c +++ b/arch/sandbox/os/common.c @@ -252,7 +252,7 @@ static int add_image(const char *_str, char *devname_template, int *devname_numb struct hf_info *hf = malloc(sizeof(struct hf_info)); char *str, *filename, *devname; char tmp[16]; - int readonly = 0; + int readonly = 0, cdev = 0, blkdev = 0; struct stat s; char *opt; int fd, ret; @@ -266,6 +266,10 @@ static int add_image(const char *_str, char *devname_template, int *devname_numb while ((opt = strsep_unescaped(&str, ","))) { if (!strcmp(opt, "ro")) readonly = 1; + if (!strcmp(opt, "cdev")) + cdev = 1; + if (!strcmp(opt, "blkdev")) + blkdev = 1; } /* parses: "devname=filename" */ @@ -284,6 +288,7 @@ static int add_image(const char *_str, char *devname_template, int *devname_numb fd = open(filename, (readonly ? O_RDONLY : O_RDWR) | O_CLOEXEC); hf->fd = fd; hf->filename = filename; + hf->is_blockdev = blkdev; if (fd < 0) { perror("open"); @@ -303,6 +308,8 @@ static int add_image(const char *_str, char *devname_template, int *devname_numb perror("ioctl"); goto err_out; } + if (!cdev) + hf->is_blockdev = 1; } if (hf->size <= SIZE_MAX) hf->base = (unsigned long)mmap(NULL, hf->size, @@ -314,6 +321,12 @@ static int add_image(const char *_str, char *devname_template, int *devname_numb if (hf->base == (unsigned long)MAP_FAILED) printf("warning: mmapping %s failed: %s\n", filename, strerror(errno)); + if (blkdev && hf->size % 512 != 0) { + printf("warning: registering %s as block device failed: invalid block size\n", + filename); + return -EINVAL; + } + ret = barebox_register_filedev(hf); if (ret) goto err_out; -- cgit v1.2.3 From a49cf5c14d050bc37f0d12f2623c86a2d383e9b7 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Sep 2020 17:27:10 +0200 Subject: boot: ignore all spaces between boot targets Boot targets are split by space. strsep unlike strtok(_r) returns an empty string for each pair of consecutive delimiters. Ignore this case. Note that this changes behavior: previously both boot '' global.boot.default= boot were identical to boot /env/boot With this change, this is no longer the case. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- commands/boot.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/commands/boot.c b/commands/boot.c index ad2d83a179..d7795bde72 100644 --- a/commands/boot.c +++ b/commands/boot.c @@ -76,6 +76,8 @@ static int do_boot(int argc, char *argv[]) entries = bootentries_alloc(); while ((name = next(&handle)) != NULL) { + if (!*name) + continue; ret = bootentry_create_from_name(entries, name); if (ret <= 0) printf("Nothing bootable found on '%s'\n", name); -- cgit v1.2.3 From a2ed66346ba87029541229a73fc018d5c402dec3 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Sep 2020 17:27:11 +0200 Subject: blspec: devicetree-overlay: don't warn on multiple delimiting spaces strsep unlike strtok(_r) returns an empty string for each pair of consecutive delimiters. blspec_apply_oftree_overlay is not equipped to handle an empty string and will attempt treating "abspath/" as device tree file. Explicitly check for empty strings, so this doesn't happen. Cc: Michael Tretter Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- common/blspec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/blspec.c b/common/blspec.c index 9e1036c834..ed66352d11 100644 --- a/common/blspec.c +++ b/common/blspec.c @@ -109,8 +109,11 @@ static void blspec_apply_oftree_overlays(const char *overlays, sep = freep = xstrdup(overlays); - while ((overlay = strsep(&sep, " "))) + while ((overlay = strsep(&sep, " "))) { + if (!*overlay) + continue; blspec_apply_oftree_overlay(overlay, abspath, dryrun); + } free(freep); } -- cgit v1.2.3 From da60d8b1757c8897ae884ef8ed08d094d7c274fb Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 15 Sep 2020 10:51:17 +0200 Subject: ARM: dts: beaglebone: Remove unnecessary tps65217.dtsi tps65217.dtsi should be used from the upstream dts sources instead. Signed-off-by: Sascha Hauer --- arch/arm/dts/tps65217.dtsi | 56 ---------------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 arch/arm/dts/tps65217.dtsi diff --git a/arch/arm/dts/tps65217.dtsi b/arch/arm/dts/tps65217.dtsi deleted file mode 100644 index a63272422d..0000000000 --- a/arch/arm/dts/tps65217.dtsi +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -/* - * Integrated Power Management Chip - * http://www.ti.com/lit/ds/symlink/tps65217.pdf - */ - -&tps { - compatible = "ti,tps65217"; - - regulators { - #address-cells = <1>; - #size-cells = <0>; - - dcdc1_reg: regulator@0 { - reg = <0>; - regulator-compatible = "dcdc1"; - }; - - dcdc2_reg: regulator@1 { - reg = <1>; - regulator-compatible = "dcdc2"; - }; - - dcdc3_reg: regulator@2 { - reg = <2>; - regulator-compatible = "dcdc3"; - }; - - ldo1_reg: regulator@3 { - reg = <3>; - regulator-compatible = "ldo1"; - }; - - ldo2_reg: regulator@4 { - reg = <4>; - regulator-compatible = "ldo2"; - }; - - ldo3_reg: regulator@5 { - reg = <5>; - regulator-compatible = "ldo3"; - }; - - ldo4_reg: regulator@6 { - reg = <6>; - regulator-compatible = "ldo4"; - }; - }; -}; -- cgit v1.2.3 From d965771ea56f6291c8e50bd194ac21427af759a5 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 15 Sep 2020 08:57:14 +0200 Subject: arm: Add prototypes for functions called from assembly Some functions are called from assembly only. There's no prototype for them so this leads to -Wmissing-prototypes warnings. Add a prototype right aboce the functions to avoid these warnings. Signed-off-by: Sascha Hauer --- arch/arm/boards/edb93xx/flash_cfg.c | 3 +++ arch/arm/boards/edb93xx/pll_cfg.c | 3 +++ arch/arm/boards/edb93xx/sdram_cfg.c | 3 +++ arch/arm/mach-ep93xx/header.c | 2 ++ 4 files changed, 11 insertions(+) diff --git a/arch/arm/boards/edb93xx/flash_cfg.c b/arch/arm/boards/edb93xx/flash_cfg.c index 6b742f967c..8400db69de 100644 --- a/arch/arm/boards/edb93xx/flash_cfg.c +++ b/arch/arm/boards/edb93xx/flash_cfg.c @@ -11,6 +11,9 @@ SMC_BCR_BLE | 2 << SMC_BCR_WST2_SHIFT | \ 1 << SMC_BCR_MW_SHIFT) +/* Called from assembly */ +void flash_cfg(void); + void flash_cfg(void) { struct smc_regs *smc = (struct smc_regs *)SMC_BASE; diff --git a/arch/arm/boards/edb93xx/pll_cfg.c b/arch/arm/boards/edb93xx/pll_cfg.c index 1f03acf915..1a1c01aba2 100644 --- a/arch/arm/boards/edb93xx/pll_cfg.c +++ b/arch/arm/boards/edb93xx/pll_cfg.c @@ -9,6 +9,9 @@ #include "pll_cfg.h" #include "early_udelay.h" +/* Called from assembly */ +void pll_cfg(void); + void pll_cfg(void) { struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE; diff --git a/arch/arm/boards/edb93xx/sdram_cfg.c b/arch/arm/boards/edb93xx/sdram_cfg.c index a9f591f197..3cee834910 100644 --- a/arch/arm/boards/edb93xx/sdram_cfg.c +++ b/arch/arm/boards/edb93xx/sdram_cfg.c @@ -17,6 +17,9 @@ static void precharge_all_banks(void); static void setup_refresh_timer(void); static void program_mode_registers(void); +/* Called from assembly */ +void sdram_cfg(void); + void sdram_cfg(void) { struct sdram_regs *sdram = (struct sdram_regs *)SDRAM_BASE; diff --git a/arch/arm/mach-ep93xx/header.c b/arch/arm/mach-ep93xx/header.c index 4e6a2e57c8..a9dde2d8b0 100644 --- a/arch/arm/mach-ep93xx/header.c +++ b/arch/arm/mach-ep93xx/header.c @@ -2,6 +2,8 @@ #include #include +void go(void); + void __naked __section(.flash_header_start) go(void) { barebox_arm_head(); -- cgit v1.2.3 From 31918d7f933ffaa116d3457e2a3ad76744db60d5 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 15 Sep 2020 08:57:14 +0200 Subject: openrisc: Add prototypes for functions called from assembly Some functions are called from assembly only. There's no prototype for them so this leads to -Wmissing-prototypes warnings. Add a prototype right aboce the functions to avoid these warnings. Signed-off-by: Sascha Hauer --- arch/openrisc/cpu/exceptions.c | 3 +++ arch/openrisc/lib/board.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/arch/openrisc/cpu/exceptions.c b/arch/openrisc/cpu/exceptions.c index d01fbfbb1c..4c52feb51c 100644 --- a/arch/openrisc/cpu/exceptions.c +++ b/arch/openrisc/cpu/exceptions.c @@ -69,6 +69,9 @@ static void exception_hang(int vect) hang(); } +/* Called from assembly */ +void exception_handler(int vect); + void exception_handler(int vect) { int exception = vect >> 8; diff --git a/arch/openrisc/lib/board.c b/arch/openrisc/lib/board.c index 67ea96fc02..9591120fee 100644 --- a/arch/openrisc/lib/board.c +++ b/arch/openrisc/lib/board.c @@ -19,6 +19,9 @@ #include #include +/* Called from assembly */ +void openrisc_start_barebox(void); + void __noreturn openrisc_start_barebox(void) { mem_malloc_init((void *)(OPENRISC_SOPC_TEXT_BASE - MALLOC_SIZE), -- cgit v1.2.3 From 69c86ae85ae6f2018e887a33bf2d3bd184071b79 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 15 Sep 2020 14:15:53 +0200 Subject: ARM: tx28: provide header file with function prototype base_board_init() doesn't have a prototype anywhere, add a header file for it. Signed-off-by: Sascha Hauer --- arch/arm/boards/karo-tx28/tx28-stk5.c | 2 ++ arch/arm/boards/karo-tx28/tx28.c | 4 ++-- arch/arm/boards/karo-tx28/tx28.h | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 arch/arm/boards/karo-tx28/tx28.h diff --git a/arch/arm/boards/karo-tx28/tx28-stk5.c b/arch/arm/boards/karo-tx28/tx28-stk5.c index c9b947953b..56211d7a3a 100644 --- a/arch/arm/boards/karo-tx28/tx28-stk5.c +++ b/arch/arm/boards/karo-tx28/tx28-stk5.c @@ -22,6 +22,8 @@ #include #include +#include "tx28.h" + static struct mxs_mci_platform_data mci_pdata = { .caps = MMC_CAP_4_BIT_DATA, .voltages = MMC_VDD_32_33 | MMC_VDD_33_34, /* fixed to 3.3 V */ diff --git a/arch/arm/boards/karo-tx28/tx28.c b/arch/arm/boards/karo-tx28/tx28.c index 52f74b5f36..8bd2252410 100644 --- a/arch/arm/boards/karo-tx28/tx28.c +++ b/arch/arm/boards/karo-tx28/tx28.c @@ -15,6 +15,8 @@ #include #include +#include "tx28.h" + /* setup the CPU card internal signals */ static const uint32_t tx28_pad_setup[] = { /* NAND interface */ @@ -61,8 +63,6 @@ static const uint32_t tx28_pad_setup[] = { }; -extern void base_board_init(void); - static int tx28_devices_init(void) { int i; diff --git a/arch/arm/boards/karo-tx28/tx28.h b/arch/arm/boards/karo-tx28/tx28.h new file mode 100644 index 0000000000..5fb1e13412 --- /dev/null +++ b/arch/arm/boards/karo-tx28/tx28.h @@ -0,0 +1,3 @@ + +void base_board_init(void); + -- cgit v1.2.3 From 804bee7ff231fe2a1ad7a7b42dcebedd2d57d45d Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 15 Sep 2020 14:17:36 +0200 Subject: ARM: tegra20-colibri-iris: drop regulators node Grouping the fixed regulators in an extra regulators node is deprecated. Move the regulators up one level and drop the reg properties to avoid dtc warnings. Signed-off-by: Sascha Hauer --- arch/arm/dts/tegra20-colibri-iris.dts | 36 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/arch/arm/dts/tegra20-colibri-iris.dts b/arch/arm/dts/tegra20-colibri-iris.dts index 9c615816ca..da5ef7a7e7 100644 --- a/arch/arm/dts/tegra20-colibri-iris.dts +++ b/arch/arm/dts/tegra20-colibri-iris.dts @@ -75,26 +75,22 @@ vqmmc-supply = <&vcc_sd_reg>; }; - regulators { - regulator@0 { - compatible = "regulator-fixed"; - reg = <0>; - regulator-name = "usb_host_vbus"; - regulator-min-microvolt = <5000000>; - regulator-max-microvolt = <5000000>; - regulator-boot-on; - regulator-always-on; - gpio = <&gpio TEGRA_GPIO(W, 2) GPIO_ACTIVE_HIGH>; - }; + regulator_usb_host_vbus { + compatible = "regulator-fixed"; + regulator-name = "usb_host_vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-boot-on; + regulator-always-on; + gpio = <&gpio TEGRA_GPIO(W, 2) GPIO_ACTIVE_HIGH>; + }; - vcc_sd_reg: regulator@1 { - compatible = "regulator-fixed"; - reg = <1>; - regulator-name = "vcc_sd"; - regulator-min-microvolt = <3300000>; - regulator-max-microvolt = <3300000>; - regulator-boot-on; - regulator-always-on; - }; + vcc_sd_reg: regulator_vcc_sd { + compatible = "regulator-fixed"; + regulator-name = "vcc_sd"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-boot-on; + regulator-always-on; }; }; -- cgit v1.2.3 From 6d0c96cceb8aaa57f52971aae6ff237e4b36ba33 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 15 Sep 2020 14:18:55 +0200 Subject: ARM: versatile: Remove unused function vpb_clk_create() is unused in the codebase. Remove it. Signed-off-by: Sascha Hauer --- arch/arm/mach-versatile/core.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c index 7c6e9523a2..006d4e7231 100644 --- a/arch/arm/mach-versatile/core.c +++ b/arch/arm/mach-versatile/core.c @@ -75,19 +75,6 @@ void clk_disable(struct clk *clk) } EXPORT_SYMBOL(clk_disable); -/* Create a clock structure with the given name */ -int vpb_clk_create(struct clk *clk, const char *dev_id) -{ - struct clk_lookup *clkdev; - - clkdev = clkdev_alloc(clk, NULL, dev_id); - if (!clkdev) - return -ENOMEM; - - clkdev_add(clkdev); - return 0; -} - /* 1Mhz / 256 */ #define TIMER_FREQ (1000000/256) -- cgit v1.2.3 From 0eecc6c3ef48474687b01be366789a3f9305e1e6 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 15 Sep 2020 08:54:15 +0200 Subject: openrisc: Add missing includes Add missing includes to avoid -Wmissing-prototypes warnings. Signed-off-by: Sascha Hauer --- arch/openrisc/cpu/cache.c | 1 + arch/openrisc/cpu/exceptions.c | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/openrisc/cpu/cache.c b/arch/openrisc/cpu/cache.c index 1da2380c03..db6403634a 100644 --- a/arch/openrisc/cpu/cache.c +++ b/arch/openrisc/cpu/cache.c @@ -17,6 +17,7 @@ #include #include #include +#include void flush_dcache_range(unsigned long addr, unsigned long stop) { diff --git a/arch/openrisc/cpu/exceptions.c b/arch/openrisc/cpu/exceptions.c index 4c52feb51c..c69ceafe80 100644 --- a/arch/openrisc/cpu/exceptions.c +++ b/arch/openrisc/cpu/exceptions.c @@ -16,6 +16,7 @@ #include #include +#include static const char * const excp_table[] = { "Unknown exception", -- cgit v1.2.3 From 646a2d8c0f9fa054c3d2eba3c4531a57e372ca5a Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 15 Sep 2020 08:56:11 +0200 Subject: openrisc: Make locally used functions static Make only locally used functions static to avoid -Wmissing-prototypes warnings. Signed-off-by: Sascha Hauer --- arch/openrisc/cpu/cache.c | 2 +- arch/openrisc/lib/cpuinfo.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/openrisc/cpu/cache.c b/arch/openrisc/cpu/cache.c index db6403634a..a124d6612c 100644 --- a/arch/openrisc/cpu/cache.c +++ b/arch/openrisc/cpu/cache.c @@ -131,7 +131,7 @@ void icache_disable(void) mtspr(SPR_SR, mfspr(SPR_SR) & ~SPR_SR_ICE); } -int cache_init(void) +static int cache_init(void) { if (mfspr(SPR_UPR) & SPR_UPR_ICP) { icache_disable(); diff --git a/arch/openrisc/lib/cpuinfo.c b/arch/openrisc/lib/cpuinfo.c index 4c52a65421..d94178ea59 100644 --- a/arch/openrisc/lib/cpuinfo.c +++ b/arch/openrisc/lib/cpuinfo.c @@ -95,7 +95,7 @@ static void cpu_implementation(ulong vr2, char *string) } } -int checkcpu(void) +static int checkcpu(void) { ulong upr = mfspr(SPR_UPR); ulong vr = mfspr(SPR_VR); -- cgit v1.2.3 From a7e01ac1499787b55d6733b7abdd76ac5ab67c5e Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 15 Sep 2020 14:21:08 +0200 Subject: scripts: tegra: Add missing include Include context.h to get the prototypes for the functions defined in context.c Signed-off-by: Sascha Hauer --- scripts/tegra/context.c | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/tegra/context.c b/scripts/tegra/context.c index 9d2fb27dc9..47e65d570b 100644 --- a/scripts/tegra/context.c +++ b/scripts/tegra/context.c @@ -17,6 +17,7 @@ #include "cbootimage.h" #include "data_layout.h" #include "set.h" +#include "context.h" void cleanup_context(build_image_context *context) -- cgit v1.2.3 From 9f22aed2e11c704a8762ed370524b5fc85e11e75 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 15 Sep 2020 14:22:48 +0200 Subject: ARM: zync: Fix include path When building out of tree we must explicitly include an absolute path starting with $(srctree) as a relative path would be relative to $(objtree). Signed-off-by: Sascha Hauer --- images/Makefile.zynq | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/Makefile.zynq b/images/Makefile.zynq index 062496ac7d..b00e748697 100644 --- a/images/Makefile.zynq +++ b/images/Makefile.zynq @@ -3,7 +3,7 @@ # zynqcfg_cpp_flags = -Wp,-MD,$(depfile) -nostdinc -x assembler-with-cpp \ - -I arch/arm/mach-zynq/include + -I $(srctree)/arch/arm/mach-zynq/include zynqcfg-tmp = $(subst $(comma),_,$(dot-target).zynqcfg.tmp) -- cgit v1.2.3 From 11359b39028689c0f9893645c0feb80ab7052baf Mon Sep 17 00:00:00 2001 From: Roland Hieber Date: Tue, 15 Sep 2020 13:52:47 +0200 Subject: mci: bcm2835: depend on sdhci The driver uses functions defined in sdhci.o, and will fail to build otherwise: drivers/mci/mci-bcm2835.o: in function `bcm2835_mci_request': drivers/mci/mci-bcm2835.c:134: undefined reference to `sdhci_set_cmd_xfer_mode' arm-v5te-linux-gnueabi-ld: drivers/mci/mci-bcm2835.c:169: undefined reference to `sdhci_read_response' arm-v5te-linux-gnueabi-ld: drivers/mci/mci-bcm2835.c:175: undefined reference to `sdhci_transfer_data' Fixes: f8dffc9338dc2c7ae830 (2019-11-19, "mci: bcm2835: Use sdhci_set_cmd_xfer_mode()") Signed-off-by: Roland Hieber Signed-off-by: Sascha Hauer --- drivers/mci/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig index f7dc5c5089..09c0569286 100644 --- a/drivers/mci/Kconfig +++ b/drivers/mci/Kconfig @@ -69,6 +69,7 @@ config MCI_S3C config MCI_BCM283X bool "MCI support for BCM283X" depends on ARCH_BCM283X || COMPILE_TEST + select MCI_SDHCI config MCI_BCM283X_SDHOST bool "BCM283X sdhost" -- cgit v1.2.3 From b8ae5933bb138ad156af38fdb3226e14dc762f8f Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Tue, 2 Jun 2020 09:57:55 +0200 Subject: common: restart: number unnamed restart handlers Follow-up commit allows referencing specific restart handler by name. Restart handlers default to "default" as name when none is given. Number them sequentially instead. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- common/restart.c | 4 +++- include/restart.h | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/common/restart.c b/common/restart.c index b19ae54657..dd15c8d5c3 100644 --- a/common/restart.c +++ b/common/restart.c @@ -19,6 +19,7 @@ #include static LIST_HEAD(restart_handler_list); +static unsigned resetidx; /** * restart_handler_register() - register a handler for restarting the system @@ -31,7 +32,7 @@ static LIST_HEAD(restart_handler_list); int restart_handler_register(struct restart_handler *rst) { if (!rst->name) - rst->name = RESTART_DEFAULT_NAME; + rst->name = basprintf("reset%u", resetidx); if (!rst->priority) rst->priority = RESTART_DEFAULT_PRIORITY; @@ -40,6 +41,7 @@ int restart_handler_register(struct restart_handler *rst) pr_debug("registering restart handler \"%s\" with priority %d\n", rst->name, rst->priority); + resetidx++; return 0; } diff --git a/include/restart.h b/include/restart.h index 7ec0910e94..6880b03b93 100644 --- a/include/restart.h +++ b/include/restart.h @@ -15,7 +15,6 @@ int restart_handler_register(struct restart_handler *); int restart_handler_register_fn(void (*restart_fn)(struct restart_handler *)); #define RESTART_DEFAULT_PRIORITY 100 -#define RESTART_DEFAULT_NAME "default" unsigned int of_get_restart_priority(struct device_node *node); -- cgit v1.2.3 From 119d453c0b40d4a477781626f944d74d439956da Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Tue, 2 Jun 2020 09:57:56 +0200 Subject: restart: give all restart handlers a descriptive name With incoming changes to choose a specific reset method, give all currently unnamed "default" reset handlers a name: - soc reset via SoC-specific means - soc-wdt reset via SoC watchdog timer - vector reset via jump to reset vector - efi reset via EFI firmware Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- arch/arm/mach-at91/at91rm9200_time.c | 2 +- arch/arm/mach-at91/at91sam9260.c | 2 +- arch/arm/mach-at91/at91sam9261.c | 2 +- arch/arm/mach-at91/at91sam9263.c | 2 +- arch/arm/mach-at91/at91sam9g45.c | 2 +- arch/arm/mach-at91/at91sam9n12.c | 2 +- arch/arm/mach-at91/at91sam9x5.c | 2 +- arch/arm/mach-at91/sama5d3.c | 2 +- arch/arm/mach-at91/sama5d4.c | 2 +- arch/arm/mach-clps711x/reset.c | 2 +- arch/arm/mach-davinci/time.c | 2 +- arch/arm/mach-ep93xx/clocksource.c | 2 +- arch/arm/mach-highbank/reset.c | 2 +- arch/arm/mach-mvebu/armada-370-xp.c | 2 +- arch/arm/mach-mvebu/dove.c | 2 +- arch/arm/mach-mvebu/kirkwood.c | 2 +- arch/arm/mach-mxs/soc-imx23.c | 2 +- arch/arm/mach-mxs/soc-imx28.c | 2 +- arch/arm/mach-nomadik/reset.c | 2 +- arch/arm/mach-omap/am33xx_generic.c | 2 +- arch/arm/mach-omap/omap3_generic.c | 2 +- arch/arm/mach-omap/omap4_generic.c | 2 +- arch/arm/mach-pxa/common.c | 2 +- arch/arm/mach-rockchip/rk3188.c | 2 +- arch/arm/mach-rockchip/rk3288.c | 2 +- arch/arm/mach-samsung/generic.c | 2 +- arch/arm/mach-socfpga/arria10-generic.c | 2 +- arch/arm/mach-socfpga/cyclone5-reset-manager.c | 2 +- arch/arm/mach-tegra/tegra20-pmc.c | 2 +- arch/arm/mach-versatile/core.c | 2 +- arch/arm/mach-vexpress/reset.c | 2 +- arch/arm/mach-zynq/zynq.c | 2 +- arch/kvx/cpu/reset.c | 2 +- arch/mips/mach-ar231x/ar231x_reset.c | 2 +- arch/mips/mach-ath79/reset.c | 2 +- arch/mips/mach-bcm47xx/reset.c | 2 +- arch/mips/mach-loongson/loongson1_reset.c | 2 +- arch/mips/mach-malta/reset.c | 2 +- arch/nios2/cpu/cpu.c | 2 +- arch/openrisc/cpu/cpu.c | 2 +- arch/powerpc/mach-mpc5xxx/cpu.c | 2 +- arch/powerpc/mach-mpc85xx/cpu.c | 2 +- common/efi/efi.c | 2 +- common/restart.c | 5 ++++- include/restart.h | 3 ++- 45 files changed, 49 insertions(+), 45 deletions(-) diff --git a/arch/arm/mach-at91/at91rm9200_time.c b/arch/arm/mach-at91/at91rm9200_time.c index 975cd956c9..f89983fe63 100644 --- a/arch/arm/mach-at91/at91rm9200_time.c +++ b/arch/arm/mach-at91/at91rm9200_time.c @@ -88,7 +88,7 @@ static void __noreturn at91rm9200_restart_soc(struct restart_handler *rst) static int restart_register_feature(void) { - restart_handler_register_fn(at91rm9200_restart_soc); + restart_handler_register_fn("soc-wdt", at91rm9200_restart_soc); return 0; } diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c index 56327a2c47..fdd8ea014e 100644 --- a/arch/arm/mach-at91/at91sam9260.c +++ b/arch/arm/mach-at91/at91sam9260.c @@ -243,7 +243,7 @@ static void at91sam9260_initialize(void) at91_add_pit(AT91SAM9260_BASE_PIT); at91_add_sam9_smc(DEVICE_ID_SINGLE, AT91SAM9260_BASE_SMC, 0x200); - restart_handler_register_fn(at91sam9260_restart); + restart_handler_register_fn("soc", at91sam9260_restart); } static int at91sam9260_setup(void) diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c index 4abc556354..0465ed9524 100644 --- a/arch/arm/mach-at91/at91sam9261.c +++ b/arch/arm/mach-at91/at91sam9261.c @@ -235,7 +235,7 @@ static void at91sam9261_initialize(void) at91_add_pit(AT91SAM9261_BASE_PIT); at91_add_sam9_smc(DEVICE_ID_SINGLE, AT91SAM9261_BASE_SMC, 0x200); - restart_handler_register_fn(at91sam9261_restart); + restart_handler_register_fn("soc", at91sam9261_restart); } static int at91sam9261_setup(void) diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c index 690f8e06bb..dc5dddfb64 100644 --- a/arch/arm/mach-at91/at91sam9263.c +++ b/arch/arm/mach-at91/at91sam9263.c @@ -256,7 +256,7 @@ static void at91sam9263_initialize(void) at91_add_sam9_smc(0, AT91SAM9263_BASE_SMC0, 0x200); at91_add_sam9_smc(1, AT91SAM9263_BASE_SMC1, 0x200); - restart_handler_register_fn(at91sam9263_restart); + restart_handler_register_fn("soc", at91sam9263_restart); } static int at91sam9263_setup(void) diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c index 569aa274fc..affc624b1d 100644 --- a/arch/arm/mach-at91/at91sam9g45.c +++ b/arch/arm/mach-at91/at91sam9g45.c @@ -270,7 +270,7 @@ static void at91sam9g45_initialize(void) at91_add_pit(AT91SAM9G45_BASE_PIT); at91_add_sam9_smc(DEVICE_ID_SINGLE, AT91SAM9G45_BASE_SMC, 0x200); - restart_handler_register_fn(at91sam9g45_restart); + restart_handler_register_fn("soc", at91sam9g45_restart); } static int at91sam9g45_setup(void) diff --git a/arch/arm/mach-at91/at91sam9n12.c b/arch/arm/mach-at91/at91sam9n12.c index 365bded56e..850d34604a 100644 --- a/arch/arm/mach-at91/at91sam9n12.c +++ b/arch/arm/mach-at91/at91sam9n12.c @@ -226,7 +226,7 @@ static void at91sam9n12_initialize(void) at91_add_pit(AT91SAM9N12_BASE_PIT); at91_add_sam9_smc(DEVICE_ID_SINGLE, AT91SAM9N12_BASE_SMC, 0x200); - restart_handler_register_fn(at91sam9n12_restart); + restart_handler_register_fn("soc", at91sam9n12_restart); } static int at91sam9n12_setup(void) diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c index 40ba9ed56e..086e27a79f 100644 --- a/arch/arm/mach-at91/at91sam9x5.c +++ b/arch/arm/mach-at91/at91sam9x5.c @@ -13,7 +13,7 @@ static void at91sam9x5_restart(struct restart_handler *rst) static int at91sam9x5_initialize(void) { - restart_handler_register_fn(at91sam9x5_restart); + restart_handler_register_fn("soc", at91sam9x5_restart); return 0; } diff --git a/arch/arm/mach-at91/sama5d3.c b/arch/arm/mach-at91/sama5d3.c index a5d464eca0..b1e7b2c565 100644 --- a/arch/arm/mach-at91/sama5d3.c +++ b/arch/arm/mach-at91/sama5d3.c @@ -397,7 +397,7 @@ static void sama5d3_initialize(void) at91_add_pit(SAMA5D3_BASE_PIT); at91_add_sam9_smc(DEVICE_ID_SINGLE, SAMA5D3_BASE_HSMC + 0x600, 0xa0); - restart_handler_register_fn(sama5d3_restart); + restart_handler_register_fn("soc", sama5d3_restart); } static int sama5d3_setup(void) diff --git a/arch/arm/mach-at91/sama5d4.c b/arch/arm/mach-at91/sama5d4.c index ca09dfe425..62e466fe51 100644 --- a/arch/arm/mach-at91/sama5d4.c +++ b/arch/arm/mach-at91/sama5d4.c @@ -305,7 +305,7 @@ static void sama5d4_initialize(void) at91_add_pit(SAMA5D4_BASE_PIT); at91_add_sam9_smc(DEVICE_ID_SINGLE, SAMA5D4_BASE_HSMC + 0x600, 0xa0); - restart_handler_register_fn(sama5d4_restart); + restart_handler_register_fn("soc", sama5d4_restart); } static int sama5d4_setup(void) diff --git a/arch/arm/mach-clps711x/reset.c b/arch/arm/mach-clps711x/reset.c index 03f40b73fa..90ddb8f5d2 100644 --- a/arch/arm/mach-clps711x/reset.c +++ b/arch/arm/mach-clps711x/reset.c @@ -22,7 +22,7 @@ static void __noreturn clps711x_restart_soc(struct restart_handler *rst) static int restart_register_feature(void) { - restart_handler_register_fn(clps711x_restart_soc); + restart_handler_register_fn("vector", clps711x_restart_soc); return 0; } diff --git a/arch/arm/mach-davinci/time.c b/arch/arm/mach-davinci/time.c index 4d1b570aa0..5b57fe6192 100644 --- a/arch/arm/mach-davinci/time.c +++ b/arch/arm/mach-davinci/time.c @@ -210,7 +210,7 @@ static void __noreturn davinci_restart_soc(struct restart_handler *rst) static int restart_register_feature(void) { - restart_handler_register_fn(davinci_restart_soc); + restart_handler_register_fn("soc-wdt", davinci_restart_soc); return 0; } diff --git a/arch/arm/mach-ep93xx/clocksource.c b/arch/arm/mach-ep93xx/clocksource.c index 4fdcc36b1c..1f3ff7f8f2 100644 --- a/arch/arm/mach-ep93xx/clocksource.c +++ b/arch/arm/mach-ep93xx/clocksource.c @@ -85,7 +85,7 @@ static void __noreturn ep92xx_restart_soc(struct restart_handler *rst) static int restart_register_feature(void) { - restart_handler_register_fn(ep92xx_restart_soc); + restart_handler_register_fn("soc", ep92xx_restart_soc); return 0; } diff --git a/arch/arm/mach-highbank/reset.c b/arch/arm/mach-highbank/reset.c index d73a0a76a5..ea3908ec2b 100644 --- a/arch/arm/mach-highbank/reset.c +++ b/arch/arm/mach-highbank/reset.c @@ -33,7 +33,7 @@ static void __noreturn highbank_poweroff(struct poweroff_handler *handler) static int highbank_init(void) { - restart_handler_register_fn(highbank_restart_soc); + restart_handler_register_fn("soc", highbank_restart_soc); poweroff_handler_register_fn(highbank_poweroff); return 0; diff --git a/arch/arm/mach-mvebu/armada-370-xp.c b/arch/arm/mach-mvebu/armada-370-xp.c index 2589f4fe72..9a35c51985 100644 --- a/arch/arm/mach-mvebu/armada-370-xp.c +++ b/arch/arm/mach-mvebu/armada-370-xp.c @@ -132,7 +132,7 @@ static int armada_370_xp_init_soc(void) if (!of_machine_is_compatible("marvell,armada-370-xp")) return 0; - restart_handler_register_fn(armada_370_xp_restart_soc); + restart_handler_register_fn("soc", armada_370_xp_restart_soc); barebox_set_model("Marvell Armada 370/XP"); barebox_set_hostname("armada"); diff --git a/arch/arm/mach-mvebu/dove.c b/arch/arm/mach-mvebu/dove.c index 37fde63f18..3c6302dd2d 100644 --- a/arch/arm/mach-mvebu/dove.c +++ b/arch/arm/mach-mvebu/dove.c @@ -36,7 +36,7 @@ static int dove_init_soc(void) if (!of_machine_is_compatible("marvell,dove")) return 0; - restart_handler_register_fn(dove_restart_soc); + restart_handler_register_fn("soc", dove_restart_soc); barebox_set_model("Marvell Dove"); barebox_set_hostname("dove"); diff --git a/arch/arm/mach-mvebu/kirkwood.c b/arch/arm/mach-mvebu/kirkwood.c index 59fb95ff4a..e50d7501c8 100644 --- a/arch/arm/mach-mvebu/kirkwood.c +++ b/arch/arm/mach-mvebu/kirkwood.c @@ -34,7 +34,7 @@ static int kirkwood_init_soc(void) if (!of_machine_is_compatible("marvell,kirkwood")) return 0; - restart_handler_register_fn(kirkwood_restart_soc); + restart_handler_register_fn("soc", kirkwood_restart_soc); barebox_set_model("Marvell Kirkwood"); barebox_set_hostname("kirkwood"); diff --git a/arch/arm/mach-mxs/soc-imx23.c b/arch/arm/mach-mxs/soc-imx23.c index f25fff18c3..8c47c766cc 100644 --- a/arch/arm/mach-mxs/soc-imx23.c +++ b/arch/arm/mach-mxs/soc-imx23.c @@ -49,7 +49,7 @@ static int imx23_devices_init(void) add_generic_device("imx23-gpio", 0, NULL, IMX_IOMUXC_BASE, 0x2000, IORESOURCE_MEM, NULL); add_generic_device("imx23-gpio", 1, NULL, IMX_IOMUXC_BASE, 0x2000, IORESOURCE_MEM, NULL); add_generic_device("imx23-gpio", 2, NULL, IMX_IOMUXC_BASE, 0x2000, IORESOURCE_MEM, NULL); - restart_handler_register_fn(imx23_restart_soc); + restart_handler_register_fn("soc", imx23_restart_soc); return 0; } diff --git a/arch/arm/mach-mxs/soc-imx28.c b/arch/arm/mach-mxs/soc-imx28.c index 49f870b5bf..a214e2b7a6 100644 --- a/arch/arm/mach-mxs/soc-imx28.c +++ b/arch/arm/mach-mxs/soc-imx28.c @@ -51,7 +51,7 @@ static int imx28_init(void) HW_CLKCTRL_WDOG_POR_DISABLE; writel(reg, IMX_CCM_BASE + HW_CLKCTRL_RESET); - restart_handler_register_fn(imx28_restart_soc); + restart_handler_register_fn("soc", imx28_restart_soc); arm_add_mem_device("ram0", IMX_MEMORY_BASE, imx28_get_memsize()); diff --git a/arch/arm/mach-nomadik/reset.c b/arch/arm/mach-nomadik/reset.c index 8bdaada8a1..d5266068e2 100644 --- a/arch/arm/mach-nomadik/reset.c +++ b/arch/arm/mach-nomadik/reset.c @@ -35,7 +35,7 @@ static void __noreturn nomadik_restart_soc(struct restart_handler *rst) static int restart_register_feature(void) { - restart_handler_register_fn(nomadik_restart_soc); + restart_handler_register_fn("soc", nomadik_restart_soc); return 0; } diff --git a/arch/arm/mach-omap/am33xx_generic.c b/arch/arm/mach-omap/am33xx_generic.c index 7577df761c..3c5cdf065c 100644 --- a/arch/arm/mach-omap/am33xx_generic.c +++ b/arch/arm/mach-omap/am33xx_generic.c @@ -244,7 +244,7 @@ int am33xx_init(void) { omap_gpmc_base = (void *)AM33XX_GPMC_BASE; - restart_handler_register_fn(am33xx_restart_soc); + restart_handler_register_fn("soc", am33xx_restart_soc); am33xx_enable_per_clocks(); diff --git a/arch/arm/mach-omap/omap3_generic.c b/arch/arm/mach-omap/omap3_generic.c index cff4a4fb11..3f6a346277 100644 --- a/arch/arm/mach-omap/omap3_generic.c +++ b/arch/arm/mach-omap/omap3_generic.c @@ -540,7 +540,7 @@ int omap3_init(void) { omap_gpmc_base = (void *)OMAP3_GPMC_BASE; - restart_handler_register_fn(omap3_restart_soc); + restart_handler_register_fn("soc", omap3_restart_soc); if (IS_ENABLED(CONFIG_RESET_SOURCE)) omap3_detect_reset_reason(); diff --git a/arch/arm/mach-omap/omap4_generic.c b/arch/arm/mach-omap/omap4_generic.c index 1f71153848..848a664064 100644 --- a/arch/arm/mach-omap/omap4_generic.c +++ b/arch/arm/mach-omap/omap4_generic.c @@ -535,7 +535,7 @@ int omap4_init(void) { omap_gpmc_base = (void *)OMAP44XX_GPMC_BASE; - restart_handler_register_fn(omap4_restart_soc); + restart_handler_register_fn("soc", omap4_restart_soc); return omap4_bootsource(); } diff --git a/arch/arm/mach-pxa/common.c b/arch/arm/mach-pxa/common.c index 106ca3020e..5b980cb81b 100644 --- a/arch/arm/mach-pxa/common.c +++ b/arch/arm/mach-pxa/common.c @@ -41,7 +41,7 @@ static void __noreturn pxa_restart_soc(struct restart_handler *rst) static int restart_register_feature(void) { - restart_handler_register_fn(pxa_restart_soc); + restart_handler_register_fn("soc-wdt", pxa_restart_soc); return 0; } diff --git a/arch/arm/mach-rockchip/rk3188.c b/arch/arm/mach-rockchip/rk3188.c index e7cbf36457..572e9dc58f 100644 --- a/arch/arm/mach-rockchip/rk3188.c +++ b/arch/arm/mach-rockchip/rk3188.c @@ -29,7 +29,7 @@ static void __noreturn rockchip_restart_soc(struct restart_handler *rst) static int restart_register_feature(void) { - restart_handler_register_fn(rockchip_restart_soc); + restart_handler_register_fn("soc", rockchip_restart_soc); return 0; } diff --git a/arch/arm/mach-rockchip/rk3288.c b/arch/arm/mach-rockchip/rk3288.c index 4e8fb4a123..9076fd9227 100644 --- a/arch/arm/mach-rockchip/rk3288.c +++ b/arch/arm/mach-rockchip/rk3288.c @@ -60,7 +60,7 @@ static void rk3288_detect_reset_reason(void) static int rk3288_init(void) { - restart_handler_register_fn(rockchip_restart_soc); + restart_handler_register_fn("soc", rockchip_restart_soc); if (IS_ENABLED(CONFIG_RESET_SOURCE)) rk3288_detect_reset_reason(); diff --git a/arch/arm/mach-samsung/generic.c b/arch/arm/mach-samsung/generic.c index de38d47e21..ed3d30d995 100644 --- a/arch/arm/mach-samsung/generic.c +++ b/arch/arm/mach-samsung/generic.c @@ -44,7 +44,7 @@ static void __noreturn samsung_restart_soc(struct restart_handler *rst) static int restart_register_feature(void) { - restart_handler_register_fn(samsung_restart_soc); + restart_handler_register_fn("soc-wdt", samsung_restart_soc); return 0; } diff --git a/arch/arm/mach-socfpga/arria10-generic.c b/arch/arm/mach-socfpga/arria10-generic.c index 53ec278739..38558309f8 100644 --- a/arch/arm/mach-socfpga/arria10-generic.c +++ b/arch/arm/mach-socfpga/arria10-generic.c @@ -70,7 +70,7 @@ static int arria10_generic_init(void) arria10_init_emac(); pr_debug("Register restart handler\n"); - restart_handler_register_fn(arria10_restart_soc); + restart_handler_register_fn("soc", arria10_restart_soc); return 0; } diff --git a/arch/arm/mach-socfpga/cyclone5-reset-manager.c b/arch/arm/mach-socfpga/cyclone5-reset-manager.c index 8635806846..4ee90b1bb0 100644 --- a/arch/arm/mach-socfpga/cyclone5-reset-manager.c +++ b/arch/arm/mach-socfpga/cyclone5-reset-manager.c @@ -37,7 +37,7 @@ static void __noreturn socfpga_restart_soc(struct restart_handler *rst) static int restart_register_feature(void) { - restart_handler_register_fn(socfpga_restart_soc); + restart_handler_register_fn("soc", socfpga_restart_soc); return 0; } diff --git a/arch/arm/mach-tegra/tegra20-pmc.c b/arch/arm/mach-tegra/tegra20-pmc.c index f7c7ac918f..a252c995ea 100644 --- a/arch/arm/mach-tegra/tegra20-pmc.c +++ b/arch/arm/mach-tegra/tegra20-pmc.c @@ -246,7 +246,7 @@ static struct driver_d tegra20_pmc_driver = { static int tegra20_pmc_init(void) { - restart_handler_register_fn(tegra20_restart_soc); + restart_handler_register_fn("soc", tegra20_restart_soc); return platform_driver_register(&tegra20_pmc_driver); } coredevice_initcall(tegra20_pmc_init); diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c index 006d4e7231..eb94a07dc9 100644 --- a/arch/arm/mach-versatile/core.c +++ b/arch/arm/mach-versatile/core.c @@ -192,7 +192,7 @@ static int versatile_init(void) amba_apb_device_add(NULL, "pl061_gpio", 1, 0x101e5000, 4096, NULL, 0); amba_apb_device_add(NULL, "pl061_gpio", 2, 0x101e6000, 4096, NULL, 0); amba_apb_device_add(NULL, "pl061_gpio", 3, 0x101e7000, 4096, NULL, 0); - restart_handler_register_fn(versatile_reset_soc); + restart_handler_register_fn("soc", versatile_reset_soc); return 0; } coredevice_initcall(versatile_init); diff --git a/arch/arm/mach-vexpress/reset.c b/arch/arm/mach-vexpress/reset.c index 3164ae3079..78e452936d 100644 --- a/arch/arm/mach-vexpress/reset.c +++ b/arch/arm/mach-vexpress/reset.c @@ -24,7 +24,7 @@ static void vexpress_reset_soc(struct restart_handler *rst) static int restart_register_feature(void) { - restart_handler_register_fn(vexpress_reset_soc); + restart_handler_register_fn("soc-wdt", vexpress_reset_soc); return 0; } diff --git a/arch/arm/mach-zynq/zynq.c b/arch/arm/mach-zynq/zynq.c index 79a6b908e0..806aeb9130 100644 --- a/arch/arm/mach-zynq/zynq.c +++ b/arch/arm/mach-zynq/zynq.c @@ -69,7 +69,7 @@ static int zynq_init(void) writel(val, 0xf8f00000); dmb(); - restart_handler_register_fn(zynq_restart_soc); + restart_handler_register_fn("soc", zynq_restart_soc); bootsource_set(zynq_bootsource_get()); diff --git a/arch/kvx/cpu/reset.c b/arch/kvx/cpu/reset.c index c7f2018e00..df36764cb6 100644 --- a/arch/kvx/cpu/reset.c +++ b/arch/kvx/cpu/reset.c @@ -60,7 +60,7 @@ static int kvx_reset_init(void) break; } - restart_handler_register_fn(kvx_restart_soc); + restart_handler_register_fn("soc", kvx_restart_soc); return 0; } diff --git a/arch/mips/mach-ar231x/ar231x_reset.c b/arch/mips/mach-ar231x/ar231x_reset.c index f88167ba4c..91414edd26 100644 --- a/arch/mips/mach-ar231x/ar231x_reset.c +++ b/arch/mips/mach-ar231x/ar231x_reset.c @@ -68,7 +68,7 @@ static struct driver_d ar231x_reset_driver = { static int ar231x_reset_init(void) { - restart_handler_register_fn(ar2312x_restart_soc); + restart_handler_register_fn("soc-wdt", ar2312x_restart_soc); return platform_driver_register(&ar231x_reset_driver); } coredevice_initcall(ar231x_reset_init); diff --git a/arch/mips/mach-ath79/reset.c b/arch/mips/mach-ath79/reset.c index b756c859d8..393ca00b08 100644 --- a/arch/mips/mach-ath79/reset.c +++ b/arch/mips/mach-ath79/reset.c @@ -22,7 +22,7 @@ static void __noreturn ath79_restart_soc(struct restart_handler *rst) static int restart_register_feature(void) { - restart_handler_register_fn(ath79_restart_soc); + restart_handler_register_fn("soc", ath79_restart_soc); return 0; } diff --git a/arch/mips/mach-bcm47xx/reset.c b/arch/mips/mach-bcm47xx/reset.c index 33dfb7b3b5..3ab9b0ce4b 100644 --- a/arch/mips/mach-bcm47xx/reset.c +++ b/arch/mips/mach-bcm47xx/reset.c @@ -19,7 +19,7 @@ static void __noreturn bcm47xx_restart_soc(struct restart_handler *rst) static int restart_register_feature(void) { - restart_handler_register_fn(bcm47xx_restart_soc); + restart_handler_register_fn("soc", bcm47xx_restart_soc); return 0; } diff --git a/arch/mips/mach-loongson/loongson1_reset.c b/arch/mips/mach-loongson/loongson1_reset.c index a6c05905de..85752f4ab8 100644 --- a/arch/mips/mach-loongson/loongson1_reset.c +++ b/arch/mips/mach-loongson/loongson1_reset.c @@ -20,7 +20,7 @@ static void __noreturn longhorn_restart_soc(struct restart_handler *rst) static int restart_register_feature(void) { - restart_handler_register_fn(longhorn_restart_soc); + restart_handler_register_fn("soc-wdt", longhorn_restart_soc); return 0; } diff --git a/arch/mips/mach-malta/reset.c b/arch/mips/mach-malta/reset.c index df7be0ae55..ad0de2741b 100644 --- a/arch/mips/mach-malta/reset.c +++ b/arch/mips/mach-malta/reset.c @@ -24,7 +24,7 @@ static void __noreturn malta_restart_soc(struct restart_handler *rst) static int restart_register_feature(void) { - restart_handler_register_fn(malta_restart_soc); + restart_handler_register_fn("soc", malta_restart_soc); return 0; } diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c index 62bcf40f63..9f86c911cc 100644 --- a/arch/nios2/cpu/cpu.c +++ b/arch/nios2/cpu/cpu.c @@ -30,7 +30,7 @@ static void __noreturn nios2_restart_soc(struct restart_handler *rst) static int restart_register_feature(void) { - return restart_handler_register_fn(nios2_restart_soc); + return restart_handler_register_fn("vector", nios2_restart_soc); } coredevice_initcall(restart_register_feature); diff --git a/arch/openrisc/cpu/cpu.c b/arch/openrisc/cpu/cpu.c index 8afd22bdea..47d8ab4288 100644 --- a/arch/openrisc/cpu/cpu.c +++ b/arch/openrisc/cpu/cpu.c @@ -33,6 +33,6 @@ static void __noreturn openrisc_restart_cpu(struct restart_handler *rst) static int restart_register_feature(void) { - return restart_handler_register_fn(openrisc_restart_cpu); + return restart_handler_register_fn("vector", openrisc_restart_cpu); } coredevice_initcall(restart_register_feature); diff --git a/arch/powerpc/mach-mpc5xxx/cpu.c b/arch/powerpc/mach-mpc5xxx/cpu.c index a85e1667bc..5cf5194aa2 100644 --- a/arch/powerpc/mach-mpc5xxx/cpu.c +++ b/arch/powerpc/mach-mpc5xxx/cpu.c @@ -92,7 +92,7 @@ static void __noreturn mpc5xxx_restart_soc(struct restart_handler *rst) static int restart_register_feature(void) { - return restart_handler_register_fn(mpc5xxx_restart_soc); + return restart_handler_register_fn("soc-wdt", mpc5xxx_restart_soc); } coredevice_initcall(restart_register_feature); diff --git a/arch/powerpc/mach-mpc85xx/cpu.c b/arch/powerpc/mach-mpc85xx/cpu.c index 7c8a59edc9..efdff24e6d 100644 --- a/arch/powerpc/mach-mpc85xx/cpu.c +++ b/arch/powerpc/mach-mpc85xx/cpu.c @@ -42,7 +42,7 @@ static void __noreturn mpc85xx_restart_soc(struct restart_handler *rst) static int restart_register_feature(void) { - restart_handler_register_fn(mpc85xx_restart_soc); + restart_handler_register_fn("soc", mpc85xx_restart_soc); return 0; } diff --git a/common/efi/efi.c b/common/efi/efi.c index 6f55e3970e..01003dc00f 100644 --- a/common/efi/efi.c +++ b/common/efi/efi.c @@ -292,7 +292,7 @@ static void __noreturn efi_poweroff_system(struct poweroff_handler *handler) static int restart_register_feature(void) { - restart_handler_register_fn(efi_restart_system); + restart_handler_register_fn("efi", efi_restart_system); poweroff_handler_register_fn(efi_poweroff_system); return 0; diff --git a/common/restart.c b/common/restart.c index dd15c8d5c3..0f9e03765d 100644 --- a/common/restart.c +++ b/common/restart.c @@ -47,6 +47,7 @@ int restart_handler_register(struct restart_handler *rst) /** * restart_handler_register_fn() - register a handler function + * @name: restart method name or NULL if name should be auto-generated * @restart_fn: The restart function * * convenience wrapper for restart_handler_register() to register a handler @@ -54,13 +55,15 @@ int restart_handler_register(struct restart_handler *rst) * * return: 0 for success or negative error code */ -int restart_handler_register_fn(void (*restart_fn)(struct restart_handler *)) +int restart_handler_register_fn(const char *name, + void (*restart_fn)(struct restart_handler *)) { struct restart_handler *rst; int ret; rst = xzalloc(sizeof(*rst)); + rst->name = xstrdup(name); rst->restart = restart_fn; ret = restart_handler_register(rst); diff --git a/include/restart.h b/include/restart.h index 6880b03b93..e7dd1bd2b7 100644 --- a/include/restart.h +++ b/include/restart.h @@ -12,7 +12,8 @@ struct restart_handler { }; int restart_handler_register(struct restart_handler *); -int restart_handler_register_fn(void (*restart_fn)(struct restart_handler *)); +int restart_handler_register_fn(const char *name, + void (*restart_fn)(struct restart_handler *)); #define RESTART_DEFAULT_PRIORITY 100 -- cgit v1.2.3 From d97016d3a53e5d9959f1e2b966c7cd0922f6bba3 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Tue, 2 Jun 2020 09:57:57 +0200 Subject: commands: reset: allow specifying reset by name So far, we were fine by using the highest priority restart handler whenever more than one was available. There are reasons to want to configure this however: - When communicating with BootROM, e.g. to force boot from recovery mode: The reset chosen must not cause the reboot mode stored to volatile memory to vanish - When testing (undocumented) reset behavior, e.g. to analyze how the EFI reset behaves Extend the reset command to support this. When no extra command line option is supplied, the old behavior is maintained. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- commands/reset.c | 27 ++++++++++++++++++++++++--- common/restart.c | 28 ++++++++++++++++++++++++++-- include/restart.h | 2 ++ 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/commands/reset.c b/commands/reset.c index 2b10f1cd18..fe54e2f9b4 100644 --- a/commands/reset.c +++ b/commands/reset.c @@ -11,24 +11,43 @@ static int cmd_reset(int argc, char *argv[]) { + struct restart_handler *rst; int opt, shutdown_flag; + const char *name = NULL; shutdown_flag = 1; - while ((opt = getopt(argc, argv, "f")) > 0) { + while ((opt = getopt(argc, argv, "flr:")) > 0) { switch (opt) { case 'f': shutdown_flag = 0; break; + case 'l': + restart_handlers_print(); + return 0; + case 'r': + name = optarg; + break; default: return COMMAND_ERROR_USAGE; } } + rst = restart_handler_get_by_name(name); + if (!rst && name) { + printf("reset '%s' does not exist\n", name); + return COMMAND_ERROR; + } + if (shutdown_flag) shutdown_barebox(); - restart_machine(); + if (rst) { + console_flush(); + rst->restart(rst); + } + + hang(); /* Not reached */ return 1; @@ -37,12 +56,14 @@ static int cmd_reset(int argc, char *argv[]) BAREBOX_CMD_HELP_START(reset) BAREBOX_CMD_HELP_TEXT("Options:") BAREBOX_CMD_HELP_OPT("-f", "force RESET, don't call shutdown") +BAREBOX_CMD_HELP_OPT("-l", "list reset handlers") +BAREBOX_CMD_HELP_OPT("-r RESET", "use reset handler named RESET") BAREBOX_CMD_HELP_END BAREBOX_CMD_START(reset) .cmd = cmd_reset, BAREBOX_CMD_DESC("perform RESET of the CPU") - BAREBOX_CMD_OPTS("[-f]") + BAREBOX_CMD_OPTS("[-flr]") BAREBOX_CMD_GROUP(CMD_GRP_BOOT) BAREBOX_CMD_HELP(cmd_reset_help) BAREBOX_CMD_COMPLETE(empty_complete) diff --git a/common/restart.c b/common/restart.c index 0f9e03765d..2bf7b166b0 100644 --- a/common/restart.c +++ b/common/restart.c @@ -75,20 +75,33 @@ int restart_handler_register_fn(const char *name, } /** - * restart_machine() - reset the whole system + * restart_handler_get_by_name() - reset the whole system */ -void __noreturn restart_machine(void) +struct restart_handler *restart_handler_get_by_name(const char *name) { struct restart_handler *rst = NULL, *tmp; unsigned int priority = 0; list_for_each_entry(tmp, &restart_handler_list, list) { + if (name && tmp->name && strcmp(name, tmp->name)) + continue; if (tmp->priority > priority) { priority = tmp->priority; rst = tmp; } } + return rst; +} + +/** + * restart_machine() - reset the whole system + */ +void __noreturn restart_machine(void) +{ + struct restart_handler *rst; + + rst = restart_handler_get_by_name(NULL); if (rst) { pr_debug("%s: using restart handler %s\n", __func__, rst->name); console_flush(); @@ -112,3 +125,14 @@ unsigned int of_get_restart_priority(struct device_node *node) return priority; } + +/* + * restart_handlers_print - print informations about all restart handlers + */ +void restart_handlers_print(void) +{ + struct restart_handler *tmp; + + list_for_each_entry(tmp, &restart_handler_list, list) + printf("%-20s %6d\n", tmp->name, tmp->priority); +} diff --git a/include/restart.h b/include/restart.h index e7dd1bd2b7..2d15c7598a 100644 --- a/include/restart.h +++ b/include/restart.h @@ -2,7 +2,9 @@ #ifndef __INCLUDE_RESTART_H #define __INCLUDE_RESTART_H +void restart_handlers_print(void); void __noreturn restart_machine(void); +struct restart_handler *restart_handler_get_by_name(const char *name); struct restart_handler { void (*restart)(struct restart_handler *); -- cgit v1.2.3 From 456fbcc4cc0245ab3416ee3e80da83bc6d5d698e Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Tue, 15 Sep 2020 11:44:17 +0200 Subject: regulator: provide regulator_get_name() stub for !CONFIG_REGULATOR Otherwise users of this function run into a link error when regulator support is compiled out. Reported-by: Roland Hieber Signed-off-by: Ahmad Fatoum Tested-by: Roland Hieber Signed-off-by: Sascha Hauer --- include/regulator.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/regulator.h b/include/regulator.h index 12d8e816cd..a9cb6dedca 100644 --- a/include/regulator.h +++ b/include/regulator.h @@ -175,6 +175,11 @@ static inline struct regulator *regulator_get(struct device_d *dev, const char * return NULL; } +static inline struct regulator *regulator_get_name(const char *name) +{ + return NULL; +} + static inline int regulator_enable(struct regulator *r) { return 0; -- cgit v1.2.3 From b389b46ad6f0ec96624f285238eccac30fe1eb5a Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Sep 2020 22:03:08 +0200 Subject: README: update to reflect current state The bulk of the README has stayed unchanged for the last ten years or so. Polish it up up a bit. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- README | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/README b/README index d8077d21b6..c4c8abbb4b 100644 --- a/README +++ b/README @@ -18,33 +18,34 @@ Features - The environment is not a variable store anymore, but a file store. It has currently some limitations, of course. The environment is not a real - read/write filesystem, it is more like a tar archive, or even more like - an ar archive, because it cannot handle directories. The saveenv command - saves the files under a certain directory (by default /env) in persistent - storage (by default /dev/env0). There is a counterpart called loadenv, too. + read/write filesystem, but more like a tar archive. + The saveenv command saves the files under a certain directory (by default + /env) in persistent storage (by default /dev/env0). There is a counterpart + called loadenv, too. - filesystem support The loader starts up with mounting a ramdisk on /. Then a devfs is mounted on /dev allowing the user (or shell commands) to access devices. Apart from - these two filesystems there is currently one filesystem ported: cramfs. One - can mount it with the usual mount command. + these two filesystems there are a number of different filesystems ported: + ext4, efi, efivarfs, ext4, fat, jffs2, NFS, pstore, squashfs, ubifs, + u-boot variable FS among others. - device/driver model Devices are no longer described by defines in the config file. Instead - there are devices which can be registered in the board .c file or - dynamically allocated. Drivers will match upon the devices automatically. + devices are registered as they are discovered (e.g. through OpenFirmware + device tree traversal or EFI handles) or by board code. + Drivers will match upon the devices automatically. - clocksource support Timekeeping has been simplified by the use of the Linux clocksource API. - Only one function is needed for a new board, no [gs]et_timer[masked]() or - reset_timer[masked]() functions. + no [gs]et_timer[masked]() or reset_timer[masked]() functions. - Kconfig and Kernel build system Only targets which are really needed get recompiled. Parallel builds are no problem anymore. This also removes the need for many many ifdefs in the code. -- simulation target +- ARCH=sandbox simulation target barebox can be compiled to run under Linux. While this is rather useless in real world this is a great debugging and development aid. New features can be easily developed and tested on long train journeys and started @@ -53,7 +54,7 @@ Features devices under barebox to emulate storage devices. - device parameter support - Each device can have a unlimited number of parameters. They can be accessed + Each device can have an unlimited number of parameters. They can be accessed on the command line with .="...", for example 'eth0.ip=192.168.0.7' or 'echo $eth0.ip' @@ -83,7 +84,7 @@ For the examples below, we use the User Mode barebox implementation, which is a port of barebox to the Linux userspace. This makes it possible to test drive the code without having real hardware. So for this test scenario, ARCH=sandbox is the valid architecture selection. This currently -only works on ia32 hosts and partly on x86-64. +works on at least IA32 hosts and x86-64 hosts. Selection of the architecture and the cross compiler can be done by using the environment variables ARCH and CROSS_COMPILE. @@ -137,7 +138,7 @@ loaded the example environment barebox will show you a menu asking for your settings. If you have started barebox as root you will find a new tap device on your -host which you can configure using ifconfig. Once you configured bareboxs +host which you can configure using ifconfig. Once you configured barebox' network settings accordingly you can do a ping or tftpboot. If you have mapped a cramfs image try mounting it with @@ -157,16 +158,15 @@ Directory Layout Most of the directory layout is based upon the Linux Kernel: -arch/*/ -> contains architecture specific parts -arch/*/mach-*/ -> SoC specific code +arch/* -> contains architecture specific parts +arch/*/include -> architecture specific includes +arch/*/mach-* -> SoC specific code +arch/*/mach-*/include -> SoC specific includes drivers/serial -> drivers drivers/net drivers/... -include/asm-* -> architecture specific includes -include/asm-*/arch-* -> SoC specific includes - fs/ -> filesystem support and filesystem drivers lib/ -> generic library functions (getopt, readline and the @@ -188,7 +188,7 @@ Documentation/ -> Sphinx generated documentation. Call "make docs" to Release Strategy ---------------- -Barebox is developed with git. From time to time, tarball releases are +Barebox is developed with git. On a monthly schedule, tarball releases are branched from the repository and released on the project web site. Here are the release rules: -- cgit v1.2.3 From 3717b35e2a5d9f1406dc3d8bb6d05805bc99c9fe Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Sep 2020 22:03:09 +0200 Subject: README: use lower-case barebox spelling This is a bit of a churn, but at least the top level README can use the correct casing. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- README | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README b/README index c4c8abbb4b..d206e30139 100644 --- a/README +++ b/README @@ -1,9 +1,9 @@ # SPDX-License-Identifier: GPL-2.0-only -Barebox +barebox ------- -Barebox is a bootloader that follows the tradition of Das U-Boot, while +barebox is a bootloader that follows the tradition of Das U-Boot, while adopting modern design ideas from the Linux kernel. @@ -72,10 +72,10 @@ Features except the ones really needed: moving the cursor and typing characters. -Building Barebox +Building barebox ---------------- -Barebox uses the Linux kernel's build system. It consists of two parts: +barebox uses the Linux kernel's build system. It consists of two parts: the Makefile infrastructure (kbuild), plus a configuration system (kconfig). So building barebox is very similar to building the Linux kernel. @@ -109,7 +109,7 @@ If everything goes well, the result is a file called barebox: # ls -l barebox -rwxr-xr-x 1 rsc ptx 114073 Jun 26 22:34 barebox -Barebox usually needs an environment for storing the configuration data. +barebox usually needs an environment for storing the configuration data. You can generate an environment using the example environment contained in board/sandbox/env: @@ -188,7 +188,7 @@ Documentation/ -> Sphinx generated documentation. Call "make docs" to Release Strategy ---------------- -Barebox is developed with git. On a monthly schedule, tarball releases are +barebox is developed with git. On a monthly schedule, tarball releases are branched from the repository and released on the project web site. Here are the release rules: @@ -228,15 +228,15 @@ are the release rules: Contributing ------------ -For any questions regarding Barebox, send a mail to the mailing list at +For any questions regarding barebox, send a mail to the mailing list at . The archives for this list are available publicly at and . -The same list should also be used to send patches. Barebox uses a similar +The same list should also be used to send patches. barebox uses a similar process as the Linux kernel, so most of the Linux guide for submitting patches also -applies to Barebox (except the step for selecting your recipient - we don't +applies to barebox (except the step for selecting your recipient - we don't have a MAINTAINERS file, instead all patches go to the list). @@ -246,7 +246,7 @@ License Copyright (C) 2000 - 2005 Wolfgang Denk, DENX Software Engineering, wd@denx.de. Copyright (C) 2018 Sascha Hauer, Pengutronix, and individual contributors -Barebox is free software: you can redistribute it and/or modify it under the +barebox is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. @@ -266,6 +266,6 @@ the above copyright and warranty notices: This eases machine processing of licensing information based on the SPDX License Identifiers that are available at http://spdx.org/licenses/. -Also note that some files in the Barebox source tree are available under +Also note that some files in the barebox source tree are available under several different GPLv2-compatible open-source licenses. This fact is noted clearly in the file headers of the respective files. -- cgit v1.2.3 From 29bc6e6154201289f5cbb8837cf193e829da487d Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Sep 2020 22:54:15 +0200 Subject: sandbox: unwind: fix indentation Indentation was unintentionally doubled. Fix this. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- arch/sandbox/lib/unwind.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sandbox/lib/unwind.c b/arch/sandbox/lib/unwind.c index 15a2798cc4..f46365ac2b 100644 --- a/arch/sandbox/lib/unwind.c +++ b/arch/sandbox/lib/unwind.c @@ -7,5 +7,5 @@ void __sanitizer_print_stack_trace(void); void dump_stack(void) { - __sanitizer_print_stack_trace(); + __sanitizer_print_stack_trace(); } -- cgit v1.2.3 From 60e7290cd6bca70edd9b66f5fb732ea604d3ce63 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Sep 2020 22:52:59 +0200 Subject: ARM: dts: stm32mp: drop no longer needed PSCI version override 52cc061f50aa ("ARM: dts: stm32mp: report psci v0.2 at least") adds a barebox override, because the upstream device tree's compatible was outdated. Since abef60363d8e ("dts: update to v5.8-rc1"), the upstream device tree has &{/psci} { compatible = "arm,psci-1.0"; }; , so now we can drop our override again without adverse effect. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- arch/arm/dts/stm32mp151.dtsi | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/arm/dts/stm32mp151.dtsi b/arch/arm/dts/stm32mp151.dtsi index 5ff3b96fae..cc25400475 100644 --- a/arch/arm/dts/stm32mp151.dtsi +++ b/arch/arm/dts/stm32mp151.dtsi @@ -37,10 +37,6 @@ compatible = "simple-bus"; }; -&{/psci} { - compatible = "arm,psci-0.2"; -}; - &{/soc} { memory-controller@5a003000 { compatible = "st,stm32mp1-ddr"; -- cgit v1.2.3 From fbf145dc86832846465a317619dd4d61af3897b3 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Tue, 15 Sep 2020 14:08:30 +0200 Subject: commands: setenv: support setenv dev.var=VAL syntax In preparation for making setenv selectable under CONFIG_SHELL_HUSH, allow a `setenv dev.var=VAL syntax`: - makes command use less surprising for hush users - allows seamless integration with current device parameter complete While at it, propagate setenv's return code to the calling shell. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- commands/setenv.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/commands/setenv.c b/commands/setenv.c index 3cf769d24a..a70a0de4ce 100644 --- a/commands/setenv.c +++ b/commands/setenv.c @@ -8,12 +8,20 @@ static int do_setenv(int argc, char *argv[]) { + char *equal; + if (argc < 2) return COMMAND_ERROR_USAGE; - setenv(argv[1], argv[2]); + equal = strrchr(argv[1], '='); + if (equal) { + equal[0] = '\0'; + if (equal[1]) + argv[2] = &equal[1]; + } + - return 0; + return setenv(argv[1], argv[2]) ? COMMAND_ERROR : COMMAND_SUCCESS; } BAREBOX_CMD_HELP_START(setenv) -- cgit v1.2.3 From 932481a005cc7b2933791a349a312af0149b6c94 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Tue, 15 Sep 2020 14:08:31 +0200 Subject: commands: setenv: allow use with hush shell setenv was so far restricted to the simple shell, because with hush, users could just do dev.var=VAL for setting variables in the environment. The hush syntax doesn't allow for setting all kinds of environment variables though, e.g. 5c00a000.tamp@5c00a000:reboot-mode.of.param can't be set with hush, because of the special characters. It could still be read by using the ${variable} syntax though. Allow setting these variables by making the setenv command generally available. The default is chosen to be 'y', because the command is deemed small and useful enough to have it there by default. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- commands/Kconfig | 13 +++++++++++++ commands/Makefile | 2 +- commands/setenv.c | 2 ++ common/Kconfig | 1 + common/complete.c | 6 ++++++ include/complete.h | 1 + 6 files changed, 24 insertions(+), 1 deletion(-) diff --git a/commands/Kconfig b/commands/Kconfig index 3789f33c3b..1399f04d8b 100644 --- a/commands/Kconfig +++ b/commands/Kconfig @@ -718,6 +718,19 @@ config CMD_SAVEENV /dev/env0. Note that envfs can only handle files, directories are being skipped silently. +config CMD_SETENV + tristate + default y + depends on !CONFIG_SHELL_NONE + prompt "setenv" + help + Set environment variable + + Usage: setenv NAME [VALUE] + + Set environment variable NAME to VALUE. + If VALUE is ommitted, then the variable is deleted. + # end Environment commands endmenu diff --git a/commands/Makefile b/commands/Makefile index 01082de44c..6cc4997cc5 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -41,7 +41,7 @@ obj-$(CONFIG_CMD_FLASH) += flash.o obj-$(CONFIG_CMD_MEMINFO) += meminfo.o obj-$(CONFIG_CMD_TIMEOUT) += timeout.o obj-$(CONFIG_CMD_READLINE) += readline.o -obj-$(CONFIG_SHELL_SIMPLE) += setenv.o +obj-$(CONFIG_CMD_SETENV) += setenv.o obj-$(CONFIG_CMD_EXPORT) += export.o obj-$(CONFIG_CMD_PRINTENV) += printenv.o obj-$(CONFIG_CMD_SAVEENV) += saveenv.o diff --git a/commands/setenv.c b/commands/setenv.c index a70a0de4ce..ad26770655 100644 --- a/commands/setenv.c +++ b/commands/setenv.c @@ -5,6 +5,7 @@ #include #include #include +#include static int do_setenv(int argc, char *argv[]) { @@ -34,5 +35,6 @@ BAREBOX_CMD_START(setenv) BAREBOX_CMD_DESC("set environment variable") BAREBOX_CMD_OPTS("NAME [VALUE]") BAREBOX_CMD_GROUP(CMD_GRP_ENV) + BAREBOX_CMD_COMPLETE(env_param_noeval_complete) BAREBOX_CMD_HELP(cmd_setenv_help) BAREBOX_CMD_END diff --git a/common/Kconfig b/common/Kconfig index 140b0f95c1..4ba58e55d4 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -411,6 +411,7 @@ choice select COMMAND_SUPPORT select PARAMETER select STDDEV + select CMD_SETENV help simple shell. No if/then, no return values from commands, no loops diff --git a/common/complete.c b/common/complete.c index 919e5abc6a..36e10405c8 100644 --- a/common/complete.c +++ b/common/complete.c @@ -336,6 +336,12 @@ static int env_param_complete(struct string_list *sl, char *instr, int eval) return 0; } +int env_param_noeval_complete(struct string_list *sl, char *instr) +{ + return env_param_complete(sl, instr, 0); +} +EXPORT_SYMBOL(env_param_noeval_complete); + static int tab_pressed = 0; void complete_reset(void) diff --git a/include/complete.h b/include/complete.h index 763d256bf4..75a92fc86a 100644 --- a/include/complete.h +++ b/include/complete.h @@ -22,5 +22,6 @@ int devicetree_alias_complete(struct string_list *sl, char *instr); int devicetree_nodepath_complete(struct string_list *sl, char *instr); int devicetree_complete(struct string_list *sl, char *instr); int devicetree_file_complete(struct string_list *sl, char *instr); +int env_param_noeval_complete(struct string_list *sl, char *instr); #endif /* __COMPLETE_ */ -- cgit v1.2.3 From 37fcc42b4a7c50480e5299b737127f594c78da51 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Tue, 15 Sep 2020 16:38:28 +0200 Subject: scripts/imx: fix typo "unkown" -> "unknown" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Uwe Kleine-König Signed-off-by: Sascha Hauer --- scripts/imx/imx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/imx/imx.c b/scripts/imx/imx.c index 1fb3922fcf..e9f05b83a3 100644 --- a/scripts/imx/imx.c +++ b/scripts/imx/imx.c @@ -275,7 +275,7 @@ static int do_soc(struct config_data *data, int argc, char *argv[]) } } - fprintf(stderr, "unkown SoC type \"%s\". Known SoCs are:\n", soc); + fprintf(stderr, "unknown SoC type \"%s\". Known SoCs are:\n", soc); for (i = 0; i < ARRAY_SIZE(socs); i++) fprintf(stderr, "%s ", socs[i].name); fprintf(stderr, "\n"); -- cgit v1.2.3 From bf2f0514300b223bb78959f764e4f0eef6f6b4fe Mon Sep 17 00:00:00 2001 From: Albert Schwarzkopf Date: Tue, 15 Sep 2020 15:36:30 +0200 Subject: bootm: Allow loading OP-TEE from FIT image Currently, TEE binaries can only be loaded if CONFIG_BOOTM_FORCE_SIGNED_IMAGES is not set. No signature check is being performed on them. Allow loading OP-TEE from FIT images. Therefore, now it's possible to ensure that only trusted OP-TEE binaries will be loaded by using signed FIT images. Signed-off-by: Albert Schwarzkopf Signed-off-by: Sascha Hauer --- arch/arm/lib32/bootm.c | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/arch/arm/lib32/bootm.c b/arch/arm/lib32/bootm.c index 971ebee8ac..c33ecc2ad8 100644 --- a/arch/arm/lib32/bootm.c +++ b/arch/arm/lib32/bootm.c @@ -20,7 +20,7 @@ #include #include #include - +#include #include #include #include @@ -166,6 +166,34 @@ static int optee_verify_header_request_region(struct image_data *data, struct op return ret; } +static int bootm_load_tee_from_fit(struct image_data *data) +{ + int ret = 0; + struct optee_header hdr; + + if (data->os_fit && + fit_has_image(data->os_fit, data->fit_config, "tee")) { + const void *tee; + unsigned long tee_size; + + ret = fit_open_image(data->os_fit, data->fit_config, "tee", + &tee, &tee_size); + if (ret) { + pr_err("Error opening tee fit image: %s\n", strerror(-ret)); + return ret; + } + memcpy(&hdr, tee, sizeof(hdr)); + if (optee_verify_header_request_region(data, &hdr) < 0) { + pr_err("%s", strerror(errno)); + ret = -errno; + goto out; + } + memcpy((void *)data->tee_res->start, tee + sizeof(hdr), hdr.init_size); + printf("Read optee image to %pa, size 0x%08x\n", (void *)data->tee_res->start, hdr.init_size); + } +out: + return ret; +} static int bootm_load_tee_from_file(struct image_data *data) { int fd, ret; @@ -262,10 +290,16 @@ static int __do_bootm_linux(struct image_data *data, unsigned long free_mem, return ret; } - if (IS_ENABLED(CONFIG_BOOTM_OPTEE) && data->tee_file) { - ret = bootm_load_tee_from_file(data); - if (ret) - return ret; + if (IS_ENABLED(CONFIG_BOOTM_OPTEE)) { + if (data->tee_file && !IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES)) { + ret = bootm_load_tee_from_file(data); + if (ret) + return ret; + } else if (IS_ENABLED(CONFIG_FITIMAGE)) { + ret = bootm_load_tee_from_fit(data); + if (ret) + return ret; + } } -- cgit v1.2.3 From c3aa46566bf93f9b08fb190098cf05e936e2a933 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Wed, 16 Sep 2020 15:54:09 +0200 Subject: globalvar: allow running actions on set with globalvar_add_bool() globalvar_add_simple_bool() and the other family of globalvars don't allow running a callback when the variable is set. This is a useful thing to have however for things like global.usbgadget.autostart=1. Provide a globalvar_add_bool() that accommodates this. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- common/globalvar.c | 8 +++++--- include/globalvar.h | 14 +++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/common/globalvar.c b/common/globalvar.c index 98a028a68a..6ab4c1f68e 100644 --- a/common/globalvar.c +++ b/common/globalvar.c @@ -514,7 +514,9 @@ int globalvar_add_simple_int(const char *name, int *value, return 0; } -int globalvar_add_simple_bool(const char *name, int *value) +int globalvar_add_bool(const char *name, + int (*set)(struct param_d *, void *), + int *value, void *priv) { struct param_d *p; int ret; @@ -523,8 +525,8 @@ int globalvar_add_simple_bool(const char *name, int *value) if (ret) return ret; - p = dev_add_param_bool(&global_device, name, NULL, NULL, - value, NULL); + p = dev_add_param_bool(&global_device, name, set, NULL, + value, priv); if (IS_ERR(p)) return PTR_ERR(p); diff --git a/include/globalvar.h b/include/globalvar.h index fc85e93e14..6f2c6db746 100644 --- a/include/globalvar.h +++ b/include/globalvar.h @@ -19,7 +19,9 @@ void globalvar_set_match(const char *match, const char *val); int globalvar_add_simple_string(const char *name, char **value); int globalvar_add_simple_int(const char *name, int *value, const char *format); -int globalvar_add_simple_bool(const char *name, int *value); +int globalvar_add_bool(const char *name, + int (*set)(struct param_d *, void *), + int *value, void *priv); int globalvar_add_simple_enum(const char *name, int *value, const char * const *names, int max); int globalvar_add_simple_bitmask(const char *name, unsigned long *value, @@ -51,8 +53,9 @@ static inline int globalvar_add_simple_int(const char *name, return 0; } -static inline int globalvar_add_simple_bool(const char *name, - int *value) +static inline int globalvar_add_bool(const char *name, + int (*set)(struct param_d *, void *), + int *value, void *priv) { return 0; } @@ -121,4 +124,9 @@ int nvvar_save(void); int nv_complete(struct string_list *sl, char *instr); int global_complete(struct string_list *sl, char *instr); +static inline int globalvar_add_simple_bool(const char *name, int *value) +{ + return globalvar_add_bool(name, NULL, value, NULL); +} + #endif /* __GLOBALVAR_H */ -- cgit v1.2.3 From 574b76b299285fbc7cc1688690ab65dc7f9b0f5f Mon Sep 17 00:00:00 2001 From: Robert Karszniewicz Date: Sat, 19 Sep 2020 22:41:33 +0200 Subject: scripts: compiler.h: include ulong is not a standard type, so it has to be defined explicitly. Signed-off-by: Robert Karszniewicz Signed-off-by: Sascha Hauer --- scripts/compiler.h | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/compiler.h b/scripts/compiler.h index 0ad25f9e8d..c932f715c5 100644 --- a/scripts/compiler.h +++ b/scripts/compiler.h @@ -62,6 +62,7 @@ typedef unsigned int uint; defined(__NetBSD__) || defined(__DragonFly__) # include #else /* assume Linux */ +# include # include # include #endif -- cgit v1.2.3 From 0b3c92f5c998a1b89123a94ec99d700ca94c738e Mon Sep 17 00:00:00 2001 From: Robert Karszniewicz Date: Sat, 19 Sep 2020 16:55:58 +0200 Subject: README: add some commas for clarity Signed-off-by: Robert Karszniewicz Signed-off-by: Sascha Hauer --- README | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README b/README index d206e30139..7c5ef9f818 100644 --- a/README +++ b/README @@ -115,7 +115,7 @@ in board/sandbox/env: # ./scripts/bareboxenv -s -p 0x10000 arch/sandbox/board/env env.bin -To get some files to play with you can generate a cramfs image: +To get some files to play with, you can generate a cramfs image: # mkcramfs somedir/ cramfs.bin The barebox image is a normal Linux executable, so it can be started @@ -134,14 +134,14 @@ given with '-i' will appear as /dev/fd[n]. If barebox finds a valid configuration sector on /dev/env0 it will load it to /env. It then executes /env/init if it exists. If you have -loaded the example environment barebox will show you a menu asking for +loaded the example environment, barebox will show you a menu asking for your settings. -If you have started barebox as root you will find a new tap device on your +If you have started barebox as root, you will find a new tap device on your host which you can configure using ifconfig. Once you configured barebox' network settings accordingly you can do a ping or tftpboot. -If you have mapped a cramfs image try mounting it with +If you have mapped a cramfs image, try mounting it with # mkdir /cram # mount /dev/fd0 cramfs /cram -- cgit v1.2.3 From 568130f6efb9b5bb20aea3742a42bfa956186479 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Fri, 18 Sep 2020 13:04:41 +0200 Subject: Regenerate defconfig files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Done with the same script used to generate commit d952a0eeba37 ("Regenerate defconfig files"). Signed-off-by: Uwe Kleine-König Signed-off-by: Sascha Hauer --- arch/arm/configs/at91sam9263ek_defconfig | 1 - arch/arm/configs/at91sam9x5ek_defconfig | 1 - arch/arm/configs/freescale-mx21-ads_defconfig | 1 - arch/arm/configs/imx_defconfig | 1 - arch/arm/configs/imx_v8_defconfig | 2 -- arch/arm/configs/kindle-mx50_defconfig | 1 - arch/arm/configs/layerscape_defconfig | 2 -- arch/arm/configs/microchip_ksz9477_evb_defconfig | 1 - arch/arm/configs/socfpga-arria10_defconfig | 1 - arch/arm/configs/virt2real_defconfig | 1 - arch/arm/configs/zii_vf610_dev_defconfig | 1 - arch/kvx/configs/generic_defconfig | 12 +++++------- arch/mips/configs/bcm47xx_defconfig | 1 - arch/mips/configs/qemu-malta_defconfig | 1 - arch/x86/configs/efi_defconfig | 1 - 15 files changed, 5 insertions(+), 23 deletions(-) diff --git a/arch/arm/configs/at91sam9263ek_defconfig b/arch/arm/configs/at91sam9263ek_defconfig index 45c6f79de4..0cde5396af 100644 --- a/arch/arm/configs/at91sam9263ek_defconfig +++ b/arch/arm/configs/at91sam9263ek_defconfig @@ -1,4 +1,3 @@ -CONFIG_ARCH_AT91SAM9263=y CONFIG_AT91_MULTI_BOARDS=y CONFIG_MACH_AT91SAM9263EK=y CONFIG_BAREBOX_MAX_IMAGE_SIZE=0x40000 diff --git a/arch/arm/configs/at91sam9x5ek_defconfig b/arch/arm/configs/at91sam9x5ek_defconfig index 11d1e4511e..7b743abfaa 100644 --- a/arch/arm/configs/at91sam9x5ek_defconfig +++ b/arch/arm/configs/at91sam9x5ek_defconfig @@ -1,4 +1,3 @@ -CONFIG_ARCH_AT91SAM9X5=y CONFIG_AT91_MULTI_BOARDS=y CONFIG_MACH_AT91SAM9X5EK=y CONFIG_BAREBOX_MAX_IMAGE_SIZE=0x40000 diff --git a/arch/arm/configs/freescale-mx21-ads_defconfig b/arch/arm/configs/freescale-mx21-ads_defconfig index e1843db3e2..b1d37f76a8 100644 --- a/arch/arm/configs/freescale-mx21-ads_defconfig +++ b/arch/arm/configs/freescale-mx21-ads_defconfig @@ -1,6 +1,5 @@ CONFIG_TEXT_BASE=0xc3000000 CONFIG_ARCH_IMX=y -CONFIG_MACH_IMX21ADS=y CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y CONFIG_MALLOC_SIZE=0x2000000 CONFIG_CMDLINE_EDITING=y diff --git a/arch/arm/configs/imx_defconfig b/arch/arm/configs/imx_defconfig index 02e33e122e..e6333220b6 100644 --- a/arch/arm/configs/imx_defconfig +++ b/arch/arm/configs/imx_defconfig @@ -13,7 +13,6 @@ CONFIG_MMU=y CONFIG_MALLOC_SIZE=0x0 CONFIG_MALLOC_TLSF=y CONFIG_KALLSYMS=y -CONFIG_RELOCATABLE=y CONFIG_PANIC_HANG=y CONFIG_HUSH_FANCY_PROMPT=y CONFIG_CMDLINE_EDITING=y diff --git a/arch/arm/configs/imx_v8_defconfig b/arch/arm/configs/imx_v8_defconfig index 7e3bfadd9e..a7e890ee99 100644 --- a/arch/arm/configs/imx_v8_defconfig +++ b/arch/arm/configs/imx_v8_defconfig @@ -10,7 +10,6 @@ CONFIG_MMU=y CONFIG_MALLOC_SIZE=0x0 CONFIG_MALLOC_TLSF=y CONFIG_KALLSYMS=y -CONFIG_RELOCATABLE=y CONFIG_HUSH_FANCY_PROMPT=y CONFIG_AUTO_COMPLETE=y CONFIG_MENU=y @@ -129,7 +128,6 @@ CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_DS1307=y CONFIG_GENERIC_PHY=y CONFIG_USB_NOP_XCEIV=y -CONFIG_PHY_FSL_IMX8MQ_USB=y CONFIG_FS_EXT4=y CONFIG_FS_TFTP=y CONFIG_FS_NFS=y diff --git a/arch/arm/configs/kindle-mx50_defconfig b/arch/arm/configs/kindle-mx50_defconfig index 552b2d6d33..95fafd56e6 100644 --- a/arch/arm/configs/kindle-mx50_defconfig +++ b/arch/arm/configs/kindle-mx50_defconfig @@ -9,7 +9,6 @@ CONFIG_MMU=y CONFIG_MALLOC_SIZE=0x0 CONFIG_MALLOC_TLSF=y CONFIG_KALLSYMS=y -CONFIG_RELOCATABLE=y CONFIG_HUSH_FANCY_PROMPT=y CONFIG_CMDLINE_EDITING=y CONFIG_AUTO_COMPLETE=y diff --git a/arch/arm/configs/layerscape_defconfig b/arch/arm/configs/layerscape_defconfig index b36f1944ec..394cd95c98 100644 --- a/arch/arm/configs/layerscape_defconfig +++ b/arch/arm/configs/layerscape_defconfig @@ -78,7 +78,6 @@ CONFIG_CMD_OFTREE=y CONFIG_CMD_TIME=y CONFIG_NET=y CONFIG_NET_NETCONSOLE=y -CONFIG_OFDEVICE=y CONFIG_OF_BAREBOX_DRIVERS=y CONFIG_DRIVER_SERIAL_NS16550=y CONFIG_DRIVER_NET_FSL_FMAN=y @@ -105,7 +104,6 @@ CONFIG_EEPROM_AT24=y CONFIG_WATCHDOG=y CONFIG_WATCHDOG_IMX=y CONFIG_GPIO_PCA953X=y -CONFIG_NVMEM=y CONFIG_REGULATOR=y CONFIG_REGULATOR_FIXED=y CONFIG_FS_EXT4=y diff --git a/arch/arm/configs/microchip_ksz9477_evb_defconfig b/arch/arm/configs/microchip_ksz9477_evb_defconfig index 4189b2c039..7130499490 100644 --- a/arch/arm/configs/microchip_ksz9477_evb_defconfig +++ b/arch/arm/configs/microchip_ksz9477_evb_defconfig @@ -1,4 +1,3 @@ -CONFIG_ARCH_SAMA5D3=y CONFIG_AT91_MULTI_BOARDS=y CONFIG_MACH_MICROCHIP_KSZ9477_EVB=y CONFIG_AEABI=y diff --git a/arch/arm/configs/socfpga-arria10_defconfig b/arch/arm/configs/socfpga-arria10_defconfig index e47a0ab183..a37bae6217 100644 --- a/arch/arm/configs/socfpga-arria10_defconfig +++ b/arch/arm/configs/socfpga-arria10_defconfig @@ -18,7 +18,6 @@ CONFIG_BOOTM_INITRD=y CONFIG_BOOTM_OFTREE=y CONFIG_DEFAULT_COMPRESSION_LZO=y CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y -CONFIG_POLLER=y CONFIG_STATE=y CONFIG_LONGHELP=y CONFIG_CMD_IOMEM=y diff --git a/arch/arm/configs/virt2real_defconfig b/arch/arm/configs/virt2real_defconfig index 814fe69e42..62315b8cb3 100644 --- a/arch/arm/configs/virt2real_defconfig +++ b/arch/arm/configs/virt2real_defconfig @@ -36,7 +36,6 @@ CONFIG_CMD_LED=y CONFIG_CMD_OF_NODE=y CONFIG_CMD_OF_PROPERTY=y CONFIG_CMD_OFTREE=y -CONFIG_OFDEVICE=y CONFIG_OF_BAREBOX_DRIVERS=y CONFIG_DRIVER_SERIAL_NS16550=y # CONFIG_SPI is not set diff --git a/arch/arm/configs/zii_vf610_dev_defconfig b/arch/arm/configs/zii_vf610_dev_defconfig index 45c24d6df4..3ed5d37458 100644 --- a/arch/arm/configs/zii_vf610_dev_defconfig +++ b/arch/arm/configs/zii_vf610_dev_defconfig @@ -8,7 +8,6 @@ CONFIG_MMU=y CONFIG_MALLOC_SIZE=0x0 CONFIG_MALLOC_TLSF=y CONFIG_KALLSYMS=y -CONFIG_RELOCATABLE=y CONFIG_HUSH_FANCY_PROMPT=y CONFIG_AUTO_COMPLETE=y CONFIG_MENU=y diff --git a/arch/kvx/configs/generic_defconfig b/arch/kvx/configs/generic_defconfig index 8162171741..0d971ff3d5 100644 --- a/arch/kvx/configs/generic_defconfig +++ b/arch/kvx/configs/generic_defconfig @@ -1,15 +1,13 @@ CONFIG_AUTO_COMPLETE=y -CONFIG_BAUDRATE=115200 -CONFIG_CLOCKSOURCE_KVX=y +CONFIG_CONSOLE_RATP=y CONFIG_CMD_BOOT=y -CONFIG_CMD_BOOTM=y +CONFIG_CMD_RESET=y CONFIG_CMD_CMP=y -CONFIG_CMD_OF_DUMP=y CONFIG_CMD_POWEROFF=y -CONFIG_CMD_RESET=y CONFIG_CMD_WD=y -CONFIG_CONSOLE_RATP=y +CONFIG_CMD_OF_DUMP=y CONFIG_DRIVER_SERIAL_NS16550=y -CONFIG_PINCTRL_SINGLE=y +CONFIG_CLOCKSOURCE_KVX=y CONFIG_WATCHDOG=y CONFIG_WATCHDOG_KVX=y +CONFIG_PINCTRL_SINGLE=y diff --git a/arch/mips/configs/bcm47xx_defconfig b/arch/mips/configs/bcm47xx_defconfig index 0cd0e9e650..9cf172a70e 100644 --- a/arch/mips/configs/bcm47xx_defconfig +++ b/arch/mips/configs/bcm47xx_defconfig @@ -9,7 +9,6 @@ CONFIG_MENU=y CONFIG_BOOTM_SHOW_TYPE=y CONFIG_PARTITION=y # CONFIG_DEFAULT_ENVIRONMENT is not set -CONFIG_POLLER=y CONFIG_LONGHELP=y CONFIG_CMD_IOMEM=y CONFIG_CMD_MEMINFO=y diff --git a/arch/mips/configs/qemu-malta_defconfig b/arch/mips/configs/qemu-malta_defconfig index 2465c0260d..ac0577c217 100644 --- a/arch/mips/configs/qemu-malta_defconfig +++ b/arch/mips/configs/qemu-malta_defconfig @@ -12,7 +12,6 @@ CONFIG_BOOTM_SHOW_TYPE=y CONFIG_CONSOLE_ALLOW_COLOR=y CONFIG_PARTITION=y CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y -CONFIG_POLLER=y CONFIG_CMD_DMESG=y CONFIG_LONGHELP=y CONFIG_CMD_IOMEM=y diff --git a/arch/x86/configs/efi_defconfig b/arch/x86/configs/efi_defconfig index 47842d10af..99bc39eaa6 100644 --- a/arch/x86/configs/efi_defconfig +++ b/arch/x86/configs/efi_defconfig @@ -14,7 +14,6 @@ CONFIG_BLSPEC=y CONFIG_CONSOLE_ACTIVATE_ALL=y CONFIG_PARTITION_DISK_EFI=y CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y -CONFIG_POLLER=y CONFIG_STATE=y CONFIG_DEBUG_LL=y CONFIG_LONGHELP=y -- cgit v1.2.3 From a1b04c33faacbcc5bc4e7e3855914c51616a3a98 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Fri, 18 Sep 2020 13:04:42 +0200 Subject: x86/config/efi: drop DRIVER_SERIAL_NS16550 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For most machines having DRIVER_SERIAL_NS16550 and DRIVER_SERIAL_EFI_STDIO both enabled results in the output appearing twice on the serial output. So remove disable the lowlevel driver and rely on the EFI bios for serial. Signed-off-by: Uwe Kleine-König Signed-off-by: Sascha Hauer --- arch/x86/configs/efi_defconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/x86/configs/efi_defconfig b/arch/x86/configs/efi_defconfig index 99bc39eaa6..83794d7a07 100644 --- a/arch/x86/configs/efi_defconfig +++ b/arch/x86/configs/efi_defconfig @@ -65,7 +65,6 @@ CONFIG_NET=y CONFIG_NET_NFS=y CONFIG_NET_NETCONSOLE=y CONFIG_DRIVER_SERIAL_EFI_STDIO=y -CONFIG_DRIVER_SERIAL_NS16550=y CONFIG_DRIVER_NET_EFI_SNP=y # CONFIG_SPI is not set CONFIG_DISK=y -- cgit v1.2.3 From 1c2a23346bd1fa727837bea9be657f4b6f28d53d Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 27 Aug 2020 10:43:30 +0200 Subject: clk_dump command: Allow printing a single clock So far the clk_dump command can only print all clocks. With this patch we can limit the output to ancestors and children of a given clock. This makes it easier to find the desired information in big clock trees. Signed-off-by: Sascha Hauer --- commands/clk.c | 15 +++++++++++++-- drivers/clk/clk.c | 50 +++++++++++++++++++++++++++++++++++++++++++++----- include/linux/clk.h | 1 + 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/commands/clk.c b/commands/clk.c index 47159dddd2..649a0a7cb2 100644 --- a/commands/clk.c +++ b/commands/clk.c @@ -139,6 +139,7 @@ BAREBOX_CMD_END static int do_clk_dump(int argc, char *argv[]) { int opt, verbose = 0; + struct clk *clk; while ((opt = getopt(argc, argv, "v")) > 0) { switch(opt) { @@ -151,7 +152,16 @@ static int do_clk_dump(int argc, char *argv[]) } } - clk_dump(verbose); + if (optind == argc) { + clk_dump(verbose); + return COMMAND_SUCCESS; + } + + clk = clk_lookup(argv[optind]); + if (IS_ERR(clk)) + return PTR_ERR(clk); + + clk_dump_one(clk, verbose); return COMMAND_SUCCESS; } @@ -164,9 +174,10 @@ BAREBOX_CMD_HELP_END BAREBOX_CMD_START(clk_dump) .cmd = do_clk_dump, BAREBOX_CMD_DESC("show information about registered clocks") - BAREBOX_CMD_OPTS("[-v]") + BAREBOX_CMD_OPTS("[-v] [clkname]") BAREBOX_CMD_GROUP(CMD_GRP_INFO) BAREBOX_CMD_HELP(cmd_clk_dump_help) + BAREBOX_CMD_COMPLETE(clk_name_complete) BAREBOX_CMD_END static int do_clk_set_parent(int argc, char *argv[]) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index f2e459a760..b04d44593b 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -678,7 +678,6 @@ static const char *clk_hw_stat(struct clk *clk) static void dump_one(struct clk *clk, int verbose, int indent) { - struct clk *c; int enabled = clk_is_enabled(clk); const char *hwstat, *stat; @@ -705,13 +704,19 @@ static void dump_one(struct clk *clk, int verbose, int indent) printf("\n"); } } +} + +static void dump_subtree(struct clk *clk, int verbose, int indent) +{ + struct clk *c; + + dump_one(clk, verbose, indent); list_for_each_entry(c, &clks, list) { struct clk *parent = clk_get_parent(c); - if (parent == clk) { - dump_one(c, verbose, indent + 1); - } + if (parent == clk) + dump_subtree(c, verbose, indent + 1); } } @@ -723,7 +728,42 @@ void clk_dump(int verbose) struct clk *parent = clk_get_parent(c); if (IS_ERR_OR_NULL(parent)) - dump_one(c, verbose, 0); + dump_subtree(c, verbose, 0); + } +} + +static int clk_print_parent(struct clk *clk, int verbose) +{ + struct clk *c; + int indent; + + c = clk_get_parent(clk); + if (IS_ERR_OR_NULL(c)) + return 0; + + indent = clk_print_parent(c, verbose); + + dump_one(c, verbose, indent); + + return indent + 1; +} + +void clk_dump_one(struct clk *clk, int verbose) +{ + int indent; + struct clk *c; + + indent = clk_print_parent(clk, verbose); + + printf("\033[1m"); + dump_one(clk, verbose, indent); + printf("\033[0m"); + + list_for_each_entry(c, &clks, list) { + struct clk *parent = clk_get_parent(c); + + if (parent == clk) + dump_subtree(c, verbose, indent + 1); } } diff --git a/include/linux/clk.h b/include/linux/clk.h index 868bf3e4ed..3d66343e8d 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -456,6 +456,7 @@ int clk_register(struct clk *clk); struct clk *clk_lookup(const char *name); void clk_dump(int verbose); +void clk_dump_one(struct clk *clk, int verbose); struct clk *clk_register_composite(const char *name, const char * const *parent_names, int num_parents, -- cgit v1.2.3 From 76cff1a4ae09964cd59fc26e22efda9436e325a2 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 27 Aug 2020 09:32:05 +0200 Subject: usb: dwc3: Whitespace cleanup Replace spaces with tabs. Signed-off-by: Sascha Hauer --- drivers/usb/dwc3/dwc3-of-simple.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c index e58d9f95fe..a0aab4f114 100644 --- a/drivers/usb/dwc3/dwc3-of-simple.c +++ b/drivers/usb/dwc3/dwc3-of-simple.c @@ -70,7 +70,7 @@ static int dwc3_of_simple_probe(struct device_d *dev) if (!simple) return -ENOMEM; - dev->priv = simple; + dev->priv = simple; simple->dev = dev; ret = dwc3_of_simple_clk_init(simple, of_count_phandle_with_args(np, @@ -78,7 +78,7 @@ static int dwc3_of_simple_probe(struct device_d *dev) if (ret) return ret; - ret = of_platform_populate(np, NULL, dev); + ret = of_platform_populate(np, NULL, dev); if (ret) { for (i = 0; i < simple->num_clocks; i++) { clk_disable(simple->clks[i]); @@ -87,7 +87,7 @@ static int dwc3_of_simple_probe(struct device_d *dev) return ret; } - return 0; + return 0; } static void dwc3_of_simple_remove(struct device_d *dev) -- cgit v1.2.3 From a16f065ae6c17704afe4ed6a4fd3772285a86e6e Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 27 Aug 2020 09:26:11 +0200 Subject: clk: Add clk_bulk_[get|put]_all() Signed-off-by: Sascha Hauer --- drivers/clk/clk-bulk.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/clk.h | 46 +++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) diff --git a/drivers/clk/clk-bulk.c b/drivers/clk/clk-bulk.c index ddbe32f9c2..b8db60dcbc 100644 --- a/drivers/clk/clk-bulk.c +++ b/drivers/clk/clk-bulk.c @@ -53,6 +53,86 @@ err: } EXPORT_SYMBOL(clk_bulk_get); +static int __must_check of_clk_bulk_get(struct device_node *np, int num_clks, + struct clk_bulk_data *clks) +{ + int ret; + int i; + + for (i = 0; i < num_clks; i++) { + clks[i].id = NULL; + clks[i].clk = NULL; + } + + for (i = 0; i < num_clks; i++) { + of_property_read_string_index(np, "clock-names", i, &clks[i].id); + clks[i].clk = of_clk_get(np, i); + if (IS_ERR(clks[i].clk)) { + ret = PTR_ERR(clks[i].clk); + pr_err("%pOF: Failed to get clk index: %d ret: %d\n", + np, i, ret); + clks[i].clk = NULL; + goto err; + } + } + + return 0; + +err: + clk_bulk_put(i, clks); + + return ret; +} + +static int __must_check of_clk_bulk_get_all(struct device_node *np, + struct clk_bulk_data **clks) +{ + struct clk_bulk_data *clk_bulk; + int num_clks; + int ret; + + num_clks = of_clk_get_parent_count(np); + if (!num_clks) + return 0; + + clk_bulk = kmalloc_array(num_clks, sizeof(*clk_bulk), GFP_KERNEL); + if (!clk_bulk) + return -ENOMEM; + + ret = of_clk_bulk_get(np, num_clks, clk_bulk); + if (ret) { + kfree(clk_bulk); + return ret; + } + + *clks = clk_bulk; + + return num_clks; +} + +void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks) +{ + if (IS_ERR_OR_NULL(clks)) + return; + + clk_bulk_put(num_clks, clks); + + kfree(clks); +} +EXPORT_SYMBOL(clk_bulk_put_all); + +int __must_check clk_bulk_get_all(struct device_d *dev, + struct clk_bulk_data **clks) +{ + struct device_node *np = dev->device_node; + + if (!np) + return 0; + + return of_clk_bulk_get_all(np, clks); +} +EXPORT_SYMBOL(clk_bulk_get_all); + /** * clk_bulk_disable - gate a set of clocks * @num_clks: the number of clk_bulk_data diff --git a/include/linux/clk.h b/include/linux/clk.h index 3d66343e8d..c49fe9a54c 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -82,6 +82,27 @@ struct clk *clk_get(struct device_d *dev, const char *id); int __must_check clk_bulk_get(struct device_d *dev, int num_clks, struct clk_bulk_data *clks); +/** + * clk_bulk_get_all - lookup and obtain all available references to clock + * producer. + * @dev: device for clock "consumer" + * @clks: pointer to the clk_bulk_data table of consumer + * + * This helper function allows drivers to get all clk consumers in one + * operation. If any of the clk cannot be acquired then any clks + * that were obtained will be freed before returning to the caller. + * + * Returns a positive value for the number of clocks obtained while the + * clock references are stored in the clk_bulk_data table in @clks field. + * Returns 0 if there're none and a negative value if something failed. + * + * Drivers must assume that the clock source is not enabled. + * + * clk_bulk_get should not be called from within interrupt context. + */ +int __must_check clk_bulk_get_all(struct device_d *dev, + struct clk_bulk_data **clks); + /** * clk_enable - inform the system when the clock source should be running. * @clk: clock source @@ -156,6 +177,19 @@ unsigned long clk_get_rate(struct clk *clk); */ void clk_bulk_put(int num_clks, struct clk_bulk_data *clks); +/** + * clk_bulk_put_all - "free" all the clock source + * @num_clks: the number of clk_bulk_data + * @clks: the clk_bulk_data table of consumer + * + * Note: drivers must ensure that all clk_bulk_enable calls made on this + * clock source are balanced by clk_bulk_disable calls prior to calling + * this function. + * + * clk_bulk_put_all should not be called from within interrupt context. + */ +void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks); + /* * The remaining APIs are optional for machine class support. */ @@ -240,8 +274,16 @@ static inline int __must_check clk_bulk_get(struct device_d *dev, int num_clks, return 0; } +static inline int __must_check clk_bulk_get_all(struct device_d *dev, + struct clk_bulk_data **clks) +{ + return 0; +} + static inline void clk_bulk_put(int num_clks, struct clk_bulk_data *clks) {} +static inline void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks) {} + static inline int clk_enable(struct clk *clk) { return 0; @@ -536,6 +578,10 @@ static inline struct clk *of_clk_get_by_name(struct device_node *np, { return ERR_PTR(-ENOENT); } +static inline unsigned int of_clk_get_parent_count(struct device_node *np) +{ + return 0; +} static inline int of_clk_init(struct device_node *root, const struct of_device_id *matches) { -- cgit v1.2.3 From 8fb0a2bf6efb67084a5d7a7f3822b4d480fca685 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 27 Aug 2020 09:31:04 +0200 Subject: usb: dwc3-of-simple: Use clk_bulk API Use clk_bulk_get_all() to retrieve all clocks rather than open code this. Also actually enable the clocks, previously they had been disabled in the error path, but never enabled before. Also this fixes a memory corruption: The driver populated an array of clks, but only allocated space for a single entry. Signed-off-by: Sascha Hauer --- drivers/usb/dwc3/dwc3-of-simple.c | 58 +++++++-------------------------------- 1 file changed, 10 insertions(+), 48 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c index a0aab4f114..ac16d22624 100644 --- a/drivers/usb/dwc3/dwc3-of-simple.c +++ b/drivers/usb/dwc3/dwc3-of-simple.c @@ -21,50 +21,16 @@ struct dwc3_of_simple { struct device_d *dev; - struct clk **clks; + struct clk_bulk_data *clks; int num_clocks; }; -static int dwc3_of_simple_clk_init(struct dwc3_of_simple *simple, int count) -{ - struct device_d *dev = simple->dev; - struct device_node *np = dev->device_node; - int i; - - simple->num_clocks = count; - - if (!count) - return 0; - - simple->clks = xzalloc(sizeof(struct clk *)); - if (!simple->clks) - return -ENOMEM; - - for (i = 0; i < simple->num_clocks; i++) { - struct clk *clk; - - clk = of_clk_get(np, i); - if (IS_ERR(clk)) { - while (--i >= 0) { - clk_disable(simple->clks[i]); - clk_put(simple->clks[i]); - } - return PTR_ERR(clk); - } - - simple->clks[i] = clk; - } - - return 0; -} - static int dwc3_of_simple_probe(struct device_d *dev) { struct dwc3_of_simple *simple; struct device_node *np = dev->device_node; int ret; - int i; simple = xzalloc(sizeof(*simple)); if (!simple) @@ -73,17 +39,18 @@ static int dwc3_of_simple_probe(struct device_d *dev) dev->priv = simple; simple->dev = dev; - ret = dwc3_of_simple_clk_init(simple, of_count_phandle_with_args(np, - "clocks", "#clock-cells")); + ret = clk_bulk_get_all(simple->dev, &simple->clks); + if (ret < 0) + return ret; + + simple->num_clocks = ret; + ret = clk_bulk_enable(simple->num_clocks, simple->clks); if (ret) return ret; - ret = of_platform_populate(np, NULL, dev); + ret = of_platform_populate(np, NULL, dev); if (ret) { - for (i = 0; i < simple->num_clocks; i++) { - clk_disable(simple->clks[i]); - clk_put(simple->clks[i]); - } + clk_bulk_disable(simple->num_clocks, simple->clks); return ret; } @@ -93,13 +60,8 @@ static int dwc3_of_simple_probe(struct device_d *dev) static void dwc3_of_simple_remove(struct device_d *dev) { struct dwc3_of_simple *simple = dev->priv; - int i; - for (i = 0; i < simple->num_clocks; i++) { - clk_disable(simple->clks[i]); - clk_put(simple->clks[i]); - } - simple->num_clocks = 0; + clk_bulk_disable(simple->num_clocks, simple->clks); } static const struct of_device_id of_dwc3_simple_match[] = { -- cgit v1.2.3