kernel: backport mtd support for subpartitions in DT

This is a new & warm feature that allows nesting partiitons in DT and
mixing their types (e.g. static vs. dynamic). It's very useful for
boards that have most partitions static but some of them require extra
parsing (e.g. a "firmware" partition).

It's required to successfully backport support for new devices using
that new syntax in their DT files.

Since brcm63xx has a custom alternative patch the upstream one is being
reverted for it. The plan is to make brcm63xx use the upstream
implementation.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
This commit is contained in:
Rafał Miłecki 2018-07-27 21:54:08 +02:00
parent 4c1aa64b4d
commit 2a598bbaa3
18 changed files with 402 additions and 36 deletions

View file

@ -0,0 +1,81 @@
From e62ff8f02eb3ae35ae7ece7c5272a689fd8b0bcd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
Date: Fri, 27 Jul 2018 21:37:48 +0200
Subject: [PATCH] Revert "mtd: partitions: use DT info for parsing partitions
with "compatible" prop"
This reverts commit 76a832254ab05502c9394cc51ded6f0abe0e0bee.
---
drivers/mtd/mtdpart.c | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -453,6 +453,22 @@ 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)
@@ -932,8 +948,8 @@ int add_mtd_partitions(struct mtd_info *
add_mtd_device(&slave->mtd);
mtd_partition_split(master, slave);
mtd_add_partition_attrs(slave);
- /* Look for subpartitions */
- parse_mtd_partitions(&slave->mtd, parts[i].types, NULL);
+ if (parts[i].types)
+ mtd_parse_part(slave, parts[i].types);
cur_offset = slave->offset + slave->mtd.size;
}
@@ -1035,12 +1051,6 @@ static const char * const default_mtd_pa
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,
@@ -1111,9 +1121,7 @@ static int mtd_part_of_parse(struct mtd_
const char *fixed = "fixed-partitions";
int ret, err = 0;
- np = mtd_get_of_node(master);
- if (!mtd_is_partition(master))
- np = of_get_child_by_name(np, "partitions");
+ np = of_get_child_by_name(mtd_get_of_node(master), "partitions");
of_property_for_each_string(np, "compatible", prop, compat) {
parser = mtd_part_get_compatible_parser(compat);
if (!parser)
@@ -1183,8 +1191,7 @@ int parse_mtd_partitions(struct mtd_info
}
if (!types)
- types = mtd_is_partition(master) ? default_subpartition_types :
- default_mtd_part_types;
+ types = default_mtd_part_types;
for ( ; *types; types++) {
/*

View file

@ -0,0 +1,81 @@
From e62ff8f02eb3ae35ae7ece7c5272a689fd8b0bcd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
Date: Fri, 27 Jul 2018 21:37:48 +0200
Subject: [PATCH] Revert "mtd: partitions: use DT info for parsing partitions
with "compatible" prop"
This reverts commit 76a832254ab05502c9394cc51ded6f0abe0e0bee.
---
drivers/mtd/mtdpart.c | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -453,6 +453,22 @@ 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)
@@ -924,8 +940,8 @@ int add_mtd_partitions(struct mtd_info *
add_mtd_device(&slave->mtd);
mtd_partition_split(master, slave);
mtd_add_partition_attrs(slave);
- /* Look for subpartitions */
- parse_mtd_partitions(&slave->mtd, parts[i].types, NULL);
+ if (parts[i].types)
+ mtd_parse_part(slave, parts[i].types);
cur_offset = slave->offset + slave->mtd.size;
}
@@ -1037,12 +1053,6 @@ static const char * const default_mtd_pa
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,
@@ -1113,9 +1123,7 @@ static int mtd_part_of_parse(struct mtd_
const char *fixed = "fixed-partitions";
int ret, err = 0;
- np = mtd_get_of_node(master);
- if (!mtd_is_partition(master))
- np = of_get_child_by_name(np, "partitions");
+ np = of_get_child_by_name(mtd_get_of_node(master), "partitions");
of_property_for_each_string(np, "compatible", prop, compat) {
parser = mtd_part_get_compatible_parser(compat);
if (!parser)
@@ -1185,8 +1193,7 @@ int parse_mtd_partitions(struct mtd_info
}
if (!types)
- types = mtd_is_partition(master) ? default_subpartition_types :
- default_mtd_part_types;
+ types = default_mtd_part_types;
for ( ; *types; types++) {
/*

View file

@ -0,0 +1,102 @@
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)
@@ -783,8 +767,8 @@ int add_mtd_partitions(struct mtd_info *
add_mtd_device(&slave->mtd);
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;
}
@@ -860,6 +844,12 @@ static const char * const default_mtd_pa
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,
@@ -930,7 +920,9 @@ static int mtd_part_of_parse(struct mtd_
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)
@@ -993,7 +985,8 @@ int parse_mtd_partitions(struct mtd_info
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++) {
/*

View file

@ -0,0 +1,102 @@
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)
@@ -775,8 +759,8 @@ int add_mtd_partitions(struct mtd_info *
add_mtd_device(&slave->mtd);
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;
}
@@ -852,6 +836,12 @@ static const char * const default_mtd_pa
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,
@@ -922,7 +912,9 @@ static int mtd_part_of_parse(struct mtd_
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)
@@ -985,7 +977,8 @@ int parse_mtd_partitions(struct mtd_info
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++) {
/*

View file

@ -104,7 +104,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
#include <linux/err.h> #include <linux/err.h>
#include <linux/of.h> #include <linux/of.h>
@@ -851,6 +852,32 @@ void deregister_mtd_parser(struct mtd_pa @@ -835,6 +836,32 @@ void deregister_mtd_parser(struct mtd_pa
EXPORT_SYMBOL_GPL(deregister_mtd_parser); EXPORT_SYMBOL_GPL(deregister_mtd_parser);
/* /*
@ -137,7 +137,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
* Do not forget to update 'parse_mtd_partitions()' kerneldoc comment if you * Do not forget to update 'parse_mtd_partitions()' kerneldoc comment if you
* are changing this array! * are changing this array!
*/ */
@@ -991,6 +1018,13 @@ int parse_mtd_partitions(struct mtd_info @@ -983,6 +1010,13 @@ int parse_mtd_partitions(struct mtd_info
struct mtd_partitions pparts = { }; struct mtd_partitions pparts = { };
struct mtd_part_parser *parser; struct mtd_part_parser *parser;
int ret, err = 0; int ret, err = 0;
@ -150,8 +150,8 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+ } + }
if (!types) if (!types)
types = default_mtd_part_types; types = mtd_is_partition(master) ? default_subpartition_types :
@@ -1031,6 +1065,7 @@ int parse_mtd_partitions(struct mtd_info @@ -1024,6 +1058,7 @@ int parse_mtd_partitions(struct mtd_info
if (ret < 0 && !err) if (ret < 0 && !err)
err = ret; err = ret;
} }

View file

@ -60,7 +60,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
/* /*
* Given a pointer to the MTD object in the mtd_part structure, we can retrieve * Given a pointer to the MTD object in the mtd_part structure, we can retrieve
* the pointer to that structure. * the pointer to that structure.
@@ -674,6 +678,7 @@ int mtd_add_partition(struct mtd_info *p @@ -658,6 +662,7 @@ int mtd_add_partition(struct mtd_info *p
mutex_unlock(&mtd_partitions_mutex); mutex_unlock(&mtd_partitions_mutex);
add_mtd_device(&new->mtd); add_mtd_device(&new->mtd);
@ -68,7 +68,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
mtd_add_partition_attrs(new); mtd_add_partition_attrs(new);
@@ -752,6 +757,35 @@ int mtd_del_partition(struct mtd_info *m @@ -736,6 +741,35 @@ int mtd_del_partition(struct mtd_info *m
} }
EXPORT_SYMBOL_GPL(mtd_del_partition); EXPORT_SYMBOL_GPL(mtd_del_partition);
@ -104,14 +104,14 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
/* /*
* This function, given a master MTD object and a partition table, creates * This function, given a master MTD object and a partition table, creates
* and registers slave MTD objects which are bound to the master according to * and registers slave MTD objects which are bound to the master according to
@@ -783,6 +817,7 @@ int add_mtd_partitions(struct mtd_info * @@ -767,6 +801,7 @@ int add_mtd_partitions(struct mtd_info *
mutex_unlock(&mtd_partitions_mutex); mutex_unlock(&mtd_partitions_mutex);
add_mtd_device(&slave->mtd); add_mtd_device(&slave->mtd);
+ mtd_partition_split(master, slave); + mtd_partition_split(master, slave);
mtd_add_partition_attrs(slave); mtd_add_partition_attrs(slave);
if (parts[i].types) /* Look for subpartitions */
mtd_parse_part(slave, parts[i].types); parse_mtd_partitions(&slave->mtd, parts[i].types, NULL);
--- a/include/linux/mtd/partitions.h --- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h +++ b/include/linux/mtd/partitions.h
@@ -110,5 +110,7 @@ int mtd_add_partition(struct mtd_info *m @@ -110,5 +110,7 @@ int mtd_add_partition(struct mtd_info *m

View file

@ -9,7 +9,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
--- a/drivers/mtd/mtdpart.c --- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c
@@ -1120,6 +1120,62 @@ void mtd_part_parser_cleanup(struct mtd_ @@ -1113,6 +1113,62 @@ void mtd_part_parser_cleanup(struct mtd_
} }
} }

View file

@ -10,7 +10,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
--- a/drivers/mtd/mtdpart.c --- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c
@@ -757,6 +757,36 @@ int mtd_del_partition(struct mtd_info *m @@ -741,6 +741,36 @@ int mtd_del_partition(struct mtd_info *m
} }
EXPORT_SYMBOL_GPL(mtd_del_partition); EXPORT_SYMBOL_GPL(mtd_del_partition);
@ -47,7 +47,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
#define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME
#else #else
@@ -765,6 +795,7 @@ EXPORT_SYMBOL_GPL(mtd_del_partition); @@ -749,6 +779,7 @@ EXPORT_SYMBOL_GPL(mtd_del_partition);
static void split_firmware(struct mtd_info *master, struct mtd_part *part) static void split_firmware(struct mtd_info *master, struct mtd_part *part)
{ {
@ -55,7 +55,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
} }
void __weak arch_split_mtd_part(struct mtd_info *master, const char *name, void __weak arch_split_mtd_part(struct mtd_info *master, const char *name,
@@ -779,6 +810,12 @@ static void mtd_partition_split(struct m @@ -763,6 +794,12 @@ static void mtd_partition_split(struct m
if (rootfs_found) if (rootfs_found)
return; return;

View file

@ -11,7 +11,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
--- a/drivers/mtd/mtdpart.c --- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c
@@ -787,6 +787,17 @@ run_parsers_by_type(struct mtd_part *sla @@ -771,6 +771,17 @@ run_parsers_by_type(struct mtd_part *sla
return nr_parts; return nr_parts;
} }
@ -29,7 +29,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
#define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME
#else #else
@@ -1230,6 +1241,24 @@ int mtd_is_partition(const struct mtd_in @@ -1223,6 +1234,24 @@ int mtd_is_partition(const struct mtd_in
} }
EXPORT_SYMBOL_GPL(mtd_is_partition); EXPORT_SYMBOL_GPL(mtd_is_partition);

View file

@ -107,7 +107,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN) if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
instr->fail_addr -= part->offset; instr->fail_addr -= part->offset;
@@ -586,19 +655,22 @@ static struct mtd_part *allocate_partiti @@ -570,19 +639,22 @@ static struct mtd_part *allocate_partiti
remainder = do_div(tmp, wr_alignment); remainder = do_div(tmp, wr_alignment);
if ((slave->mtd.flags & MTD_WRITEABLE) && remainder) { if ((slave->mtd.flags & MTD_WRITEABLE) && remainder) {
/* Doesn't start on a boundary of major erase size */ /* Doesn't start on a boundary of major erase size */

View file

@ -114,7 +114,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
#include <linux/err.h> #include <linux/err.h>
#include <linux/of.h> #include <linux/of.h>
@@ -843,6 +844,42 @@ void deregister_mtd_parser(struct mtd_pa @@ -827,6 +828,42 @@ void deregister_mtd_parser(struct mtd_pa
EXPORT_SYMBOL_GPL(deregister_mtd_parser); EXPORT_SYMBOL_GPL(deregister_mtd_parser);
/* /*
@ -157,7 +157,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
* Do not forget to update 'parse_mtd_partitions()' kerneldoc comment if you * Do not forget to update 'parse_mtd_partitions()' kerneldoc comment if you
* are changing this array! * are changing this array!
*/ */
@@ -983,6 +1020,13 @@ int parse_mtd_partitions(struct mtd_info @@ -975,6 +1012,13 @@ int parse_mtd_partitions(struct mtd_info
struct mtd_partitions pparts = { }; struct mtd_partitions pparts = { };
struct mtd_part_parser *parser; struct mtd_part_parser *parser;
int ret, err = 0; int ret, err = 0;
@ -170,8 +170,8 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+ } + }
if (!types) if (!types)
types = default_mtd_part_types; types = mtd_is_partition(master) ? default_subpartition_types :
@@ -1023,6 +1067,7 @@ int parse_mtd_partitions(struct mtd_info @@ -1016,6 +1060,7 @@ int parse_mtd_partitions(struct mtd_info
if (ret < 0 && !err) if (ret < 0 && !err)
err = ret; err = ret;
} }

View file

@ -60,7 +60,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
/* /*
* Given a pointer to the MTD object in the mtd_part structure, we can retrieve * Given a pointer to the MTD object in the mtd_part structure, we can retrieve
* the pointer to that structure. * the pointer to that structure.
@@ -666,6 +670,7 @@ int mtd_add_partition(struct mtd_info *p @@ -650,6 +654,7 @@ int mtd_add_partition(struct mtd_info *p
mutex_unlock(&mtd_partitions_mutex); mutex_unlock(&mtd_partitions_mutex);
add_mtd_device(&new->mtd); add_mtd_device(&new->mtd);
@ -68,7 +68,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
mtd_add_partition_attrs(new); mtd_add_partition_attrs(new);
@@ -744,6 +749,35 @@ int mtd_del_partition(struct mtd_info *m @@ -728,6 +733,35 @@ int mtd_del_partition(struct mtd_info *m
} }
EXPORT_SYMBOL_GPL(mtd_del_partition); EXPORT_SYMBOL_GPL(mtd_del_partition);
@ -104,14 +104,14 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
/* /*
* This function, given a master MTD object and a partition table, creates * This function, given a master MTD object and a partition table, creates
* and registers slave MTD objects which are bound to the master according to * and registers slave MTD objects which are bound to the master according to
@@ -775,6 +809,7 @@ int add_mtd_partitions(struct mtd_info * @@ -759,6 +793,7 @@ int add_mtd_partitions(struct mtd_info *
mutex_unlock(&mtd_partitions_mutex); mutex_unlock(&mtd_partitions_mutex);
add_mtd_device(&slave->mtd); add_mtd_device(&slave->mtd);
+ mtd_partition_split(master, slave); + mtd_partition_split(master, slave);
mtd_add_partition_attrs(slave); mtd_add_partition_attrs(slave);
if (parts[i].types) /* Look for subpartitions */
mtd_parse_part(slave, parts[i].types); parse_mtd_partitions(&slave->mtd, parts[i].types, NULL);
--- a/include/linux/mtd/partitions.h --- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h +++ b/include/linux/mtd/partitions.h
@@ -110,5 +110,7 @@ int mtd_add_partition(struct mtd_info *m @@ -110,5 +110,7 @@ int mtd_add_partition(struct mtd_info *m

View file

@ -9,7 +9,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
--- a/drivers/mtd/mtdpart.c --- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c
@@ -1122,6 +1122,62 @@ void mtd_part_parser_cleanup(struct mtd_ @@ -1115,6 +1115,62 @@ void mtd_part_parser_cleanup(struct mtd_
} }
} }

View file

@ -10,7 +10,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
--- a/drivers/mtd/mtdpart.c --- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c
@@ -749,6 +749,36 @@ int mtd_del_partition(struct mtd_info *m @@ -733,6 +733,36 @@ int mtd_del_partition(struct mtd_info *m
} }
EXPORT_SYMBOL_GPL(mtd_del_partition); EXPORT_SYMBOL_GPL(mtd_del_partition);
@ -47,7 +47,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
#define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME
#else #else
@@ -757,6 +787,7 @@ EXPORT_SYMBOL_GPL(mtd_del_partition); @@ -741,6 +771,7 @@ EXPORT_SYMBOL_GPL(mtd_del_partition);
static void split_firmware(struct mtd_info *master, struct mtd_part *part) static void split_firmware(struct mtd_info *master, struct mtd_part *part)
{ {
@ -55,7 +55,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
} }
void __weak arch_split_mtd_part(struct mtd_info *master, const char *name, void __weak arch_split_mtd_part(struct mtd_info *master, const char *name,
@@ -771,6 +802,12 @@ static void mtd_partition_split(struct m @@ -755,6 +786,12 @@ static void mtd_partition_split(struct m
if (rootfs_found) if (rootfs_found)
return; return;

View file

@ -11,7 +11,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
--- a/drivers/mtd/mtdpart.c --- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c
@@ -779,6 +779,17 @@ run_parsers_by_type(struct mtd_part *sla @@ -763,6 +763,17 @@ run_parsers_by_type(struct mtd_part *sla
return nr_parts; return nr_parts;
} }
@ -29,7 +29,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
#define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME
#else #else
@@ -1232,6 +1243,24 @@ int mtd_is_partition(const struct mtd_in @@ -1225,6 +1236,24 @@ int mtd_is_partition(const struct mtd_in
} }
EXPORT_SYMBOL_GPL(mtd_is_partition); EXPORT_SYMBOL_GPL(mtd_is_partition);

View file

@ -107,7 +107,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN) if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
instr->fail_addr -= part->offset; instr->fail_addr -= part->offset;
@@ -578,19 +647,22 @@ static struct mtd_part *allocate_partiti @@ -562,19 +631,22 @@ static struct mtd_part *allocate_partiti
remainder = do_div(tmp, wr_alignment); remainder = do_div(tmp, wr_alignment);
if ((slave->mtd.flags & MTD_WRITEABLE) && remainder) { if ((slave->mtd.flags & MTD_WRITEABLE) && remainder) {
/* Doesn't start on a boundary of major erase size */ /* Doesn't start on a boundary of major erase size */

View file

@ -6,7 +6,7 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
--- a/drivers/mtd/parsers/parser_trx.c --- a/drivers/mtd/parsers/parser_trx.c
+++ b/drivers/mtd/parsers/parser_trx.c +++ b/drivers/mtd/parsers/parser_trx.c
@@ -29,6 +29,33 @@ struct trx_header { @@ -30,6 +30,33 @@ struct trx_header {
uint32_t offset[3]; uint32_t offset[3];
} __packed; } __packed;
@ -40,7 +40,7 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
static const char *parser_trx_data_part_name(struct mtd_info *master, static const char *parser_trx_data_part_name(struct mtd_info *master,
size_t offset) size_t offset)
{ {
@@ -83,21 +110,21 @@ static int parser_trx_parse(struct mtd_i @@ -84,21 +111,21 @@ static int parser_trx_parse(struct mtd_i
if (trx.offset[2]) { if (trx.offset[2]) {
part = &parts[curr_part++]; part = &parts[curr_part++];
part->name = "loader"; part->name = "loader";

View file

@ -11,7 +11,7 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
--- a/drivers/mtd/bcm47xxpart.c --- a/drivers/mtd/bcm47xxpart.c
+++ b/drivers/mtd/bcm47xxpart.c +++ b/drivers/mtd/bcm47xxpart.c
@@ -39,6 +39,7 @@ @@ -40,6 +40,7 @@
#define NVRAM_HEADER 0x48534C46 /* FLSH */ #define NVRAM_HEADER 0x48534C46 /* FLSH */
#define POT_MAGIC1 0x54544f50 /* POTT */ #define POT_MAGIC1 0x54544f50 /* POTT */
#define POT_MAGIC2 0x504f /* OP */ #define POT_MAGIC2 0x504f /* OP */
@ -19,7 +19,7 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
#define ML_MAGIC1 0x39685a42 #define ML_MAGIC1 0x39685a42
#define ML_MAGIC2 0x26594131 #define ML_MAGIC2 0x26594131
#define TRX_MAGIC 0x30524448 #define TRX_MAGIC 0x30524448
@@ -182,6 +183,15 @@ static int bcm47xxpart_parse(struct mtd_ @@ -183,6 +184,15 @@ static int bcm47xxpart_parse(struct mtd_
MTD_WRITEABLE); MTD_WRITEABLE);
continue; continue;
} }