mvebu: update and fixup 4.4 patches
[openwrt/svn-archive/archive.git] / target / linux / mvebu / patches-4.4 / 100-find_active_root.patch
1 The WRT1900AC among other Linksys routers uses a dual-firmware layout.
2 Dynamically rename the active partition to "ubi".
3
4 Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
5
6 --- a/drivers/mtd/ofpart.c
7 +++ b/drivers/mtd/ofpart.c
8 @@ -25,6 +25,8 @@ static bool node_has_compatible(struct d
9 return of_get_property(pp, "compatible", NULL);
10 }
11
12 +static int mangled_rootblock;
13 +
14 static int parse_ofpart_partitions(struct mtd_info *master,
15 struct mtd_partition **pparts,
16 struct mtd_part_parser_data *data)
17 @@ -32,6 +34,7 @@ static int parse_ofpart_partitions(struc
18 struct device_node *mtd_node;
19 struct device_node *ofpart_node;
20 const char *partname;
21 + const char *owrtpart = "ubi";
22 struct device_node *pp;
23 int nr_parts, i, ret = 0;
24 bool dedicated = true;
25 @@ -102,9 +105,15 @@ static int parse_ofpart_partitions(struc
26 (*pparts)[i].offset = of_read_number(reg, a_cells);
27 (*pparts)[i].size = of_read_number(reg + a_cells, s_cells);
28
29 - partname = of_get_property(pp, "label", &len);
30 - if (!partname)
31 - partname = of_get_property(pp, "name", &len);
32 + if (mangled_rootblock && (i == mangled_rootblock)) {
33 + partname = owrtpart;
34 + } else {
35 + partname = of_get_property(pp, "label", &len);
36 +
37 + if (!partname)
38 + partname = of_get_property(pp, "name", &len);
39 + }
40 +
41 (*pparts)[i].name = partname;
42
43 if (of_get_property(pp, "read-only", &len))
44 @@ -207,6 +216,18 @@ static int __init ofpart_parser_init(voi
45 return 0;
46 }
47
48 +static int __init active_root(char *str)
49 +{
50 + get_option(&str, &mangled_rootblock);
51 +
52 + if (!mangled_rootblock)
53 + return 1;
54 +
55 + return 1;
56 +}
57 +
58 +__setup("mangled_rootblock=", active_root);
59 +
60 static void __exit ofpart_parser_exit(void)
61 {
62 deregister_mtd_parser(&ofpart_parser);