1
0

508-MIPS-ath79-prom-image-command-line-hack.patch 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. --- a/arch/mips/ath79/prom.c
  2. +++ b/arch/mips/ath79/prom.c
  3. @@ -33,6 +33,41 @@ static void __init ath79_prom_append_cmd
  4. strlcat(arcs_cmdline, ath79_cmdline_buf, sizeof(arcs_cmdline));
  5. }
  6. +#ifdef CONFIG_IMAGE_CMDLINE_HACK
  7. +extern char __image_cmdline[];
  8. +
  9. +static int __init ath79_use_image_cmdline(void)
  10. +{
  11. + char *p = __image_cmdline;
  12. + int replace = 0;
  13. +
  14. + if (*p == '-') {
  15. + replace = 1;
  16. + p++;
  17. + }
  18. +
  19. + if (*p == '\0')
  20. + return 0;
  21. +
  22. + if (replace) {
  23. + strlcpy(arcs_cmdline, p, sizeof(arcs_cmdline));
  24. + } else {
  25. + strlcat(arcs_cmdline, " ", sizeof(arcs_cmdline));
  26. + strlcat(arcs_cmdline, p, sizeof(arcs_cmdline));
  27. + }
  28. +
  29. + /* Validate and setup environment pointer */
  30. + if (fw_arg2 < CKSEG0)
  31. + _fw_envp = NULL;
  32. + else
  33. + _fw_envp = (int *)fw_arg2;
  34. +
  35. + return 1;
  36. +}
  37. +#else
  38. +static inline int ath79_use_image_cmdline(void) { return 0; }
  39. +#endif
  40. +
  41. static int __init ath79_prom_init_myloader(void)
  42. {
  43. struct myloader_info *mylo;
  44. @@ -61,6 +96,8 @@ static int __init ath79_prom_init_myload
  45. ath79_prom_append_cmdline("ethaddr", mac_buf);
  46. + ath79_use_image_cmdline();
  47. +
  48. return 1;
  49. }
  50. @@ -71,7 +108,8 @@ void __init prom_init(void)
  51. if (ath79_prom_init_myloader())
  52. return;
  53. - fw_init_cmdline();
  54. + if (!ath79_use_image_cmdline())
  55. + fw_init_cmdline();
  56. env = fw_getenv("ethaddr");
  57. if (env)
  58. --- a/arch/mips/fw/lib/cmdline.c
  59. +++ b/arch/mips/fw/lib/cmdline.c
  60. @@ -35,6 +35,7 @@ void __init fw_init_cmdline(void)
  61. else
  62. _fw_envp = (int *)fw_arg2;
  63. + arcs_cmdline[0] = '\0';
  64. for (i = 1; i < fw_argc; i++) {
  65. strlcat(arcs_cmdline, fw_argv(i), COMMAND_LINE_SIZE);
  66. if (i < (fw_argc - 1))