2018-07-27 19:54:08 +00:00
|
|
|
From 76a832254ab05502c9394cc51ded6f0abe0e0bee Mon Sep 17 00:00:00 2001
|
|
|
|
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
|
|
|
|
Date: Fri, 13 Jul 2018 16:32:21 +0200
|
|
|
|
Subject: [PATCH] mtd: partitions: use DT info for parsing partitions with
|
|
|
|
"compatible" prop
|
|
|
|
MIME-Version: 1.0
|
|
|
|
Content-Type: text/plain; charset=UTF-8
|
|
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
|
|
|
|
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>
|
|
|
|
---
|
|
|
|
drivers/mtd/mtdpart.c | 33 +++++++++++++--------------------
|
|
|
|
1 file changed, 13 insertions(+), 20 deletions(-)
|
|
|
|
|
|
|
|
--- a/drivers/mtd/mtdpart.c
|
|
|
|
+++ b/drivers/mtd/mtdpart.c
|
|
|
|
@@ -370,22 +370,6 @@ static inline void free_partition(struct
|
|
|
|
kfree(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
-/**
|
|
|
|
- * mtd_parse_part - parse MTD partition looking for subpartitions
|
|
|
|
- *
|
|
|
|
- * @slave: part that is supposed to be a container and should be parsed
|
|
|
|
- * @types: NULL-terminated array with names of partition parsers to try
|
|
|
|
- *
|
|
|
|
- * Some partitions are kind of containers with extra subpartitions (volumes).
|
|
|
|
- * There can be various formats of such containers. This function tries to use
|
|
|
|
- * specified parsers to analyze given partition and registers found
|
|
|
|
- * subpartitions on success.
|
|
|
|
- */
|
|
|
|
-static int mtd_parse_part(struct mtd_part *slave, const char *const *types)
|
|
|
|
-{
|
|
|
|
- return parse_mtd_partitions(&slave->mtd, types, NULL);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
static struct mtd_part *allocate_partition(struct mtd_info *parent,
|
|
|
|
const struct mtd_partition *part, int partno,
|
|
|
|
uint64_t cur_offset)
|
2019-12-06 13:55:57 +00:00
|
|
|
@@ -803,8 +787,8 @@ int add_mtd_partitions(struct mtd_info *
|
|
|
|
}
|
2018-07-27 19:54:08 +00:00
|
|
|
|
|
|
|
mtd_add_partition_attrs(slave);
|
|
|
|
- if (parts[i].types)
|
|
|
|
- mtd_parse_part(slave, parts[i].types);
|
|
|
|
+ /* Look for subpartitions */
|
|
|
|
+ parse_mtd_partitions(&slave->mtd, parts[i].types, NULL);
|
|
|
|
|
|
|
|
cur_offset = slave->offset + slave->mtd.size;
|
|
|
|
}
|
2019-12-06 13:55:57 +00:00
|
|
|
@@ -885,6 +869,12 @@ static const char * const default_mtd_pa
|
2018-07-27 19:54:08 +00:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
+/* Check DT only when looking for subpartitions. */
|
|
|
|
+static const char * const default_subpartition_types[] = {
|
|
|
|
+ "ofpart",
|
|
|
|
+ NULL
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
static int mtd_part_do_parse(struct mtd_part_parser *parser,
|
|
|
|
struct mtd_info *master,
|
|
|
|
struct mtd_partitions *pparts,
|
2019-12-06 13:55:57 +00:00
|
|
|
@@ -955,7 +945,9 @@ static int mtd_part_of_parse(struct mtd_
|
2018-07-27 19:54:08 +00:00
|
|
|
const char *fixed = "fixed-partitions";
|
|
|
|
int ret, err = 0;
|
|
|
|
|
|
|
|
- np = of_get_child_by_name(mtd_get_of_node(master), "partitions");
|
|
|
|
+ np = mtd_get_of_node(master);
|
|
|
|
+ if (!mtd_is_partition(master))
|
|
|
|
+ np = of_get_child_by_name(np, "partitions");
|
|
|
|
of_property_for_each_string(np, "compatible", prop, compat) {
|
|
|
|
parser = mtd_part_get_compatible_parser(compat);
|
|
|
|
if (!parser)
|
2019-12-06 13:55:57 +00:00
|
|
|
@@ -1018,7 +1010,8 @@ int parse_mtd_partitions(struct mtd_info
|
2018-07-27 19:54:08 +00:00
|
|
|
int ret, err = 0;
|
|
|
|
|
|
|
|
if (!types)
|
|
|
|
- types = default_mtd_part_types;
|
|
|
|
+ types = mtd_is_partition(master) ? default_subpartition_types :
|
|
|
|
+ default_mtd_part_types;
|
|
|
|
|
|
|
|
for ( ; *types; types++) {
|
|
|
|
/*
|