This patch tends to make CONFIG_CMDLINE work with CONFIG_CMDLINE_EXTEND
and CONFIG_CMDLINE_BOOTLOADER. The touched function is bootcmdline_init()`.
There's already code handling CONFIG_CMDLINE_FORCE, which replaces
`boot_command_line` with CONFIG_CMDLINE and immediately`goto out`. It'd be
similar way to handle CONFIG_CMDLINE_EXTEND and CONFIG_CMDLINE_BOOTLOADER,
so I added some code after OF_FLATTREE part to handle them.
Signed-off-by: Dong Zhihong <[email protected]>
---
v2 -> v1:Reworded the commit message so it's more imperative (Markus);
Added `goto out` to FDT part (Huacai)
arch/loongarch/kernel/setup.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c
index 78a00359bde3..3cafda1a409e 100644
--- a/arch/loongarch/kernel/setup.c
+++ b/arch/loongarch/kernel/setup.c
@@ -332,7 +332,24 @@ 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
+
+#ifdef CONFIG_CMDLINE
+ /*
+ * If CONFIG_CMDLINE_BOOTLOADER is enabled then we use thei built-in
+ * command line if no command line given, or we append given command
+ * line to the built-in one if CONFIG_CMDLINE_EXTEND is enabled.
+ */
+ if (IS_ENABLED(CONFIG_CMDLINE_EXTEND)) {
+ strscpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+ strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
+ strlcat(boot_command_line, init_command_line, COMMAND_LINE_SIZE);
}
+
+ if (IS_ENABLED(CONFIG_CMDLINE_BOOTLOADER) && !boot_command_line[0])
+ strscpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
#endif
out:
--
2.25.1
Use "LoongArch" instead of "LOONGARCH". "LOONGARCH" should only show up
in macro names, enum value names, etc.
On Tue, 2023-07-11 at 21:27 +0800, Dong Zhihong wrote:
> This patch tends to make CONFIG_CMDLINE work with CONFIG_CMDLINE_EXTEND
As Markus already told you, submitting-patches.rst says:
"Describe your changes in imperative mood, e.g. "make xyzzy do frotz"
instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy
to do frotz", as if you are giving orders to the codebase to change
its behaviour."
i. e. "Make CONFIG_CMDLINE work with ...".
> and CONFIG_CMDLINE_BOOTLOADER. The touched function is bootcmdline_init()`.
> There's already code handling CONFIG_CMDLINE_FORCE, which replaces
> `boot_command_line` with CONFIG_CMDLINE and immediately`goto out`. It'd be
> similar way to handle CONFIG_CMDLINE_EXTEND and CONFIG_CMDLINE_BOOTLOADER,
> so I added some code after OF_FLATTREE part to handle them.
>
> Signed-off-by: Dong Zhihong <[email protected]>
> ---
>
> v2 -> v1:Reworded the commit message so it's more imperative (Markus);
> Added `goto out` to FDT part (Huacai)
>
> arch/loongarch/kernel/setup.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c
> index 78a00359bde3..3cafda1a409e 100644
> --- a/arch/loongarch/kernel/setup.c
> +++ b/arch/loongarch/kernel/setup.c
> @@ -332,7 +332,24 @@ 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
> +
> +#ifdef CONFIG_CMDLINE
> + /*
> + * If CONFIG_CMDLINE_BOOTLOADER is enabled then we use thei built-in
> + * command line if no command line given, or we append given command
> + * line to the built-in one if CONFIG_CMDLINE_EXTEND is enabled.
> + */
> + if (IS_ENABLED(CONFIG_CMDLINE_EXTEND)) {
> + strscpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> + strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
> + strlcat(boot_command_line, init_command_line, COMMAND_LINE_SIZE);
> }
> +
> + if (IS_ENABLED(CONFIG_CMDLINE_BOOTLOADER) && !boot_command_line[0])
> + strscpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> #endif
>
> out:
--
Xi Ruoyao <[email protected]>
School of Aerospace Science and Technology, Xidian University