Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 223DAC433F5 for ; Tue, 31 May 2022 18:15:31 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6D36583F40; Tue, 31 May 2022 20:15:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kiEu7kVv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9536F83D84; Tue, 31 May 2022 20:15:16 +0200 (CEST) Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C820883B15 for ; Tue, 31 May 2022 20:14:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ovpanait@gmail.com Received: by mail-wr1-x42b.google.com with SMTP id k19so11582747wrd.8 for ; Tue, 31 May 2022 11:14:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ullOEFmXm+Ed83WlLyGGwGuL1P6pLE4A8ILpeXizkIc=; b=kiEu7kVvmo/E2tlmjoFuobdpguqoqaA0qRTRsJg7+TLYW+rWzZ9WdBb2ZwRZpk8FZe aI062BOgVlr2HxyGDostTBx95jng7XwibvUuycb4U43Ox26cZm4Vjmi1MLtaUyo62/Jt ZpzB+K+lGheDyLJIfo4JqfbzjJOopqJFkOmp8wVQS7+6BhdGm0MZx310iTj11BdxkxSP LJaDojUto9BfKQlNc06bM8cxuD7y7Bw6zLVYTvbeI4HNwfJ4NRGxpCnK3lBn9o+3DUNF 7MHze4tW4l1NGke8RQDGagu6wY0CQAHaFw9Edbhd+P5VFFS4KDNnTGZtAZE7P8ebwPTc s32w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ullOEFmXm+Ed83WlLyGGwGuL1P6pLE4A8ILpeXizkIc=; b=Xd3s7FdDV/mzT5yDRWM/aJNzp0lBhV12Lu51xMqMzx8akjlQftg1fhGYom9bPiLIiB aHUYDnD0P/a8ep+qkuzv5+XfbhYxndM6NigxOj3Bc00TVh3WV+QXx3rdHsmWD5YkB8qv egnOlPyqDULLtQ/KNcNpJ6O2C//cytTzM2nPcN22GatlKrUnxoP7Cn9NDBe8v8vVQJbB ElEuMBQpTbREj9YL7avaJiUq4jnkyyb9h8ewZ20hVPKlscA50B+z6nVsKvZMGx1Gik+T 05LHwqilM9gRE96VcqOUGfVvyUn32xPUQrsPa4QrTJ6NJRdq5sEveSuE+1EkF2T5CE2h 6FAw== X-Gm-Message-State: AOAM531vCD1pI1loY4pZkmPE8orWdNzCVYQJGSNI4uE3rVvxdh+r7rUA ytsox/7L6Z63bhl6nVUkJGpBJVe1H3E= X-Google-Smtp-Source: ABdhPJwu7lnlDY0Tu8xfGOG3ofypeIcBhKMlyCJjjg5MLH3gj9+1vG52sZThQi8yUFvs0Hjc/LCRPw== X-Received: by 2002:adf:e7ca:0:b0:210:941:3363 with SMTP id e10-20020adfe7ca000000b0021009413363mr23215969wrn.25.1654020889268; Tue, 31 May 2022 11:14:49 -0700 (PDT) Received: from localhost.localdomain ([2a02:2f0e:c003:7c00:45d1:29c0:7802:f752]) by smtp.gmail.com with ESMTPSA id l3-20020a1c7903000000b003974027722csm2682980wme.47.2022.05.31.11.14.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 11:14:48 -0700 (PDT) From: Ovidiu Panait To: u-boot@lists.denx.de Cc: monstr@monstr.eu, Ovidiu Panait Subject: [PATCH v2 01/14] cmd: cpu: migrate cpu command to U_BOOT_CMD_WITH_SUBCMDS() Date: Tue, 31 May 2022 21:14:22 +0300 Message-Id: <20220531181435.3473549-1-ovpanait@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Migrate cpu command to use U_BOOT_CMD_WITH_SUBCMDS() helper macro, to reduce duplicated code. This also fixes the cpu command on boards that enable CONFIG_NEEDS_MANUAL_RELOC. Signed-off-by: Ovidiu Panait --- NOTE: this series depends on the following "events" patch: https://lore.kernel.org/u-boot/20220515184029.2169025-2-ovpanait@gmail.com/ Changes in v2: - New patch. cmd/cpu.c | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/cmd/cpu.c b/cmd/cpu.c index 67dbb044b5..2ca4d05ae8 100644 --- a/cmd/cpu.c +++ b/cmd/cpu.c @@ -82,36 +82,13 @@ static int do_cpu_detail(struct cmd_tbl *cmdtp, int flag, int argc, return 0; } -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, "", ""), -}; - -/* - * Process a cpu sub-command - */ -static int do_cpu(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]) -{ - 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)); - - if (c) - return c->cmd(cmdtp, flag, argc, argv); - else - return CMD_RET_USAGE; -} - -U_BOOT_CMD( - cpu, 2, 1, do_cpu, - "display information about CPUs", +#if CONFIG_IS_ENABLED(SYS_LONGHELP) +static char cpu_help_text[] = "list - list available CPUs\n" "cpu detail - show CPU detail" -); + ; +#endif + +U_BOOT_CMD_WITH_SUBCMDS(cpu, "display information about CPUs", cpu_help_text, + U_BOOT_SUBCMD_MKENT(list, 1, 1, do_cpu_list), + U_BOOT_SUBCMD_MKENT(detail, 1, 0, do_cpu_detail)); -- 2.25.1