From patchwork Mon Mar 14 01:07:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 596886 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3qNfnk3gPqz9rxv for ; Mon, 14 Mar 2016 12:10:50 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=CV7oB/os; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1B0DEA771D; Mon, 14 Mar 2016 02:08:47 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3Gsm8xarB1nL; Mon, 14 Mar 2016 02:08:47 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id ED42DA775C; Mon, 14 Mar 2016 02:08:36 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4953CA76ED for ; Mon, 14 Mar 2016 02:08:19 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3DTSWxR0cxct for ; Mon, 14 Mar 2016 02:08:19 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-io0-f180.google.com (mail-io0-f180.google.com [209.85.223.180]) by theia.denx.de (Postfix) with ESMTPS id C57E4A75D5 for ; Mon, 14 Mar 2016 02:08:12 +0100 (CET) Received: by mail-io0-f180.google.com with SMTP id g203so205564671iof.2 for ; Sun, 13 Mar 2016 18:08:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=DL8P3eXpeq4vRPf9ADY5OVsmhL/cFt4r3JTn0z4bSpo=; b=CV7oB/osL543eKOcWWA5RjNfImEeOaC14loNujcWsEm9stL5Y1wAvaPg7Co2yAIq2E 7RQO5UUeMAxn8CRNXSrDkilw1LuxQ31r+9T5MVJ0KHy8KCV67klbESzmqBAvotMg/R8F ZMAKkpM2IXTCaQXFy6pqd1yc15vTqn5PTVzgcg8k0oY1PvVnRSmdYhg5znlMOwZBw1Ja 1E/Cf4N9dZotPXsvhbkvDto/Td05tnlnivyHQQeEJO1AxM9fzxU76bEx5QjET8wMBeqd EoTs2jciMUT3y8hdAFD2fODgGfLlZqUWDFUgX+nFTKnw8Q7YHOJnRRNM5SA4I4/55BRp FapA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=DL8P3eXpeq4vRPf9ADY5OVsmhL/cFt4r3JTn0z4bSpo=; b=hhqr1Pje1nUGaHwCk6KJ5WIqeITnlITZqSa45J0wFhC09GxxOVlOkeCMjhr2ov/vLW 7Z8JMyOWeqsoJAJoTVCJJmAJ9l3XRdM7bfhoPMr6N5OlcGFfPq32Ib6zkkby+SXZkFsq fjX+PY9B7tlkM7jCBvAbrqT8ICo4h1NIpFerOjIYB4+DKD2lvODmjpw4Ju/m5mCc68UF i6s/GEkBWD8FrdUp840Aup4QIjYramsgZRTjdZ6HWQPfKNH5hnRUqht4iNOVAbjtLdH1 IX8le0pIG/F4ZPr0hiQKOqA2JRXbNWOjZPhzP+Xj8T0m0aTlmBMrFxv/eTNMj5XtbaaV aRaw== X-Gm-Message-State: AD7BkJIgG6dQsQR8MBaixRUheMs4K6JlWKDwWXOq3z3W2VRP+e/B0AATPPsjNfbyCyYVSAXY X-Received: by 10.107.3.145 with SMTP id e17mr20049327ioi.125.1457917690857; Sun, 13 Mar 2016 18:08:10 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by smtp.gmail.com with ESMTPSA id g68sm8499235ioj.29.2016.03.13.18.07.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Mar 2016 18:08:09 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id EC19B221964; Sun, 13 Mar 2016 19:07:48 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Sun, 13 Mar 2016 19:07:33 -0600 Message-Id: <1457917655-30547-8-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.7.0.rc3.207.g0ac5344 In-Reply-To: <1457917655-30547-1-git-send-email-sjg@chromium.org> References: <1457917655-30547-1-git-send-email-sjg@chromium.org> Cc: Tom Rini , Stephen Warren Subject: [U-Boot] [PATCH v2 7/9] Allow command code to compile to nothing X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" When CONFIG_CMDLINE is disabled we need to remove all the command-line code. Most can be removed by dropping the appropriate linker lists from the images, but sub-commands must be dealt with specially. A simple mechanism is used to avoid 'unused static function' errors. Signed-off-by: Simon Glass Reviewed-by: Tom Rini --- Changes in v2: None include/command.h | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/include/command.h b/include/command.h index 0d2b653..08f0486 100644 --- a/include/command.h +++ b/include/command.h @@ -182,21 +182,44 @@ int board_run_command(const char *cmdline); # define _CMD_HELP(x) #endif +#ifdef CONFIG_CMDLINE #define U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, \ _usage, _help, _comp) \ { #_name, _maxargs, _rep, _cmd, _usage, \ _CMD_HELP(_help) _CMD_COMPLETE(_comp) } -#define U_BOOT_CMD_MKENT(_name, _maxargs, _rep, _cmd, _usage, _help) \ - U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, \ - _usage, _help, NULL) - #define U_BOOT_CMD_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, _help, _comp) \ ll_entry_declare(cmd_tbl_t, _name, cmd) = \ U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, \ _usage, _help, _comp); +#else +#define U_BOOT_SUBCMD_START(name) static cmd_tbl_t name[] = {}; +#define U_BOOT_SUBCMD_END + +#define _CMD_REMOVE(_name, _cmd) \ + int __remove_ ## _name(void) \ + { \ + if (0) \ + _cmd(NULL, 0, 0, NULL); \ + return 0; \ + } +#define U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, \ + _help, _comp) \ + { #_name, _maxargs, _rep, 0 ? _cmd : NULL, _usage, \ + _CMD_HELP(_help) _CMD_COMPLETE(_comp) } + +#define U_BOOT_CMD_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, _help, \ + _comp) \ + _CMD_REMOVE(sub_ ## _name, _cmd) + +#endif /* CONFIG_CMDLINE */ + #define U_BOOT_CMD(_name, _maxargs, _rep, _cmd, _usage, _help) \ U_BOOT_CMD_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, _help, NULL) +#define U_BOOT_CMD_MKENT(_name, _maxargs, _rep, _cmd, _usage, _help) \ + U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, \ + _usage, _help, NULL) + #endif /* __COMMAND_H */