X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=cmd%2Fcpu.c;h=ff553c16c4e4107125bde4785b8ca906dda59891;hb=09140113108541b95d340f3c7b6ee597d31ccc73;hp=bc4dc5c529b87565c36c7d289e47a7e9533edfd4;hpb=312a6c016a2d81aa3fbc605f5c0c315b6a4e3464;p=oweals%2Fu-boot.git diff --git a/cmd/cpu.c b/cmd/cpu.c index bc4dc5c529..ff553c16c4 100644 --- a/cmd/cpu.c +++ b/cmd/cpu.c @@ -1,8 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (c) 2015 Google, Inc * Written by Simon Glass - * - * SPDX-License-Identifier: GPL-2.0+ + * Copyright (c) 2017 Álvaro Fernández Rojas */ #include @@ -15,25 +15,21 @@ static const char *cpu_feature_name[CPU_FEAT_COUNT] = { "L1 cache", "MMU", "Microcode", + "Device ID", }; static int print_cpu_list(bool detail) { struct udevice *dev; - struct uclass *uc; char buf[100]; - int ret; - ret = uclass_get(UCLASS_CPU, &uc); - if (ret) { - printf("Cannot find CPU uclass\n"); - return ret; - } - uclass_foreach_dev(dev, uc) { + for (uclass_first_device(UCLASS_CPU, &dev); + dev; + uclass_next_device(&dev)) { struct cpu_platdata *plat = dev_get_parent_platdata(dev); struct cpu_info info; - bool first; - int i; + bool first = true; + int ret, i; ret = cpu_get_desc(dev, buf, sizeof(buf)); printf("%3d: %-10s %s\n", dev->seq, dev->name, @@ -44,13 +40,12 @@ static int print_cpu_list(bool detail) if (ret) { printf("\t(no detail available"); if (ret != -ENOSYS) - printf(": err=%d\n", ret); + printf(": err=%d", ret); printf(")\n"); continue; } printf("\tID = %d, freq = ", plat->cpu_id); print_freq(info.cpu_freq, ""); - first = true; for (i = 0; i < CPU_FEAT_COUNT; i++) { if (info.features & (1 << i)) { printf("%s%s", first ? ": " : ", ", @@ -59,10 +54,9 @@ static int print_cpu_list(bool detail) } } printf("\n"); - if (info.features & (1 << CPU_FEAT_UCODE)) { + if (info.features & (1 << CPU_FEAT_UCODE)) printf("\tMicrocode version %#x\n", plat->ucode_version); - } if (info.features & (1 << CPU_FEAT_DEVICE_ID)) printf("\tDevice ID %#lx\n", plat->device_id); } @@ -70,7 +64,8 @@ static int print_cpu_list(bool detail) return 0; } -static int do_cpu_list(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +static int do_cpu_list(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) { if (print_cpu_list(false)) return CMD_RET_FAILURE; @@ -78,7 +73,7 @@ static int do_cpu_list(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) return 0; } -static int do_cpu_detail(cmd_tbl_t *cmdtp, int flag, int argc, +static int do_cpu_detail(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { if (print_cpu_list(true)) @@ -87,7 +82,7 @@ static int do_cpu_detail(cmd_tbl_t *cmdtp, int flag, int argc, return 0; } -static cmd_tbl_t cmd_cpu_sub[] = { +static struct cmd_tbl cmd_cpu_sub[] = { U_BOOT_CMD_MKENT(list, 2, 1, do_cpu_list, "", ""), U_BOOT_CMD_MKENT(detail, 4, 0, do_cpu_detail, "", ""), }; @@ -95,17 +90,18 @@ static cmd_tbl_t cmd_cpu_sub[] = { /* * Process a cpu sub-command */ -static int do_cpu(cmd_tbl_t *cmdtp, int flag, int argc, - char * const argv[]) +static int do_cpu(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) { - cmd_tbl_t *c = NULL; + struct cmd_tbl *c = NULL; /* Strip off leading 'cpu' command argument */ argc--; argv++; if (argc) - c = find_cmd_tbl(argv[0], cmd_cpu_sub, ARRAY_SIZE(cmd_cpu_sub)); + c = find_cmd_tbl(argv[0], cmd_cpu_sub, + ARRAY_SIZE(cmd_cpu_sub)); if (c) return c->cmd(cmdtp, flag, argc, argv);