1 From 76a832254ab05502c9394cc51ded6f0abe0e0bee Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
3 Date: Fri, 13 Jul 2018 16:32:21 +0200
4 Subject: [PATCH] mtd: partitions: use DT info for parsing partitions with
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 So far only flash devices could be described in DT regarding partitions
11 parsing. That could be done with "partitions" subnode and a proper
14 Some devices may use hierarchical (multi-level) layouts and may mix used
15 layouts (fixed and dynamic). Describing that in DT is done by specifying
16 "compatible" for DT-represented partition plus optionally more
17 properties and/or subnodes.
19 To support such layouts each DT partition has to be checked for
20 additional description.
22 Please note this implementation will work in parallel with support for
23 partition type specified for non-DT setups. That already works since
24 commit 1a0915be1926 ("mtd: partitions: add support for partition
27 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
28 Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
30 drivers/mtd/mtdpart.c | 33 +++++++++++++--------------------
31 1 file changed, 13 insertions(+), 20 deletions(-)
33 --- a/drivers/mtd/mtdpart.c
34 +++ b/drivers/mtd/mtdpart.c
35 @@ -370,22 +370,6 @@ static inline void free_partition(struct
40 - * mtd_parse_part - parse MTD partition looking for subpartitions
42 - * @slave: part that is supposed to be a container and should be parsed
43 - * @types: NULL-terminated array with names of partition parsers to try
45 - * Some partitions are kind of containers with extra subpartitions (volumes).
46 - * There can be various formats of such containers. This function tries to use
47 - * specified parsers to analyze given partition and registers found
48 - * subpartitions on success.
50 -static int mtd_parse_part(struct mtd_part *slave, const char *const *types)
52 - return parse_mtd_partitions(&slave->mtd, types, NULL);
55 static struct mtd_part *allocate_partition(struct mtd_info *parent,
56 const struct mtd_partition *part, int partno,
58 @@ -795,8 +779,8 @@ int add_mtd_partitions(struct mtd_info *
61 mtd_add_partition_attrs(slave);
63 - mtd_parse_part(slave, parts[i].types);
64 + /* Look for subpartitions */
65 + parse_mtd_partitions(&slave->mtd, parts[i].types, NULL);
67 cur_offset = slave->offset + slave->mtd.size;
69 @@ -877,6 +861,12 @@ static const char * const default_mtd_pa
73 +/* Check DT only when looking for subpartitions. */
74 +static const char * const default_subpartition_types[] = {
79 static int mtd_part_do_parse(struct mtd_part_parser *parser,
80 struct mtd_info *master,
81 struct mtd_partitions *pparts,
82 @@ -947,7 +937,9 @@ static int mtd_part_of_parse(struct mtd_
83 const char *fixed = "fixed-partitions";
86 - np = of_get_child_by_name(mtd_get_of_node(master), "partitions");
87 + np = mtd_get_of_node(master);
88 + if (!mtd_is_partition(master))
89 + np = of_get_child_by_name(np, "partitions");
90 of_property_for_each_string(np, "compatible", prop, compat) {
91 parser = mtd_part_get_compatible_parser(compat);
93 @@ -1010,7 +1002,8 @@ int parse_mtd_partitions(struct mtd_info
97 - types = default_mtd_part_types;
98 + types = mtd_is_partition(master) ? default_subpartition_types :
99 + default_mtd_part_types;
101 for ( ; *types; types++) {