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

12345678910111213141516171819202122232425262728293031323334353637
  1. --- a/arch/arm/Kconfig
  2. +++ b/arch/arm/Kconfig
  3. @@ -1836,6 +1836,14 @@ config ARM_ATAG_DTB_COMPAT_CMDLINE_MANGL
  4. Only command line ATAG will be processed, the rest of the ATAGs
  5. sent by bootloader will be ignored.
  6. +config CMDLINE_OVERRIDE
  7. + bool "Use alternative cmdline from device tree"
  8. + help
  9. + Some bootloaders may have uneditable bootargs. While CMDLINE_FORCE can
  10. + be used, this is not a good option for kernels that are shared across
  11. + devices. This setting enables using "chosen/cmdline-override" as the
  12. + cmdline if it exists in the device tree.
  13. +
  14. endchoice
  15. config CMDLINE
  16. --- a/drivers/of/fdt.c
  17. +++ b/drivers/of/fdt.c
  18. @@ -1060,6 +1060,17 @@ int __init early_init_dt_scan_chosen(uns
  19. if (p != NULL && l > 0)
  20. strlcpy(data, p, min(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(data, p, min((int)l, COMMAND_LINE_SIZE));
  30. +#endif
  31. +
  32. /*
  33. * CONFIG_CMDLINE is meant to be a default in case nothing else
  34. * managed to set the command line, unless CONFIG_CMDLINE_FORCE