summaryrefslogtreecommitdiff
path: root/target/linux/ar71xx/patches-4.1/508-MIPS-ath79-prom-image-command-line-hack.patch
blob: 0cf4869ff641b1466aaf21b14cca812891a19c8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
--- a/arch/mips/ath79/prom.c
+++ b/arch/mips/ath79/prom.c
@@ -32,6 +32,35 @@ static void __init ath79_prom_append_cmd
 	strlcat(arcs_cmdline, ath79_cmdline_buf, sizeof(arcs_cmdline));
 }
 
+#ifdef CONFIG_IMAGE_CMDLINE_HACK
+extern char __image_cmdline[];
+
+static int __init ath79_use_image_cmdline(void)
+{
+	char *p = __image_cmdline;
+	int replace = 0;
+
+	if (*p == '-') {
+		replace = 1;
+		p++;
+	}
+
+	if (*p == '\0')
+		return 0;
+
+	if (replace) {
+		strlcpy(arcs_cmdline, p, sizeof(arcs_cmdline));
+	} else {
+		strlcat(arcs_cmdline, " ", sizeof(arcs_cmdline));
+		strlcat(arcs_cmdline, p, sizeof(arcs_cmdline));
+	}
+
+	return 1;
+}
+#else
+static inline int ath79_use_image_cmdline(void) { return 0; }
+#endif
+
 static int __init ath79_prom_init_myloader(void)
 {
 	struct myloader_info *mylo;
@@ -60,6 +89,8 @@ static int __init ath79_prom_init_myload
 
 	ath79_prom_append_cmdline("ethaddr", mac_buf);
 
+	ath79_use_image_cmdline();
+
 	return 1;
 }
 
@@ -70,7 +101,8 @@ void __init prom_init(void)
 	if (ath79_prom_init_myloader())
 		return;
 
-	fw_init_cmdline();
+	if (!ath79_use_image_cmdline())
+		fw_init_cmdline();
 
 	env = fw_getenv("ethaddr");
 	if (env)