[PATCH v4 5/8] cmd: Move meminfo command into its own file
Ilias Apalodimas
ilias.apalodimas at linaro.org
Mon Oct 21 10:54:38 CEST 2024
On Mon, 21 Oct 2024 at 11:19, Simon Glass <sjg at chromium.org> wrote:
>
> In preparation for expanding this command, move it into a separate file.
> Rename the function to remove the extra underscore. Update the number of
> arguments to 1, since 3 is incorrect.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> (no changes since v2)
>
> Changes in v2:
> - Split into its own patch
>
> cmd/Kconfig | 1 +
> cmd/Makefile | 1 +
> cmd/mem.c | 19 -------------------
> cmd/meminfo.c | 26 ++++++++++++++++++++++++++
> 4 files changed, 28 insertions(+), 19 deletions(-)
> create mode 100644 cmd/meminfo.c
>
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index a4ca61c37dd..05bd3e8a5e2 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -885,6 +885,7 @@ config MD5SUM_VERIFY
>
> config CMD_MEMINFO
> bool "meminfo"
> + default y if SANDBOX
> help
> Display memory information.
>
> diff --git a/cmd/Makefile b/cmd/Makefile
> index 3c5bd56e912..16e275eba63 100644
> --- a/cmd/Makefile
> +++ b/cmd/Makefile
> @@ -110,6 +110,7 @@ obj-$(CONFIG_CMD_LOG) += log.o
> obj-$(CONFIG_CMD_LSBLK) += lsblk.o
> obj-$(CONFIG_CMD_MD5SUM) += md5sum.o
> obj-$(CONFIG_CMD_MEMORY) += mem.o
> +obj-$(CONFIG_CMD_MEMINFO) += meminfo.o
> obj-$(CONFIG_CMD_IO) += io.o
> obj-$(CONFIG_CMD_MII) += mii.o
> obj-$(CONFIG_CMD_MISC) += misc.o
> diff --git a/cmd/mem.c b/cmd/mem.c
> index 4d6fde28531..9e716776393 100644
> --- a/cmd/mem.c
> +++ b/cmd/mem.c
> @@ -1379,17 +1379,6 @@ U_BOOT_CMD(
>
> #endif
>
> -#ifdef CONFIG_CMD_MEMINFO
> -static int do_mem_info(struct cmd_tbl *cmdtp, int flag, int argc,
> - char *const argv[])
> -{
> - puts("DRAM: ");
> - print_size(gd->ram_size, "\n");
> -
> - return 0;
> -}
> -#endif
> -
> U_BOOT_CMD(
> base, 2, 1, do_mem_base,
> "print or set address offset",
> @@ -1433,14 +1422,6 @@ U_BOOT_CMD(
> );
> #endif /* CONFIG_CMD_MX_CYCLIC */
>
> -#ifdef CONFIG_CMD_MEMINFO
> -U_BOOT_CMD(
> - meminfo, 3, 1, do_mem_info,
> - "display memory information",
> - ""
> -);
> -#endif
> -
> #ifdef CONFIG_CMD_RANDOM
> U_BOOT_CMD(
> random, 4, 0, do_random,
> diff --git a/cmd/meminfo.c b/cmd/meminfo.c
> new file mode 100644
> index 00000000000..bb9bcec2e3f
> --- /dev/null
> +++ b/cmd/meminfo.c
> @@ -0,0 +1,26 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright 2024 Google LLC
> + * Written by Simon Glass <sjg at chromium.org>
> + */
> +
> +#include <command.h>
> +#include <display_options.h>
> +#include <asm/global_data.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +static int do_meminfo(struct cmd_tbl *cmdtp, int flag, int argc,
> + char *const argv[])
> +{
> + puts("DRAM: ");
> + print_size(gd->ram_size, "\n");
> +
> + return 0;
> +}
> +
> +U_BOOT_CMD(
> + meminfo, 1, 1, do_meminfo,
> + "display memory information",
> + ""
> +);
> --
> 2.43.0
>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
More information about the U-Boot
mailing list