202-linksys-find-active-root.patch 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. The WRT1900AC among other Linksys routers uses a dual-firmware layout.
  2. Dynamically rename the active partition to "ubi".
  3. Signed-off-by: Imre Kaloz <[email protected]>
  4. ---
  5. --- a/drivers/mtd/parsers/ofpart_core.c
  6. +++ b/drivers/mtd/parsers/ofpart_core.c
  7. @@ -38,6 +38,8 @@ static bool node_has_compatible(struct d
  8. return of_get_property(pp, "compatible", NULL);
  9. }
  10. +static int mangled_rootblock;
  11. +
  12. static int parse_fixed_partitions(struct mtd_info *master,
  13. const struct mtd_partition **pparts,
  14. struct mtd_part_parser_data *data)
  15. @@ -47,6 +49,7 @@ static int parse_fixed_partitions(struct
  16. struct mtd_partition *parts;
  17. struct device_node *mtd_node;
  18. struct device_node *ofpart_node;
  19. + const char *owrtpart = "ubi";
  20. const char *partname;
  21. struct device_node *pp;
  22. int nr_parts, i, ret = 0;
  23. @@ -152,9 +155,15 @@ static int parse_fixed_partitions(struct
  24. parts[i].size = of_read_number(reg + a_cells, s_cells);
  25. parts[i].of_node = pp;
  26. - partname = of_get_property(pp, "label", &len);
  27. - if (!partname)
  28. - partname = of_get_property(pp, "name", &len);
  29. + if (mangled_rootblock && (i == mangled_rootblock)) {
  30. + partname = owrtpart;
  31. + } else {
  32. + partname = of_get_property(pp, "label", &len);
  33. +
  34. + if (!partname)
  35. + partname = of_get_property(pp, "name", &len);
  36. + }
  37. +
  38. parts[i].name = partname;
  39. if (of_get_property(pp, "read-only", &len))
  40. @@ -271,6 +280,18 @@ static int __init ofpart_parser_init(voi
  41. return 0;
  42. }
  43. +static int __init active_root(char *str)
  44. +{
  45. + get_option(&str, &mangled_rootblock);
  46. +
  47. + if (!mangled_rootblock)
  48. + return 1;
  49. +
  50. + return 1;
  51. +}
  52. +
  53. +__setup("mangled_rootblock=", active_root);
  54. +
  55. static void __exit ofpart_parser_exit(void)
  56. {
  57. deregister_mtd_parser(&ofpart_parser);