From e288366364c39f684a0c4a0ea9336f0873cb9b67 Mon Sep 17 00:00:00 2001 From: "J. Neuschäfer" Date: Wed, 11 Dec 2024 23:25:25 +0100 Subject: cmd: ufetch: Fix type mismatch on 32-bit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 32-bit architectures, LAST_LINE (_LAST_LINE - 1UL) is 64 bits long, but size_t (from ARRAY_SIZE(...)) is 32 bits. This results in a warning because the max() macro expects the same type on both sides: cmd/ufetch.c: In function ‘do_ufetch’: include/linux/kernel.h:179:24: warning: comparison of distinct pointer types lacks a cast [-Wcompare-distinct-pointer-types] 179 | (void) (&_max1 == &_max2); \ | ^~ cmd/ufetch.c:92:25: note: in expansion of macro ‘max’ 92 | int num_lines = max(LAST_LINE + 1, ARRAY_SIZE(logo_lines)); | ^~~ Fix this by casting LAST_LINE to size_t. Reviewed-by: Caleb Connolly Signed-off-by: J. Neuschäfer Link: https://lore.kernel.org/r/20241211-ufetch-v2-1-2b5432ffaeb1@posteo.net Signed-off-by: Caleb Connolly --- cmd/ufetch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/ufetch.c b/cmd/ufetch.c index 0b825d7e8c7..5f3ef847b26 100644 --- a/cmd/ufetch.c +++ b/cmd/ufetch.c @@ -89,7 +89,7 @@ enum output_lines { static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - int num_lines = max(LAST_LINE + 1, ARRAY_SIZE(logo_lines)); + int num_lines = max((size_t)LAST_LINE + 1, ARRAY_SIZE(logo_lines)); const char *model, *compatible; char *ipaddr; int n_cmds, n_cpus = 0, ret, compatlen; -- cgit v1.3.1 From c38d5bad35078c9e6c38f1c84b366fddd75af302 Mon Sep 17 00:00:00 2001 From: "J. Neuschäfer" Date: Wed, 11 Dec 2024 23:25:26 +0100 Subject: cmd: Allow building ufetch without CONFIG_BLK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ufetch command is still quite useful on systems without block device support; remove the CONFIG_BLK dependency and make sure the code compiles/works with and without CONFIG_BLK. Reviewed-by: Caleb Connolly Signed-off-by: J. Neuschäfer Link: https://lore.kernel.org/r/20241211-ufetch-v2-2-2b5432ffaeb1@posteo.net Signed-off-by: Caleb Connolly --- cmd/Kconfig | 1 - cmd/ufetch.c | 13 +++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'cmd') diff --git a/cmd/Kconfig b/cmd/Kconfig index 864b6d464ba..2a5a77f0064 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -178,7 +178,6 @@ config CMD_CPU config CMD_UFETCH bool "U-Boot fetch" - depends on BLK help Fetch utility for U-Boot (akin to neofetch). Prints information about U-Boot and the board it is running on in a pleasing format. diff --git a/cmd/ufetch.c b/cmd/ufetch.c index 5f3ef847b26..83cec0f6d5c 100644 --- a/cmd/ufetch.c +++ b/cmd/ufetch.c @@ -92,11 +92,9 @@ static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc, int num_lines = max((size_t)LAST_LINE + 1, ARRAY_SIZE(logo_lines)); const char *model, *compatible; char *ipaddr; - int n_cmds, n_cpus = 0, ret, compatlen; + int n_cmds, n_cpus = 0, compatlen; size_t size; ofnode np; - struct udevice *dev; - struct blk_desc *desc; bool skip_ascii = false; if (argc > 1 && strcmp(argv[1], "-n") == 0) { @@ -199,7 +197,12 @@ static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc, print_size(size, "\n"); break; case STORAGE: - default: + default: { +#ifdef CONFIG_BLK + struct udevice *dev; + struct blk_desc *desc; + int ret; + ret = uclass_find_device_by_seq(UCLASS_BLK, line - STORAGE, &dev); if (!ret && dev) { desc = dev_get_uclass_plat(dev); @@ -213,8 +216,10 @@ static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc, } else if (ret == -ENODEV && (skip_ascii || line > ARRAY_SIZE(logo_lines))) { break; } +#endif printf("\n"); } + } } printf(RESET "\n\n"); -- cgit v1.3.1 From 3db33a6fd69078c5b77b32fe7eaede4ec08a9471 Mon Sep 17 00:00:00 2001 From: "J. Neuschäfer" Date: Wed, 11 Dec 2024 23:25:27 +0100 Subject: cmd: ufetch: Show CPU architecture under "CPU" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When looking at ufetch output it isn't immediately obvious which CPU architecture the presented board has. This patch therefore adds the CPU architecture string (for example "powerpc") to the "CPU:" line. The new format is: CPU: powerpc (1 cores, 1 in use) Signed-off-by: J. Neuschäfer Reviewed-by: Caleb Connolly Link: https://lore.kernel.org/r/20241211-ufetch-v2-3-2b5432ffaeb1@posteo.net Signed-off-by: Caleb Connolly --- cmd/ufetch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/ufetch.c b/cmd/ufetch.c index 83cec0f6d5c..ed5a856c7ab 100644 --- a/cmd/ufetch.c +++ b/cmd/ufetch.c @@ -188,7 +188,7 @@ static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc, if (ofnode_name_eq(np, "cpu")) n_cpus++; } - printf("CPU:" RESET " %d (1 in use)\n", n_cpus); + printf("CPU: " RESET CONFIG_SYS_ARCH " (%d cores, 1 in use)\n", n_cpus); break; case MEMORY: for (int j = 0; j < CONFIG_NR_DRAM_BANKS && gd->bd->bi_dram[j].size; j++) -- cgit v1.3.1