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 --- a/drivers/mtd/mtdpart.c
12 +++ b/drivers/mtd/mtdpart.c
13 @@ -741,6 +741,36 @@ int mtd_del_partition(struct mtd_info *m
15 EXPORT_SYMBOL_GPL(mtd_del_partition);
18 +run_parsers_by_type(struct mtd_part *slave, enum mtd_parser_type type)
20 + struct mtd_partition *parts;
24 + nr_parts = parse_mtd_partitions_by_type(&slave->mtd, type, (const struct mtd_partition **)&parts,
29 + if (WARN_ON(!parts))
32 + for (i = 0; i < nr_parts; i++) {
33 + /* adjust partition offsets */
34 + parts[i].offset += slave->offset;
36 + mtd_add_partition(slave->parent,
47 #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
48 #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME
50 @@ -749,6 +779,7 @@ EXPORT_SYMBOL_GPL(mtd_del_partition);
52 static void split_firmware(struct mtd_info *master, struct mtd_part *part)
54 + run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE);
57 void __weak arch_split_mtd_part(struct mtd_info *master, const char *name,
58 @@ -763,6 +794,12 @@ static void mtd_partition_split(struct m
62 + if (!strcmp(part->mtd.name, "rootfs")) {
63 + run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS);
68 if (!strcmp(part->mtd.name, SPLIT_FIRMWARE_NAME) &&
69 IS_ENABLED(CONFIG_MTD_SPLIT_FIRMWARE))
70 split_firmware(master, part);
71 --- a/include/linux/mtd/partitions.h
72 +++ b/include/linux/mtd/partitions.h
73 @@ -74,6 +74,8 @@ struct mtd_part_parser_data {
75 enum mtd_parser_type {
76 MTD_PARSER_TYPE_DEVICE = 0,
77 + MTD_PARSER_TYPE_ROOTFS,
78 + MTD_PARSER_TYPE_FIRMWARE,
81 struct mtd_part_parser {