1 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
2 Date: Thu, 6 May 2021 12:33:58 +0200
3 Subject: [PATCH] mtd: parsers: ofpart: fix parsing subpartitions
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
8 ofpart was recently patched to not scan random partition nodes as
9 subpartitions. That change unfortunately broke scanning valid
13 compatible = "fixed-partitions";
18 compatible = "fixed-partitions";
24 reg = <0x80000 0x80000>;
29 Fix that regression by adding 1 more code path. We actually need 3
30 conditional blocks to support 3 possible cases. This change also makes
31 code easier to understand & follow.
33 Reported-by: David Bauer <mail@david-bauer.net>
34 Fixes: 2d751203aacf ("mtd: parsers: ofpart: limit parsing of deprecated DT syntax
35 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
37 drivers/mtd/parsers/ofpart_core.c | 26 ++++++++++++++------------
38 1 file changed, 14 insertions(+), 12 deletions(-)
40 --- a/drivers/mtd/parsers/ofpart_core.c
41 +++ b/drivers/mtd/parsers/ofpart_core.c
42 @@ -57,20 +57,22 @@ static int parse_fixed_partitions(struct
46 - ofpart_node = of_get_child_by_name(mtd_node, "partitions");
47 - if (!ofpart_node && !master->parent) {
49 - * We might get here even when ofpart isn't used at all (e.g.,
50 - * when using another parser), so don't be louder than
53 - pr_debug("%s: 'partitions' subnode not found on %pOF. Trying to parse direct subnodes as partitions.\n",
54 - master->name, mtd_node);
55 + if (!master->parent) { /* Master */
56 + ofpart_node = of_get_child_by_name(mtd_node, "partitions");
59 + * We might get here even when ofpart isn't used at all (e.g.,
60 + * when using another parser), so don't be louder than
63 + pr_debug("%s: 'partitions' subnode not found on %pOF. Trying to parse direct subnodes as partitions.\n",
64 + master->name, mtd_node);
65 + ofpart_node = mtd_node;
68 + } else { /* Partition */
69 ofpart_node = mtd_node;
75 of_id = of_match_node(parse_ofpart_match_table, ofpart_node);
76 if (dedicated && !of_id) {