Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7061884rwp; Tue, 18 Jul 2023 09:27:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlFRJdXCZcjei0pOfrvK0CEiyc3+iEIGyDspnqgbT14NSeCPNZ+kpM1JihVdddsVVKJIA7UQ X-Received: by 2002:a17:907:97d4:b0:98d:4b97:acc8 with SMTP id js20-20020a17090797d400b0098d4b97acc8mr518734ejc.25.1689697630019; Tue, 18 Jul 2023 09:27:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689697630; cv=none; d=google.com; s=arc-20160816; b=j4luukg68TloCDVDZUtEaWJFzSaVXTBfB52Ma3fe+wJ0U8Z0GZZS7DlAWWh66fkCec TVEUE3puR2r7Gf4xIyFz1QKpqB+CdHiP+YLTDkpAnZVS2yYmxd5eKIRjjSuuNMPl8O8Z D3xbHaHmu5/6SqYWn0Mapekz8Uk5kSVhAXCkZzTXvWqt55jSbaOTUggZaQU3zasXe2BF ioOby/d1Ux5WncAQhYE6q6E8nX+FiQiSzt5TRssqD935On69IPMN0gdbA4WrJIgr108+ e6EY8oTjB8AazLrJSGsjksrUJEuQAy1650Oc6+CYEaSPhextG53tvVDzWjqARULbzDAv PAAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=hqFkTENYgRTyYs2/nWbTX9AMhY2wDPAfYh7jwpw76bM=; fh=dkZMXsO62OknhhapWL5tvFwtPkmFIjMDSfVSNsyCXhc=; b=drwSQ3Tn0M4vxH6hsVrK7PBNKuYgexrpgVzutXxHrLIElVTWhrSOJ27T36TIOLWBMI gR6Mx2ADbqN6d2CX59LylixAG5F/XsxTFGt5MB7AOr3d4DEkfhoZWlsTN6h/GoQEIrt/ tz4uApD1u6+7fGjOIkz+jN7Tscu2apBAInxDSI+zJGMRCqREBOUsIONra1nYSU9jCyo3 OtONDDXMh1QWnZqW3YXy0flUY5U4kZMjZ50YUrSd3QO/K4fBVJB+i+oXBjzTHaWvnIe7 q/iXdgmLXcHJyY+VyIcM7VzKT1br/7svHtON+EqtVlf/LiQGE4E0BnpWBCO8y2idBg39 /cag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kd22-20020a17090798d600b009920612b89asi1496344ejc.351.2023.07.18.09.26.46; Tue, 18 Jul 2023 09:27:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233719AbjGRPer (ORCPT + 99 others); Tue, 18 Jul 2023 11:34:47 -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: 8bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); strlcat(boot_command_line, init_command_line, COMMAND_LINE_SIZE); + goto out; } #endif + /* + * 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 = boot_command_line; } -- 2.39.3