900-arm-add-cmdline-override.patch 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. --- a/arch/arm/Kconfig
  2. +++ b/arch/arm/Kconfig
  3. @@ -1568,6 +1568,14 @@ config ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEN
  4. endchoice
  5. +config CMDLINE_OVERRIDE
  6. + bool "Use alternative cmdline from device tree"
  7. + help
  8. + Some bootloaders may have uneditable bootargs. While CMDLINE_FORCE can
  9. + be used, this is not a good option for kernels that are shared across
  10. + devices. This setting enables using "chosen/cmdline-override" as the
  11. + cmdline if it exists in the device tree.
  12. +
  13. config CMDLINE
  14. string "Default kernel command string"
  15. default ""
  16. --- a/drivers/of/fdt.c
  17. +++ b/drivers/of/fdt.c
  18. @@ -1189,6 +1189,17 @@ int __init early_init_dt_scan_chosen(cha
  19. if (p != NULL && l > 0)
  20. strlcat(cmdline, p, min_t(int, strlen(cmdline) + (int)l, COMMAND_LINE_SIZE));
  21. + /* CONFIG_CMDLINE_OVERRIDE is used to fallback to a different
  22. + * device tree option of chosen/bootargs-override. This is
  23. + * helpful on boards where u-boot sets bootargs, and is unable
  24. + * to be modified.
  25. + */
  26. +#ifdef CONFIG_CMDLINE_OVERRIDE
  27. + p = of_get_flat_dt_prop(node, "bootargs-override", &l);
  28. + if (p != NULL && l > 0)
  29. + strlcpy(cmdline, p, min((int)l, COMMAND_LINE_SIZE));
  30. +#endif
  31. +
  32. handle_cmdline:
  33. /*
  34. * CONFIG_CMDLINE is meant to be a default in case nothing else