linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: Implement CONFIG_CMDLINE_EXTEND
@ 2015-11-18  9:28 Pavel Fedin
  2015-11-18 16:09 ` Rob Herring
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Fedin @ 2015-11-18  9:28 UTC (permalink / raw)
  To: linux-arm-kernel

Add an option to extend built-in command line with one obtained from
the device tree.

This option is very useful for, for example, switching between some
stable and development version, when one of them requires additional
arguments (e. g. to turn on some extra debug). It can be annoying to
reprogram command line in the bootloaded every time.

Actually, this patch introduces the necessary support to all
architectures using the device tree, however only arm64 Kconfig is
modified, because this is the only platform i can test.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
---
 arch/arm64/Kconfig | 18 ++++++++++++++++++
 drivers/of/fdt.c   | 12 ++++++++++--
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 9ac16a4..c741837 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -695,6 +695,23 @@ config CMDLINE
 	  entering them here. As a minimum, you should specify the the
 	  root device (e.g. root=/dev/nfs).
 
+choice
+	prompt "Kernel command line type" if CMDLINE != ""
+	default CMDLINE_FROM_BOOTLOADER
+
+config CMDLINE_FROM_BOOTLOADER
+	bool "Use bootloader kernel arguments if available"
+	help
+	  Uses the command-line options passed by the boot loader. If
+	  the boot loader doesn't provide any, the default kernel command
+	  string provided in CMDLINE will be used.
+
+config CMDLINE_EXTEND
+	bool "Extend bootloader kernel arguments"
+	help
+	  The command-line arguments provided by the boot loader will be
+	  appended to the default kernel command string.
+
 config CMDLINE_FORCE
 	bool "Always use the default kernel command string"
 	help
@@ -702,6 +719,7 @@ config CMDLINE_FORCE
 	  loader passes other arguments to the kernel.
 	  This is useful if you cannot or don't want to change the
 	  command-line options your boot loader passes to the kernel.
+endchoice
 
 config EFI_STUB
 	bool
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index d243029..494307e 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -949,8 +949,16 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
 
 	/* Retrieve command line */
 	p = of_get_flat_dt_prop(node, "bootargs", &l);
-	if (p != NULL && l > 0)
-		strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
+	if (p != NULL && l > 0) {
+		int offset = 0;
+#ifdef CONFIG_CMDLINE
+#ifdef CONFIG_CMDLINE_EXTEND
+		strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+		offset = strlcat(data, " ", COMMAND_LINE_SIZE);
+#endif
+#endif
+		strlcpy(data + offset, p, min(l, COMMAND_LINE_SIZE - offset));
+	}
 
 	/*
 	 * CONFIG_CMDLINE is meant to be a default in case nothing else
-- 
2.4.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-18 16:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-18  9:28 [PATCH] arm64: Implement CONFIG_CMDLINE_EXTEND Pavel Fedin
2015-11-18 16:09 ` Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).