diff options
author | Rafał Miłecki <rafal@milecki.pl> | 2018-07-13 10:32:21 -0400 |
---|---|---|
committer | Boris Brezillon <boris.brezillon@bootlin.com> | 2018-07-24 17:04:27 -0400 |
commit | 76a832254ab05502c9394cc51ded6f0abe0e0bee (patch) | |
tree | cc0b80f0f70f71563cbafd6ac12d2b068ba786e8 | |
parent | d2ad00eb78792b396a6d012f15d6297a1701b8bc (diff) |
mtd: partitions: use DT info for parsing partitions with "compatible" prop
So far only flash devices could be described in DT regarding partitions
parsing. That could be done with "partitions" subnode and a proper
"compatible" string.
Some devices may use hierarchical (multi-level) layouts and may mix used
layouts (fixed and dynamic). Describing that in DT is done by specifying
"compatible" for DT-represented partition plus optionally more
properties and/or subnodes.
To support such layouts each DT partition has to be checked for
additional description.
Please note this implementation will work in parallel with support for
partition type specified for non-DT setups. That already works since
commit 1a0915be1926 ("mtd: partitions: add support for partition
parsers").
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
-rw-r--r-- | drivers/mtd/mtdpart.c | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index f8d3a015cdad..52e2cb35fc79 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c | |||
@@ -322,22 +322,6 @@ static inline void free_partition(struct mtd_part *p) | |||
322 | kfree(p); | 322 | kfree(p); |
323 | } | 323 | } |
324 | 324 | ||
325 | /** | ||
326 | * mtd_parse_part - parse MTD partition looking for subpartitions | ||
327 | * | ||
328 | * @slave: part that is supposed to be a container and should be parsed | ||
329 | * @types: NULL-terminated array with names of partition parsers to try | ||
330 | * | ||
331 | * Some partitions are kind of containers with extra subpartitions (volumes). | ||
332 | * There can be various formats of such containers. This function tries to use | ||
333 | * specified parsers to analyze given partition and registers found | ||
334 | * subpartitions on success. | ||
335 | */ | ||
336 | static int mtd_parse_part(struct mtd_part *slave, const char *const *types) | ||
337 | { | ||
338 | return parse_mtd_partitions(&slave->mtd, types, NULL); | ||
339 | } | ||
340 | |||
341 | static struct mtd_part *allocate_partition(struct mtd_info *parent, | 325 | static struct mtd_part *allocate_partition(struct mtd_info *parent, |
342 | const struct mtd_partition *part, int partno, | 326 | const struct mtd_partition *part, int partno, |
343 | uint64_t cur_offset) | 327 | uint64_t cur_offset) |
@@ -735,8 +719,8 @@ int add_mtd_partitions(struct mtd_info *master, | |||
735 | 719 | ||
736 | add_mtd_device(&slave->mtd); | 720 | add_mtd_device(&slave->mtd); |
737 | mtd_add_partition_attrs(slave); | 721 | mtd_add_partition_attrs(slave); |
738 | if (parts[i].types) | 722 | /* Look for subpartitions */ |
739 | mtd_parse_part(slave, parts[i].types); | 723 | parse_mtd_partitions(&slave->mtd, parts[i].types, NULL); |
740 | 724 | ||
741 | cur_offset = slave->offset + slave->mtd.size; | 725 | cur_offset = slave->offset + slave->mtd.size; |
742 | } | 726 | } |
@@ -812,6 +796,12 @@ static const char * const default_mtd_part_types[] = { | |||
812 | NULL | 796 | NULL |
813 | }; | 797 | }; |
814 | 798 | ||
799 | /* Check DT only when looking for subpartitions. */ | ||
800 | static const char * const default_subpartition_types[] = { | ||
801 | "ofpart", | ||
802 | NULL | ||
803 | }; | ||
804 | |||
815 | static int mtd_part_do_parse(struct mtd_part_parser *parser, | 805 | static int mtd_part_do_parse(struct mtd_part_parser *parser, |
816 | struct mtd_info *master, | 806 | struct mtd_info *master, |
817 | struct mtd_partitions *pparts, | 807 | struct mtd_partitions *pparts, |
@@ -882,7 +872,9 @@ static int mtd_part_of_parse(struct mtd_info *master, | |||
882 | const char *fixed = "fixed-partitions"; | 872 | const char *fixed = "fixed-partitions"; |
883 | int ret, err = 0; | 873 | int ret, err = 0; |
884 | 874 | ||
885 | np = of_get_child_by_name(mtd_get_of_node(master), "partitions"); | 875 | np = mtd_get_of_node(master); |
876 | if (!mtd_is_partition(master)) | ||
877 | np = of_get_child_by_name(np, "partitions"); | ||
886 | of_property_for_each_string(np, "compatible", prop, compat) { | 878 | of_property_for_each_string(np, "compatible", prop, compat) { |
887 | parser = mtd_part_get_compatible_parser(compat); | 879 | parser = mtd_part_get_compatible_parser(compat); |
888 | if (!parser) | 880 | if (!parser) |
@@ -945,7 +937,8 @@ int parse_mtd_partitions(struct mtd_info *master, const char *const *types, | |||
945 | int ret, err = 0; | 937 | int ret, err = 0; |
946 | 938 | ||
947 | if (!types) | 939 | if (!types) |
948 | types = default_mtd_part_types; | 940 | types = mtd_is_partition(master) ? default_subpartition_types : |
941 | default_mtd_part_types; | ||
949 | 942 | ||
950 | for ( ; *types; types++) { | 943 | for ( ; *types; types++) { |
951 | /* | 944 | /* |