0050-fdt-Add-support-for-the-CONFIG_CMDLINE_EXTEND-option.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. From 02b9189111d560c40c1ee4252b65d1dd59244108 Mon Sep 17 00:00:00 2001
  2. From: Phil Elwell <phil@raspberrypi.org>
  3. Date: Fri, 5 Dec 2014 17:26:26 +0000
  4. Subject: [PATCH] fdt: Add support for the CONFIG_CMDLINE_EXTEND option
  5. ---
  6. drivers/of/fdt.c | 29 ++++++++++++++++++++++++-----
  7. 1 file changed, 24 insertions(+), 5 deletions(-)
  8. --- a/drivers/of/fdt.c
  9. +++ b/drivers/of/fdt.c
  10. @@ -957,19 +957,38 @@ int __init early_init_dt_scan_chosen(uns
  11. /* Retrieve command line */
  12. p = of_get_flat_dt_prop(node, "bootargs", &l);
  13. - if (p != NULL && l > 0)
  14. - strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
  15. /*
  16. * CONFIG_CMDLINE is meant to be a default in case nothing else
  17. * managed to set the command line, unless CONFIG_CMDLINE_FORCE
  18. * is set in which case we override whatever was found earlier.
  19. + *
  20. + * However, it can be useful to be able to treat the default as
  21. + * a starting point to be extended using CONFIG_CMDLINE_EXTEND.
  22. */
  23. + ((char *)data)[0] = '\0';
  24. +
  25. #ifdef CONFIG_CMDLINE
  26. -#ifndef CONFIG_CMDLINE_FORCE
  27. - if (!((char *)data)[0])
  28. + strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
  29. +
  30. + if (p != NULL && l > 0) {
  31. +#if defined(CONFIG_CMDLINE_EXTEND)
  32. + int len = strlen(data);
  33. + if (len > 0) {
  34. + strlcat(data, " ", COMMAND_LINE_SIZE);
  35. + len++;
  36. + }
  37. + strlcpy((char *)data + len, p, min((int)l, COMMAND_LINE_SIZE - len));
  38. +#elif defined(CONFIG_CMDLINE_FORCE)
  39. + pr_warning("Ignoring bootargs property (using the default kernel command line)\n");
  40. +#else
  41. + /* Neither extend nor force - just override */
  42. + strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
  43. #endif
  44. - strlcpy(data, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
  45. + }
  46. +#else /* CONFIG_CMDLINE */
  47. + if (p != NULL && l > 0)
  48. + strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
  49. #endif /* CONFIG_CMDLINE */
  50. pr_debug("Command line is: %s\n", (char*)data);