From patchwork Mon Oct 19 13:55:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1384322 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=DOE9vMEm; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CFJJg15WJz9sSC for ; Tue, 20 Oct 2020 00:58:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C1EDD82457; Mon, 19 Oct 2020 15:56:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="DOE9vMEm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 502AF8242A; Mon, 19 Oct 2020 15:56:28 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) (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 CBE14823DE for ; Mon, 19 Oct 2020 15:56:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x142.google.com with SMTP id q1so122964ilt.6 for ; Mon, 19 Oct 2020 06:56:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ol4a0XWPJF2WmrqSqo+BE0PglCcLxncfC+VNB9GCb9s=; b=DOE9vMEmEnzJxN3mrq9W1W3Bfh+WjXUn6Qjh3gxqlF2jHDE1/qFl/Kd1hiD5yi4R7u aO2k6fhT3I5XsXTDwXQAt3XOHOmvDPlt2rmqTMN0/oMoIx1HIaOthZlmD9o/B6gY63Vv INqUkk6xeeqrjlwiSxJmeuFGRqIQEyw7NpG84= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ol4a0XWPJF2WmrqSqo+BE0PglCcLxncfC+VNB9GCb9s=; b=RnEBQ+KPbkMN7POmXcbgV63GSTElJD1+OJxJPXGoOZTut+EHFieH02kc1aBFZFz4Cf GAj2F9pTKb2YRSVjD5QML/2Y9gHrL6AnAxL/KJvth2r1F9ZOgn+eYQmdcrMhG22RucQb tKixewcKL6E9uiNjlbInkI3NSI5Xz/WDI2ir3FuksSuP8kO4hY3S8u4ROHyE+axs0MPL lKtRdfmjFndcX1XyYXobIJEyfdHjQEAKucPs9xfTsU9GDIoJJ8KXAbrMSNe/Tv6YhK7c uvS3IChgnKRFzsaz6TwaAc1FXQcW8Jq9ZSSDQL/8b2WerrsPqJWqmjTxEpB4EzX+0Zqv nSWA== X-Gm-Message-State: AOAM533HOXl5M/XV1wnLSsKqwq+0C6Tt+WPwTCPSPNJV2LqIVpQLjNwo H/lSKDQq1g3xwAUTYBBwQ47RYVDPqLbzwumA X-Google-Smtp-Source: ABdhPJw0lwjoPe3DV4ed2DAFs0DB+SUxiiEnM1zKrS7QBT4+8nCuMcnrPxlr17t3Ql2861XqLUkBaw== X-Received: by 2002:a92:d24e:: with SMTP id v14mr34803ilg.92.1603115778479; Mon, 19 Oct 2020 06:56:18 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id r17sm10164078iov.7.2020.10.19.06.56.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2020 06:56:18 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Bernhard Messerklinger , Wolfgang Wallner , Walter Lozano , Simon Glass , Daniel Schwierzeck , Michael Walle , Tero Kristo Subject: [PATCH 08/11] bootm: Update bootm_process_cmdline_env() to use flags Date: Mon, 19 Oct 2020 07:55:59 -0600 Message-Id: <20201019135602.3943835-9-sjg@chromium.org> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog In-Reply-To: <20201019135602.3943835-1-sjg@chromium.org> References: <20201019135602.3943835-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean At present only one transformation is supported: making the Linux console silent. To prepare for adding more, convert the boolean parameter into a flag value. Signed-off-by: Simon Glass --- common/bootm.c | 8 +++++--- include/bootm.h | 11 +++++++++-- test/bootm.c | 10 +++++----- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/common/bootm.c b/common/bootm.c index 41965fa304c..5a5b79c5cd0 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -540,16 +540,17 @@ static int fixup_silent_linux(char *buf, int maxlen) return 0; } -int bootm_process_cmdline_env(bool do_silent) +int bootm_process_cmdline_env(int flags) { const int maxlen = MAX_CMDLINE_SIZE; + bool do_silent; const char *env; char *buf; int ret; /* First check if any action is needed */ do_silent = IS_ENABLED(CONFIG_SILENT_CONSOLE) && - !IS_ENABLED(CONFIG_SILENT_U_BOOT_ONLY) && do_silent; + !IS_ENABLED(CONFIG_SILENT_U_BOOT_ONLY) && (flags & BOOTM_CL_SILENT); if (!do_silent) return 0; @@ -683,7 +684,8 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc, if (!ret && (states & BOOTM_STATE_OS_BD_T)) ret = boot_fn(BOOTM_STATE_OS_BD_T, argc, argv, images); if (!ret && (states & BOOTM_STATE_OS_PREP)) { - ret = bootm_process_cmdline_env(images->os.os == IH_OS_LINUX); + ret = bootm_process_cmdline_env(images->os.os == IH_OS_LINUX ? + BOOTM_CL_SILENT : 0); if (ret) { printf("Cmdline setup failed (err=%d)\n", ret); ret = CMD_RET_FAILURE; diff --git a/include/bootm.h b/include/bootm.h index f12ee2b3cb3..4876d7b2882 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -75,6 +75,13 @@ void board_quiesce_devices(void); */ void switch_to_non_secure_mode(void); +/* Flags to control bootm_process_cmdline() */ +enum bootm_cmdline_t { + BOOTM_CL_SILENT = 1 << 0, /* Do silent console processing */ + + BOOTM_CL_ALL = 1, /* All substitutions */ +}; + /** * arch_preboot_os() - arch specific configuration before booting */ @@ -91,9 +98,9 @@ void board_preboot_os(void); * Updates the 'bootargs' envvar as required. This handles making Linux boot * silently if requested ('silent_linux' envvar) * - * @do_silent: Process bootargs for silent console + * @flags: Flags to control what happens (see bootm_cmdline_t) * @return 0 if OK, -ENOMEM if out of memory */ -int bootm_process_cmdline_env(bool do_silent); +int bootm_process_cmdline_env(int flags); #endif diff --git a/test/bootm.c b/test/bootm.c index c203f0acd60..ba08920bb17 100644 --- a/test/bootm.c +++ b/test/bootm.c @@ -23,26 +23,26 @@ static int bootm_test_silent_var(struct unit_test_state *uts) /* 'silent_linux' not set should do nothing */ env_set("silent_linux", NULL); env_set("bootargs", CONSOLE_STR); - ut_assertok(bootm_process_cmdline_env(true)); + ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT)); ut_asserteq_str(CONSOLE_STR, env_get("bootargs")); env_set("bootargs", NULL); - ut_assertok(bootm_process_cmdline_env(true)); + ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT)); ut_assertnull(env_get("bootargs")); ut_assertok(env_set("silent_linux", "no")); env_set("bootargs", CONSOLE_STR); - ut_assertok(bootm_process_cmdline_env(true)); + ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT)); ut_asserteq_str(CONSOLE_STR, env_get("bootargs")); ut_assertok(env_set("silent_linux", "yes")); env_set("bootargs", CONSOLE_STR); - ut_assertok(bootm_process_cmdline_env(true)); + ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT)); ut_asserteq_str("console=", env_get("bootargs")); /* Empty buffer should still add the string */ env_set("bootargs", NULL); - ut_assertok(bootm_process_cmdline_env(true)); + ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT)); ut_asserteq_str("console=", env_get("bootargs")); return 0;