From nobody Mon Feb 9 03:20:07 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E6B7EB64DA for ; Tue, 18 Jul 2023 15:34:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231474AbjGRPes (ORCPT ); Tue, 18 Jul 2023 11:34:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233728AbjGRPei (ORCPT ); Tue, 18 Jul 2023 11:34:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE2551AC for ; Tue, 18 Jul 2023 08:34:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8BFA061638 for ; Tue, 18 Jul 2023 15:34:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71956C433C7; Tue, 18 Jul 2023 15:34:11 +0000 (UTC) From: Huacai Chen To: Huacai Chen Cc: loongarch@lists.linux.dev, Xuefeng Li , Guo Ren , Xuerui Wang , Jiaxun Yang , linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn, Zhihong Dong , Huacai Chen Subject: [PATCH v5] LoongArch: Fix CONFIG_CMDLINE_EXTEND and CONFIG_CMDLINE_BOOTLOADER handling Date: Tue, 18 Jul 2023 23:33:48 +0800 Message-Id: <20230718153348.3340811-1-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Zhihong Dong Fix CONFIG_CMDLINE_EXTEND and CONFIG_CMDLINE_BOOTLOADER handling. The touched function is bootcmdline_init(). There's already code handling CONFIG_CMDLINE_FORCE that replaces boot_command_line with CONFIG_CMDLINE and immediately `goto out`. There should be some similar logic to handle CONFIG_CMDLINE_EXTEND and CONFIG_CMDLINE_BOOTLOADER, so this patch add some code to fix it. Signed-off-by: Zhihong Dong Signed-off-by: Huacai Chen --- v4 -> v5: Update commit message and adjust the code logic. v3 -> v4: Make CONFIG_CMDLINE appended to the end of command line (Huacai); Removed unnecessary #ifdef since CONFIG_CMDLINE is always a string on LoongArch Reworded comments Reworded the subject of commit message (Huacai) v2 -> v3: Reworded the commit message again to make it imperative (Ruoyao) v1 -> v2: Reworded the commit message so it's more imperative (Markus); Added `goto out` to FDT part (Huacai) arch/loongarch/kernel/setup.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c index 95e6b579dfdd..5a6f61ed567f 100644 --- a/arch/loongarch/kernel/setup.c +++ b/arch/loongarch/kernel/setup.c @@ -332,9 +332,25 @@ static void __init bootcmdline_init(char **cmdline_p) strlcat(boot_command_line, " ", COMMAND_LINE_SIZE); =20 strlcat(boot_command_line, init_command_line, COMMAND_LINE_SIZE); + goto out; } #endif =20 + /* + * Append built-in command line to the bootloader command line if + * CONFIG_CMDLINE_EXTEND is enabled. + */ + if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) && CONFIG_CMDLINE[0]) { + strlcat(boot_command_line, " ", COMMAND_LINE_SIZE); + strlcat(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); + } + + /* + * Use built-in command line if the bootloader command line is empty. + */ + if ((IS_ENABLED(CONFIG_CMDLINE_BOOTLOADER) && !boot_command_line[0]) + strscpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); + out: *cmdline_p =3D boot_command_line; } --=20 2.39.3