mvebu: use CONFIG_MANGLE_BOOTARGS
[oweals/openwrt.git] / target / linux / mvebu / patches-3.18 / 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,12 +25,15 @@ 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  {
18         struct device_node *node;
19         const char *partname;
20 +       const char *owrtpart = "ubi";
21         struct device_node *pp;
22         int nr_parts, i;
23  
24 @@ -78,9 +81,15 @@ static int parse_ofpart_partitions(struc
25                 (*pparts)[i].offset = of_read_number(reg, a_cells);
26                 (*pparts)[i].size = of_read_number(reg + a_cells, s_cells);
27  
28 -               partname = of_get_property(pp, "label", &len);
29 -               if (!partname)
30 -                       partname = of_get_property(pp, "name", &len);
31 +               if (mangled_rootblock && (i == mangled_rootblock)) {
32 +                               partname = owrtpart;
33 +               } else {
34 +                       partname = of_get_property(pp, "label", &len);
35 +
36 +                       if (!partname)
37 +                               partname = of_get_property(pp, "name", &len);
38 +               }
39 +
40                 (*pparts)[i].name = partname;
41  
42                 if (of_get_property(pp, "read-only", &len))
43 @@ -178,6 +187,18 @@ static int __init ofpart_parser_init(voi
44         return 0;
45  }
46  
47 +static int __init active_root(char *str)
48 +{
49 +       get_option(&str, &mangled_rootblock);
50 +
51 +       if (!mangled_rootblock)
52 +               return 1;
53 +
54 +       return 1;
55 +}
56 +
57 +__setup("mangled_rootblock=", active_root);
58 +
59  static void __exit ofpart_parser_exit(void)
60  {
61         deregister_mtd_parser(&ofpart_parser);