1 From: Gabor Juhos <juhosg@openwrt.org>
2 Subject: kernel/3.10: allow to use partition parsers for rootfs and firmware split
4 lede-commit: 3b71cd94bc9517bc25267dccb393b07d4b54564e
5 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
7 drivers/mtd/mtdpart.c | 37 +++++++++++++++++++++++++++++++++++++
8 include/linux/mtd/partitions.h | 2 ++
9 2 files changed, 39 insertions(+)
11 diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
12 index f20207e32075..28f76315dfa0 100644
13 --- a/drivers/mtd/mtdpart.c
14 +++ b/drivers/mtd/mtdpart.c
15 @@ -761,6 +761,36 @@ int mtd_del_partition(struct mtd_info *mtd, int partno)
17 EXPORT_SYMBOL_GPL(mtd_del_partition);
20 +run_parsers_by_type(struct mtd_part *slave, enum mtd_parser_type type)
22 + struct mtd_partition *parts;
26 + nr_parts = parse_mtd_partitions_by_type(&slave->mtd, type, (const struct mtd_partition **)&parts,
31 + if (WARN_ON(!parts))
34 + for (i = 0; i < nr_parts; i++) {
35 + /* adjust partition offsets */
36 + parts[i].offset += slave->offset;
38 + mtd_add_partition(slave->parent,
49 #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
50 #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME
52 @@ -769,6 +799,7 @@ EXPORT_SYMBOL_GPL(mtd_del_partition);
54 static void split_firmware(struct mtd_info *master, struct mtd_part *part)
56 + run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE);
59 void __weak arch_split_mtd_part(struct mtd_info *master, const char *name,
60 @@ -783,6 +814,12 @@ static void mtd_partition_split(struct mtd_info *master, struct mtd_part *part)
64 + if (!strcmp(part->mtd.name, "rootfs")) {
65 + run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS);
70 if (!strcmp(part->mtd.name, SPLIT_FIRMWARE_NAME) &&
71 IS_ENABLED(CONFIG_MTD_SPLIT_FIRMWARE))
72 split_firmware(master, part);
73 diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
74 index baafd542432e..356e29815aa2 100644
75 --- a/include/linux/mtd/partitions.h
76 +++ b/include/linux/mtd/partitions.h
77 @@ -74,6 +74,8 @@ struct mtd_part_parser_data {
79 enum mtd_parser_type {
80 MTD_PARSER_TYPE_DEVICE = 0,
81 + MTD_PARSER_TYPE_ROOTFS,
82 + MTD_PARSER_TYPE_FIRMWARE,
85 struct mtd_part_parser {