Skip to content

Commit 78b782c

Browse files
committed
of: Change logic to overwrite cmd_line with CONFIG_CMDLINE
We used to overwrite with CONFIG_CMDLINE if we found a chosen node but failed to get bootargs out of it or they were empty, unless CONFIG_CMDLINE_FORCE is set. Instead change that to overwrite if "data" is non empty after the bootargs check. It allows arch code to have other mechanisms to retrieve the command line prior to parsing the device-tree. Note: CONFIG_CMDLINE_FORCE case should ideally be handled elsewhere as it won't work as it-is if the device-tree has no /chosen node Signed-off-by: Benjamin Herrenschmidt <[email protected]> CC: [email protected] CC: Grant Likely <[email protected]> Acked-by: Grant Likely <[email protected]>
1 parent 55190f8 commit 78b782c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/of/fdt.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,9 +681,14 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
681681
if (p != NULL && l > 0)
682682
strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
683683

684+
/*
685+
* CONFIG_CMDLINE is meant to be a default in case nothing else
686+
* managed to set the command line, unless CONFIG_CMDLINE_FORCE
687+
* is set in which case we override whatever was found earlier.
688+
*/
684689
#ifdef CONFIG_CMDLINE
685690
#ifndef CONFIG_CMDLINE_FORCE
686-
if (p == NULL || l == 0 || (l == 1 && (*p) == 0))
691+
if (!((char *)data)[0])
687692
#endif
688693
strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
689694
#endif /* CONFIG_CMDLINE */

0 commit comments

Comments
 (0)