1 --- a/arch/mips/ath79/prom.c
2 +++ b/arch/mips/ath79/prom.c
7 +static char ath79_cmdline_buf[COMMAND_LINE_SIZE] __initdata;
9 static inline int is_valid_ram_addr(void *addr)
11 if (((u32) addr > KSEG0) &&
12 @@ -32,6 +34,41 @@ static inline int is_valid_ram_addr(void
16 +static void __init ath79_prom_append_cmdline(const char *name,
19 + snprintf(ath79_cmdline_buf, sizeof(ath79_cmdline_buf),
20 + " %s=%s", name, value);
21 + strlcat(arcs_cmdline, ath79_cmdline_buf, sizeof(arcs_cmdline));
24 +static const char * __init ath79_prom_find_env(char **envp, const char *name)
26 + const char *ret = NULL;
30 + if (!is_valid_ram_addr(envp))
34 + for (p = envp; is_valid_ram_addr(*p); p++) {
35 + if (strncmp(name, *p, len) == 0 && (*p)[len] == '=') {
40 + /* RedBoot env comes in pointer pairs - key, value */
41 + if (strncmp(name, *p, len) == 0 && (*p)[len] == 0)
42 + if (is_valid_ram_addr(*(++p))) {
51 static __init void ath79_prom_init_cmdline(int argc, char **argv)
54 @@ -48,7 +85,32 @@ static __init void ath79_prom_init_cmdli
56 void __init prom_init(void)
61 ath79_prom_init_cmdline(fw_arg0, (char **)fw_arg1);
63 + envp = (char **)fw_arg2;
64 + if (!strstr(arcs_cmdline, "ethaddr=")) {
65 + env = ath79_prom_find_env(envp, "ethaddr");
67 + ath79_prom_append_cmdline("ethaddr", env);
70 + if (!strstr(arcs_cmdline, "board=")) {
71 + env = ath79_prom_find_env(envp, "board");
73 + /* Workaround for buggy bootloaders */
74 + if (strcmp(env, "RouterStation") == 0 ||
75 + strcmp(env, "Ubiquiti AR71xx-based board") == 0)
78 + if (strcmp(env, "RouterStation PRO") == 0)
81 + ath79_prom_append_cmdline("board", env);
86 void __init prom_free_prom_memory(void)