bcm53xx: add testing support for kernel 5.10
[openwrt/staging/ldir.git] / target / linux / bcm53xx / patches-5.10 / 140-mtd-parsers-trx-parse-firmware-MTD-partitions-only.patch
1 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
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
8 Parsing every partition with "compatible" set to "brcm,trx" results in
9 parsing both: firmware partition and failsafe partition on devices that
10 implement failsafe booting. This affects e.g. Linksys EA9500 which has:
11
12 partition@200000 {
13 reg = <0x0200000 0x01d00000>;
14 compatible = "linksys,ns-firmware", "brcm,trx";
15 };
16
17 partition@1f00000 {
18 reg = <0x01f00000 0x01d00000>;
19 compatible = "linksys,ns-firmware", "brcm,trx";
20 };
21
22 Check for MTD partition name "firmware" before parsing. Recently added
23 ofpart_linksys_ns.c creates "firmware" and "failsafe" depending on
24 bootloader setup.
25
26 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
27 ---
28 drivers/mtd/parsers/parser_trx.c | 4 ++++
29 1 file changed, 4 insertions(+)
30
31 --- a/drivers/mtd/parsers/parser_trx.c
32 +++ b/drivers/mtd/parsers/parser_trx.c
33 @@ -85,6 +85,10 @@ static int parser_trx_parse(struct mtd_i
34 uint8_t curr_part = 0, i = 0;
35 int err;
36
37 + /* Don't parse any failsafe / backup partitions */
38 + if (strcmp(mtd->name, "firmware"))
39 + return -EINVAL;
40 +
41 parts = kcalloc(TRX_PARSER_MAX_PARTS, sizeof(struct mtd_partition),
42 GFP_KERNEL);
43 if (!parts)