OpenWrt – Blame information for rev 2
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 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 |
||
5 | "compatible" prop |
||
6 | MIME-Version: 1.0 |
||
7 | Content-Type: text/plain; charset=UTF-8 |
||
8 | Content-Transfer-Encoding: 8bit |
||
9 | |||
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 |
||
12 | "compatible" string. |
||
13 | |||
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. |
||
18 | |||
19 | To support such layouts each DT partition has to be checked for |
||
20 | additional description. |
||
21 | |||
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 |
||
25 | parsers"). |
||
26 | |||
27 | Signed-off-by: Rafał Miłecki <rafal@milecki.pl> |
||
28 | Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> |
||
29 | --- |
||
30 | drivers/mtd/mtdpart.c | 33 +++++++++++++-------------------- |
||
31 | 1 file changed, 13 insertions(+), 20 deletions(-) |
||
32 | |||
33 | --- a/drivers/mtd/mtdpart.c |
||
34 | +++ b/drivers/mtd/mtdpart.c |
||
35 | @@ -370,22 +370,6 @@ static inline void free_partition(struct |
||
36 | kfree(p); |
||
37 | } |
||
38 | |||
39 | -/** |
||
40 | - * mtd_parse_part - parse MTD partition looking for subpartitions |
||
41 | - * |
||
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 |
||
44 | - * |
||
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. |
||
49 | - */ |
||
50 | -static int mtd_parse_part(struct mtd_part *slave, const char *const *types) |
||
51 | -{ |
||
52 | - return parse_mtd_partitions(&slave->mtd, types, NULL); |
||
53 | -} |
||
54 | - |
||
55 | static struct mtd_part *allocate_partition(struct mtd_info *parent, |
||
56 | const struct mtd_partition *part, int partno, |
||
57 | uint64_t cur_offset) |
||
58 | @@ -783,8 +767,8 @@ int add_mtd_partitions(struct mtd_info * |
||
59 | |||
60 | add_mtd_device(&slave->mtd); |
||
61 | mtd_add_partition_attrs(slave); |
||
62 | - if (parts[i].types) |
||
63 | - mtd_parse_part(slave, parts[i].types); |
||
64 | + /* Look for subpartitions */ |
||
65 | + parse_mtd_partitions(&slave->mtd, parts[i].types, NULL); |
||
66 | |||
67 | cur_offset = slave->offset + slave->mtd.size; |
||
68 | } |
||
69 | @@ -860,6 +844,12 @@ static const char * const default_mtd_pa |
||
70 | NULL |
||
71 | }; |
||
72 | |||
73 | +/* Check DT only when looking for subpartitions. */ |
||
74 | +static const char * const default_subpartition_types[] = { |
||
75 | + "ofpart", |
||
76 | + NULL |
||
77 | +}; |
||
78 | + |
||
79 | static int mtd_part_do_parse(struct mtd_part_parser *parser, |
||
80 | struct mtd_info *master, |
||
81 | struct mtd_partitions *pparts, |
||
82 | @@ -930,7 +920,9 @@ static int mtd_part_of_parse(struct mtd_ |
||
83 | const char *fixed = "fixed-partitions"; |
||
84 | int ret, err = 0; |
||
85 | |||
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); |
||
92 | if (!parser) |
||
93 | @@ -993,7 +985,8 @@ int parse_mtd_partitions(struct mtd_info |
||
94 | int ret, err = 0; |
||
95 | |||
96 | if (!types) |
||
97 | - types = default_mtd_part_types; |
||
98 | + types = mtd_is_partition(master) ? default_subpartition_types : |
||
99 | + default_mtd_part_types; |
||
100 | |||
101 | for ( ; *types; types++) { |
||
102 | /* |