kernel: backport mtd support for subpartitions in DT
[openwrt/openwrt.git] / target / linux / brcm63xx / patches-4.14 / 119-Revert-mtd-partitions-use-DT-info-for-parsing-partit.patch
1 From e62ff8f02eb3ae35ae7ece7c5272a689fd8b0bcd Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
3 Date: Fri, 27 Jul 2018 21:37:48 +0200
4 Subject: [PATCH] Revert "mtd: partitions: use DT info for parsing partitions
5 with "compatible" prop"
6
7 This reverts commit 76a832254ab05502c9394cc51ded6f0abe0e0bee.
8 ---
9 drivers/mtd/mtdpart.c | 33 ++++++++++++++++++++-------------
10 1 file changed, 20 insertions(+), 13 deletions(-)
11
12 --- a/drivers/mtd/mtdpart.c
13 +++ b/drivers/mtd/mtdpart.c
14 @@ -453,6 +453,22 @@ static inline void free_partition(struct
15 kfree(p);
16 }
17
18 +/**
19 + * mtd_parse_part - parse MTD partition looking for subpartitions
20 + *
21 + * @slave: part that is supposed to be a container and should be parsed
22 + * @types: NULL-terminated array with names of partition parsers to try
23 + *
24 + * Some partitions are kind of containers with extra subpartitions (volumes).
25 + * There can be various formats of such containers. This function tries to use
26 + * specified parsers to analyze given partition and registers found
27 + * subpartitions on success.
28 + */
29 +static int mtd_parse_part(struct mtd_part *slave, const char *const *types)
30 +{
31 + return parse_mtd_partitions(&slave->mtd, types, NULL);
32 +}
33 +
34 static struct mtd_part *allocate_partition(struct mtd_info *parent,
35 const struct mtd_partition *part, int partno,
36 uint64_t cur_offset)
37 @@ -932,8 +948,8 @@ int add_mtd_partitions(struct mtd_info *
38 add_mtd_device(&slave->mtd);
39 mtd_partition_split(master, slave);
40 mtd_add_partition_attrs(slave);
41 - /* Look for subpartitions */
42 - parse_mtd_partitions(&slave->mtd, parts[i].types, NULL);
43 + if (parts[i].types)
44 + mtd_parse_part(slave, parts[i].types);
45
46 cur_offset = slave->offset + slave->mtd.size;
47 }
48 @@ -1035,12 +1051,6 @@ static const char * const default_mtd_pa
49 NULL
50 };
51
52 -/* Check DT only when looking for subpartitions. */
53 -static const char * const default_subpartition_types[] = {
54 - "ofpart",
55 - NULL
56 -};
57 -
58 static int mtd_part_do_parse(struct mtd_part_parser *parser,
59 struct mtd_info *master,
60 struct mtd_partitions *pparts,
61 @@ -1111,9 +1121,7 @@ static int mtd_part_of_parse(struct mtd_
62 const char *fixed = "fixed-partitions";
63 int ret, err = 0;
64
65 - np = mtd_get_of_node(master);
66 - if (!mtd_is_partition(master))
67 - np = of_get_child_by_name(np, "partitions");
68 + np = of_get_child_by_name(mtd_get_of_node(master), "partitions");
69 of_property_for_each_string(np, "compatible", prop, compat) {
70 parser = mtd_part_get_compatible_parser(compat);
71 if (!parser)
72 @@ -1183,8 +1191,7 @@ int parse_mtd_partitions(struct mtd_info
73 }
74
75 if (!types)
76 - types = mtd_is_partition(master) ? default_subpartition_types :
77 - default_mtd_part_types;
78 + types = default_mtd_part_types;
79
80 for ( ; *types; types++) {
81 /*