140-mtd-parsers-trx-parse-firmware-MTD-partitions-only.patch 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <[email protected]>
  2. Date: Tue, 13 Apr 2021 18:25:20 +0200
  3. Subject: [PATCH] mtd: parsers: trx: parse "firmware" MTD partitions only
  4. MIME-Version: 1.0
  5. Content-Type: text/plain; charset=UTF-8
  6. Content-Transfer-Encoding: 8bit
  7. Parsing every partition with "compatible" set to "brcm,trx" results in
  8. parsing both: firmware partition and failsafe partition on devices that
  9. implement failsafe booting. This affects e.g. Linksys EA9500 which has:
  10. partition@200000 {
  11. reg = <0x0200000 0x01d00000>;
  12. compatible = "linksys,ns-firmware", "brcm,trx";
  13. };
  14. partition@1f00000 {
  15. reg = <0x01f00000 0x01d00000>;
  16. compatible = "linksys,ns-firmware", "brcm,trx";
  17. };
  18. Check for MTD partition name "firmware" before parsing. Recently added
  19. ofpart_linksys_ns.c creates "firmware" and "failsafe" depending on
  20. bootloader setup.
  21. Signed-off-by: Rafał Miłecki <[email protected]>
  22. ---
  23. drivers/mtd/parsers/parser_trx.c | 4 ++++
  24. 1 file changed, 4 insertions(+)
  25. --- a/drivers/mtd/parsers/parser_trx.c
  26. +++ b/drivers/mtd/parsers/parser_trx.c
  27. @@ -92,6 +92,10 @@ static int parser_trx_parse(struct mtd_i
  28. if (err != 0 && err != -EINVAL)
  29. pr_err("failed to parse \"brcm,trx-magic\" DT attribute, using default: %d\n", err);
  30. + /* Don't parse any failsafe / backup partitions */
  31. + if (strcmp(mtd->name, "firmware"))
  32. + return -EINVAL;
  33. +
  34. parts = kcalloc(TRX_PARSER_MAX_PARTS, sizeof(struct mtd_partition),
  35. GFP_KERNEL);
  36. if (!parts)