[U-Boot] [PATCHv2 1/3] cmd: Move the "dm" command from test/dm/ to cmd/

The "dm" command under CONFIG_CMD_DM should live under cmd/ rather than test/dm/ so move it.
Signed-off-by: Tom Rini trini@konsulko.com --- cmd/Makefile | 1 + cmd/dm.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/dm/Makefile | 1 - test/dm/cmd_dm.c | 88 -------------------------------------------------------- 4 files changed, 89 insertions(+), 89 deletions(-) create mode 100644 cmd/dm.c delete mode 100644 test/dm/cmd_dm.c
diff --git a/cmd/Makefile b/cmd/Makefile index 49986437ba58..15ae4d250f50 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -40,6 +40,7 @@ obj-$(CONFIG_CMD_CPU) += cpu.o obj-$(CONFIG_DATAFLASH_MMC_SELECT) += dataflash_mmc_mux.o obj-$(CONFIG_CMD_DATE) += date.o obj-$(CONFIG_CMD_DEMO) += demo.o +obj-$(CONFIG_CMD_DM) += dm.o obj-$(CONFIG_CMD_SOUND) += sound.o ifdef CONFIG_POST obj-$(CONFIG_CMD_DIAG) += diag.o diff --git a/cmd/dm.c b/cmd/dm.c new file mode 100644 index 000000000000..7b271db0bbe7 --- /dev/null +++ b/cmd/dm.c @@ -0,0 +1,88 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2013 Google, Inc + * + * (C) Copyright 2012 + * Marek Vasut marex@denx.de + */ + +#include <common.h> +#include <command.h> +#include <dm.h> +#include <malloc.h> +#include <mapmem.h> +#include <errno.h> +#include <asm/io.h> +#include <dm/root.h> +#include <dm/util.h> + +static int do_dm_dump_all(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + dm_dump_all(); + + return 0; +} + +static int do_dm_dump_uclass(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + dm_dump_uclass(); + + return 0; +} + +static int do_dm_dump_devres(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + dm_dump_devres(); + + return 0; +} + +static cmd_tbl_t test_commands[] = { + U_BOOT_CMD_MKENT(tree, 0, 1, do_dm_dump_all, "", ""), + U_BOOT_CMD_MKENT(uclass, 1, 1, do_dm_dump_uclass, "", ""), + U_BOOT_CMD_MKENT(devres, 1, 1, do_dm_dump_devres, "", ""), +}; + +static __maybe_unused void dm_reloc(void) +{ + static int relocated; + + if (!relocated) { + fixup_cmdtable(test_commands, ARRAY_SIZE(test_commands)); + relocated = 1; + } +} + +static int do_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + cmd_tbl_t *test_cmd; + int ret; + +#ifdef CONFIG_NEEDS_MANUAL_RELOC + dm_reloc(); +#endif + + if (argc < 2) + return CMD_RET_USAGE; + test_cmd = find_cmd_tbl(argv[1], test_commands, + ARRAY_SIZE(test_commands)); + argc -= 2; + argv += 2; + if (!test_cmd || argc > test_cmd->maxargs) + return CMD_RET_USAGE; + + ret = test_cmd->cmd(test_cmd, flag, argc, argv); + + return cmd_process_error(test_cmd, ret); +} + +U_BOOT_CMD( + dm, 3, 1, do_dm, + "Driver model low level access", + "tree Dump driver model tree ('*' = activated)\n" + "dm uclass Dump list of instances for each uclass\n" + "dm devres Dump list of device resources for each device" +); diff --git a/test/dm/Makefile b/test/dm/Makefile index 2c9081e4dd66..42f1d81a33d2 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -2,7 +2,6 @@ # # Copyright (c) 2013 Google, Inc
-obj-$(CONFIG_CMD_DM) += cmd_dm.o obj-$(CONFIG_UT_DM) += bus.o obj-$(CONFIG_UT_DM) += test-driver.o obj-$(CONFIG_UT_DM) += test-fdt.o diff --git a/test/dm/cmd_dm.c b/test/dm/cmd_dm.c deleted file mode 100644 index 7b271db0bbe7..000000000000 --- a/test/dm/cmd_dm.c +++ /dev/null @@ -1,88 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Copyright (c) 2013 Google, Inc - * - * (C) Copyright 2012 - * Marek Vasut marex@denx.de - */ - -#include <common.h> -#include <command.h> -#include <dm.h> -#include <malloc.h> -#include <mapmem.h> -#include <errno.h> -#include <asm/io.h> -#include <dm/root.h> -#include <dm/util.h> - -static int do_dm_dump_all(cmd_tbl_t *cmdtp, int flag, int argc, - char * const argv[]) -{ - dm_dump_all(); - - return 0; -} - -static int do_dm_dump_uclass(cmd_tbl_t *cmdtp, int flag, int argc, - char * const argv[]) -{ - dm_dump_uclass(); - - return 0; -} - -static int do_dm_dump_devres(cmd_tbl_t *cmdtp, int flag, int argc, - char * const argv[]) -{ - dm_dump_devres(); - - return 0; -} - -static cmd_tbl_t test_commands[] = { - U_BOOT_CMD_MKENT(tree, 0, 1, do_dm_dump_all, "", ""), - U_BOOT_CMD_MKENT(uclass, 1, 1, do_dm_dump_uclass, "", ""), - U_BOOT_CMD_MKENT(devres, 1, 1, do_dm_dump_devres, "", ""), -}; - -static __maybe_unused void dm_reloc(void) -{ - static int relocated; - - if (!relocated) { - fixup_cmdtable(test_commands, ARRAY_SIZE(test_commands)); - relocated = 1; - } -} - -static int do_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) -{ - cmd_tbl_t *test_cmd; - int ret; - -#ifdef CONFIG_NEEDS_MANUAL_RELOC - dm_reloc(); -#endif - - if (argc < 2) - return CMD_RET_USAGE; - test_cmd = find_cmd_tbl(argv[1], test_commands, - ARRAY_SIZE(test_commands)); - argc -= 2; - argv += 2; - if (!test_cmd || argc > test_cmd->maxargs) - return CMD_RET_USAGE; - - ret = test_cmd->cmd(test_cmd, flag, argc, argv); - - return cmd_process_error(test_cmd, ret); -} - -U_BOOT_CMD( - dm, 3, 1, do_dm, - "Driver model low level access", - "tree Dump driver model tree ('*' = activated)\n" - "dm uclass Dump list of instances for each uclass\n" - "dm devres Dump list of device resources for each device" -);

The contents of the test subdirectories only make sense when we have CONFIG_UNIT_TEST set. We will otherwise attempt to build code on for example sandbox that needs CONFIG_UNIT_TEST otherwise and rather than complicate the Makefiles simply leave them out when we can.
Signed-off-by: Tom Rini trini@konsulko.com --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/Makefile b/Makefile index 0d11ff97971a..02326bea5f64 100644 --- a/Makefile +++ b/Makefile @@ -725,8 +725,7 @@ libs-y += common/ libs-y += env/ libs-$(CONFIG_API) += api/ libs-$(CONFIG_HAS_POST) += post/ -libs-y += test/ -libs-y += test/dm/ +libs-$(CONFIG_UNIT_TEST) += test/ test/dm/ libs-$(CONFIG_UT_ENV) += test/env/ libs-$(CONFIG_UT_OVERLAY) += test/overlay/

On Fri, Dec 07, 2018 at 07:00:40PM -0500, Tom Rini wrote:
The contents of the test subdirectories only make sense when we have CONFIG_UNIT_TEST set. We will otherwise attempt to build code on for example sandbox that needs CONFIG_UNIT_TEST otherwise and rather than complicate the Makefiles simply leave them out when we can.
Signed-off-by: Tom Rini trini@konsulko.com
Applied to u-boot/master, thanks!

From: Otavio Salvador otavio@ossystems.com.br
The motivation for this is to allow distributions to distribute all possible tools in a generic way, avoiding the need of specific tools building for each machine.
Especially on OpenEmbedded / Yocto Project ecosystem, it is very common each BSP to end providing their specific tools when they need to generate images for some SoC (e.g MX23 / MX28 in meta-freescale case).
Using this, we can package the tools doing:
$: make tools-only_defconfig $: make tools-only
Signed-off-by: Otavio Salvador otavio@ossystems.com.br [trini: Add MAINTAINERS entry for myself, add to .travis.yml, make U-Boot itself buildable to not trip up other frameworks] Signed-off-by: Tom Rini trini@konsulko.com --- .travis.yml | 4 ++++ MAINTAINERS | 1 + configs/tools-only_defconfig | 24 ++++++++++++++++++++++++ tools/Makefile | 2 +- 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 configs/tools-only_defconfig
diff --git a/.travis.yml b/.travis.yml index ed07d817fa47..f43a272b3231 100644 --- a/.travis.yml +++ b/.travis.yml @@ -332,6 +332,10 @@ matrix: - name: "sloccount" script: - sloccount . + # Ensure host tools build + - name: "Build tools-only" + script: + - make tools-only_config tools-only -j$(nproc)
# test/py - name: "test/py sandbox" diff --git a/MAINTAINERS b/MAINTAINERS index 0cec39c542db..0fb089807c57 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -719,5 +719,6 @@ L: u-boot@lists.denx.de Q: http://patchwork.ozlabs.org/project/uboot/list/ S: Maintained T: git git://git.denx.de/u-boot.git +F: configs/tools-only_defconfig F: * F: */ diff --git a/configs/tools-only_defconfig b/configs/tools-only_defconfig new file mode 100644 index 000000000000..fb0607678541 --- /dev/null +++ b/configs/tools-only_defconfig @@ -0,0 +1,24 @@ +CONFIG_SYS_TEXT_BASE=0 +CONFIG_ANDROID_BOOT_IMAGE=y +CONFIG_FIT=y +CONFIG_FIT_SIGNATURE=y +# CONFIG_CMD_BOOTD is not set +# CONFIG_CMD_BOOTM is not set +# CONFIG_CMD_ELF is not set +# CONFIG_CMD_DATE is not set +CONFIG_OF_CONTROL=y +CONFIG_OF_HOSTFILE=y +CONFIG_DEFAULT_DEVICE_TREE="sandbox" +# CONFIG_UDP_FUNCTION_FASTBOOT is not set +CONFIG_SANDBOX_GPIO=y +CONFIG_DM_I2C_COMPAT=y +CONFIG_PCI=y +CONFIG_DM_PCI=y +CONFIG_PCI_SANDBOX=y +CONFIG_DM_RTC=y +CONFIG_SOUND=y +CONFIG_SYSRESET=y +# CONFIG_VIRTIO_MMIO is not set +# CONFIG_VIRTIO_PCI is not set +# CONFIG_VIRTIO_SANDBOX is not set +# CONFIG_EFI_LOADER is not set diff --git a/tools/Makefile b/tools/Makefile index c93d17a42fdf..29ff6ed221b1 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -125,7 +125,7 @@ fit_info-objs := $(dumpimage-mkimage-objs) fit_info.o fit_check_sign-objs := $(dumpimage-mkimage-objs) fit_check_sign.o file2include-objs := file2include.o
-ifneq ($(CONFIG_MX23)$(CONFIG_MX28),) +ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_FIT_SIGNATURE),) # Add CONFIG_MXS into host CFLAGS, so we can check whether or not register # the mxsimage support within tools/mxsimage.c . HOSTCFLAGS_mxsimage.o += -DCONFIG_MXS

On Fri, Dec 07, 2018 at 07:00:41PM -0500, Tom Rini wrote:
From: Otavio Salvador otavio@ossystems.com.br
The motivation for this is to allow distributions to distribute all possible tools in a generic way, avoiding the need of specific tools building for each machine.
Especially on OpenEmbedded / Yocto Project ecosystem, it is very common each BSP to end providing their specific tools when they need to generate images for some SoC (e.g MX23 / MX28 in meta-freescale case).
Using this, we can package the tools doing:
$: make tools-only_defconfig $: make tools-only
Signed-off-by: Otavio Salvador otavio@ossystems.com.br [trini: Add MAINTAINERS entry for myself, add to .travis.yml, make U-Boot itself buildable to not trip up other frameworks] Signed-off-by: Tom Rini trini@konsulko.com
Applied to u-boot/master, thanks!

On Fri, Dec 07, 2018 at 07:00:39PM -0500, Tom Rini wrote:
The "dm" command under CONFIG_CMD_DM should live under cmd/ rather than test/dm/ so move it.
Signed-off-by: Tom Rini trini@konsulko.com
Applied to u-boot/master, thanks!
participants (1)
-
Tom Rini