From patchwork Fri Nov 10 01:38:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Walker (danielwa)" X-Patchwork-Id: 13451998 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 71E48C4332F for ; Fri, 10 Nov 2023 01:39:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345769AbjKJBjw (ORCPT ); Thu, 9 Nov 2023 20:39:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345719AbjKJBjk (ORCPT ); Thu, 9 Nov 2023 20:39:40 -0500 Received: from rcdn-iport-4.cisco.com (rcdn-iport-4.cisco.com [173.37.86.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4599E469F; Thu, 9 Nov 2023 17:39:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=3742; q=dns/txt; s=iport; t=1699580376; x=1700789976; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hVMC2g6F+sS5xh4dm4+qY8r7kQHgggs8qh2zLFytqSA=; b=JhlMP1dPTIyUwm1rec5aMwHGZIFrepP8tOUXFodpJwuc7/JCwT8zHsP8 E2Bskw0xhe+HYAFiOp3Xx3yvKKpQX2Sug+CbsyAaJ08RLKeuRgQBWpvPA BVxvpaCt5vTZ/9ohFjssN+k4bdGwZOTyTVSarh7q534oOGjMsZFZHevrj Q=; X-CSE-ConnectionGUID: t3gihvnOTkyYQzPMwAhgsg== X-CSE-MsgGUID: suRZL8VFTx6nMj9/gpbWKg== X-IPAS-Result: A0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qS2cOC1OfdOamkF0PS2HU1wXocGN5N/ NrNT+ZPsFzn1kp1YorW5s2WnkzVRkE9v2wcnslyKOfWZsADkzmuvbS05vfK3ayy IronPort-HdrOrdr: A9a23:8hX10KzJCp3ev/u3nQRoKrPwF71zdoMgy1knxilNoNJuHvBw8P re+MjzuiWbtN98YhsdcJW7Scq9qBDnhPtICPcqXItKNTOO0ACVxcNZnOnfKlbbdBEWmNQx6U 5ISdkYNDSJNzhHZQKQ2njALz7mq+P3lpyVuQ== X-Talos-CUID: 9a23:ovLiuG2jLCZwgmjd/3mxMbxfBpsqc33DylDsIF6JMHRRbaK8SVCL9/Yx X-Talos-MUID: 9a23:Dz9OZAirh9HKqH0Sbu1iIsMpL9pS0YD+Nm4xgcsAnsvVciNoMQi+g2Hi X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.03,291,1694736000"; d="scan'208";a="134982800" Received: from rcdn-core-4.cisco.com ([173.37.93.155]) by rcdn-iport-4.cisco.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2023 01:38:33 +0000 Received: from goliath.lan ([10.25.128.169]) by rcdn-core-4.cisco.com (8.15.2/8.15.2) with ESMTP id 3AA1cHVN011466; Fri, 10 Nov 2023 01:38:32 GMT From: Daniel Walker To: Will Deacon , Christophe Leroy , Rob Herring , Daniel Gimpelevich , Andrew Morton , Pratyush Brahma , Tomas Mudrunka , Sean Anderson , x86@kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Rob Herring , Frank Rowand Cc: xe-linux-external@cisco.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/8] of: replace command line handling Date: Thu, 9 Nov 2023 17:38:11 -0800 Message-Id: <20231110013817.2378507-8-danielwa@cisco.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231110013817.2378507-1-danielwa@cisco.com> References: <20231110013817.2378507-1-danielwa@cisco.com> MIME-Version: 1.0 X-Auto-Response-Suppress: DR, OOF, AutoReply X-Outbound-SMTP-Client: 10.25.128.169, [10.25.128.169] X-Outbound-Node: rcdn-core-4.cisco.com Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org Rob Herring has complained about this section of code. I removed the command line handling code to the cmdline.h header. This hopefully makes it easier for Rob to maintain it (at least he doesn't have to look at it directly anymore). I would like to add a Kconfig option called OF_DEPRECATED_CMDLINE which an architecture would set if it uses this code. This would allow a platform to use the cmdline.h and the added function directly and remove the Kconfig option. This change would be in a subsequent patch. This code was boot tested on powerpc 32bit, powerpc 64bit without any generic command line conversion. Cc: xe-linux-external@cisco.com Signed-off-by: Daniel Walker --- drivers/of/fdt.c | 22 +++------------------- include/linux/cmdline.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index bf502ba8da95..1fc1b17d04dc 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -26,6 +26,7 @@ #include #include #include +#include #include /* for COMMAND_LINE_SIZE */ #include @@ -1183,27 +1184,10 @@ int __init early_init_dt_scan_chosen(char *cmdline) /* Retrieve command line */ p = of_get_flat_dt_prop(node, "bootargs", &l); - if (p != NULL && l > 0) - strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE)); handle_cmdline: - /* - * CONFIG_CMDLINE is meant to be a default in case nothing else - * managed to set the command line, unless CONFIG_CMDLINE_FORCE - * is set in which case we override whatever was found earlier. - */ -#ifdef CONFIG_CMDLINE -#if defined(CONFIG_CMDLINE_EXTEND) - strlcat(cmdline, " ", COMMAND_LINE_SIZE); - strlcat(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE); -#elif defined(CONFIG_CMDLINE_FORCE) - strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE); -#else - /* No arguments from boot loader, use kernel's cmdl*/ - if (!((char *)cmdline)[0]) - strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE); -#endif -#endif /* CONFIG_CMDLINE */ + + of_deprecated_cmdline_update(cmdline, p, l); pr_debug("Command line is: %s\n", (char *)cmdline); diff --git a/include/linux/cmdline.h b/include/linux/cmdline.h index a94758a0f257..c772afb7340f 100644 --- a/include/linux/cmdline.h +++ b/include/linux/cmdline.h @@ -103,4 +103,35 @@ __cmdline_add_builtin( #define cmdline_get_static_builtin(dest) \ (CMDLINE_STATIC_PREPEND CMDLINE_STATIC_APPEND) + +#ifndef CONFIG_GENERIC_CMDLINE +static inline bool of_deprecated_cmdline_update(char *cmdline, const char *dt_bootargs, int length) +{ + if (dt_bootargs != NULL && length > 0) + strlcpy(cmdline, dt_bootargs, min(length, COMMAND_LINE_SIZE)); + /* + * CONFIG_CMDLINE is meant to be a default in case nothing else + * managed to set the command line, unless CONFIG_CMDLINE_FORCE + * is set in which case we override whatever was found earlier. + */ + +#ifdef CONFIG_CMDLINE +#if defined(CONFIG_CMDLINE_EXTEND) + strlcat(cmdline, " ", COMMAND_LINE_SIZE); + strlcat(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE); +#elif defined(CONFIG_CMDLINE_FORCE) + strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE); +#else + /* No arguments from boot loader, use kernel's cmdl*/ + if (!((char *)cmdline)[0]) + strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE); #endif +#endif /* CONFIG_CMDLINE */ + return true; +} +#else +static inline bool of_deprecated_cmdline_update(char *cmdline, const char *dt_bootargs, int length) { return false; } +#endif /* CONFIG_GENERIC_CMDLINE */ + + +#endif /* _LINUX_CMDLINE_H */