+++ /dev/null
-From 173b0add0cff6558f950c0cb1eacfb729d482711 Mon Sep 17 00:00:00 2001
-From: Hauke Mehrtens <hauke@hauke-m.de>
-Date: Sun, 17 May 2015 18:48:38 +0200
-Subject: [PATCH 4/8] mtd: part: add generic parsing of linux,part-probe
-
-This moves the linux,part-probe device tree parsing code from
-physmap_of.c to mtdpart.c. Now all drivers can use this feature by just
-providing a reference to their device tree node in struct
-mtd_part_parser_data.
-
-Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
----
- Documentation/devicetree/bindings/mtd/nand.txt | 16 ++++++++++
- drivers/mtd/maps/physmap_of.c | 40 +-----------------------
- drivers/mtd/mtdpart.c | 43 ++++++++++++++++++++++++++
- 3 files changed, 60 insertions(+), 39 deletions(-)
-
---- a/Documentation/devicetree/bindings/mtd/nand.txt
-+++ b/Documentation/devicetree/bindings/mtd/nand.txt
-@@ -12,6 +12,22 @@
- - nand-ecc-step-size: integer representing the number of data bytes
- that are covered by a single ECC step.
-
-+- linux,part-probe: list of name as strings of the partition parser
-+ which should be used to parse the partition table.
-+ They will be tried in the specified ordering and
-+ the next one will be used if the previous one
-+ failed.
-+
-+ Example: linux,part-probe = "cmdlinepart", "ofpart";
-+
-+ This is also the default value, which will be used
-+ if this attribute is not specified. It could be
-+ that the flash driver in use overwrote the default
-+ value and uses some other default.
-+
-+ Possible values are: bcm47xxpart, afs, ar7part,
-+ ofoldpart, ofpart, bcm63xxpart, RedBoot, cmdlinepart
-+
- The ECC strength and ECC step size properties define the correction capability
- of a controller. Together, they say a controller can correct "{strength} bit
- errors per {size} bytes".
---- a/drivers/mtd/maps/physmap_of.c
-+++ b/drivers/mtd/maps/physmap_of.c
-@@ -112,45 +112,9 @@ static struct mtd_info *obsolete_probe(s
- static const char * const part_probe_types_def[] = {
- "cmdlinepart", "RedBoot", "ofpart", "ofoldpart", NULL };
-
--static const char * const *of_get_probes(struct device_node *dp)
--{
-- const char *cp;
-- int cplen;
-- unsigned int l;
-- unsigned int count;
-- const char **res;
--
-- cp = of_get_property(dp, "linux,part-probe", &cplen);
-- if (cp == NULL)
-- return part_probe_types_def;
--
-- count = 0;
-- for (l = 0; l != cplen; l++)
-- if (cp[l] == 0)
-- count++;
--
-- res = kzalloc((count + 1)*sizeof(*res), GFP_KERNEL);
-- count = 0;
-- while (cplen > 0) {
-- res[count] = cp;
-- l = strlen(cp) + 1;
-- cp += l;
-- cplen -= l;
-- count++;
-- }
-- return res;
--}
--
--static void of_free_probes(const char * const *probes)
--{
-- if (probes != part_probe_types_def)
-- kfree(probes);
--}
--
- static struct of_device_id of_flash_match[];
- static int of_flash_probe(struct platform_device *dev)
- {
-- const char * const *part_probe_types;
- const struct of_device_id *match;
- struct device_node *dp = dev->dev.of_node;
- struct resource res;
-@@ -310,10 +274,8 @@ static int of_flash_probe(struct platfor
- goto err_out;
-
- ppdata.of_node = dp;
-- part_probe_types = of_get_probes(dp);
-- mtd_device_parse_register(info->cmtd, part_probe_types, &ppdata,
-+ mtd_device_parse_register(info->cmtd, part_probe_types_def, &ppdata,
- NULL, 0);
-- of_free_probes(part_probe_types);
-
- kfree(mtd_list);
-
---- a/drivers/mtd/mtdpart.c
-+++ b/drivers/mtd/mtdpart.c
-@@ -29,6 +29,7 @@
- #include <linux/kmod.h>
- #include <linux/mtd/mtd.h>
- #include <linux/mtd/partitions.h>
-+#include <linux/of.h>
- #include <linux/magic.h>
- #include <linux/err.h>
- #include <linux/kconfig.h>
-@@ -992,6 +993,40 @@ void deregister_mtd_parser(struct mtd_pa
- EXPORT_SYMBOL_GPL(deregister_mtd_parser);
-
- /*
-+ * Parses the linux,part-probe device tree property.
-+ * When a non null value is returned it has to be freed with kfree() by
-+ * the caller.
-+ */
-+static const char * const *of_get_probes(struct device_node *dp)
-+{
-+ const char *cp;
-+ int cplen;
-+ unsigned int l;
-+ unsigned int count;
-+ const char **res;
-+
-+ cp = of_get_property(dp, "linux,part-probe", &cplen);
-+ if (cp == NULL)
-+ return NULL;
-+
-+ count = 0;
-+ for (l = 0; l != cplen; l++)
-+ if (cp[l] == 0)
-+ count++;
-+
-+ res = kzalloc((count + 1) * sizeof(*res), GFP_KERNEL);
-+ count = 0;
-+ while (cplen > 0) {
-+ res[count] = cp;
-+ l = strlen(cp) + 1;
-+ cp += l;
-+ cplen -= l;
-+ count++;
-+ }
-+ return res;
-+}
-+
-+/*
- * Do not forget to update 'parse_mtd_partitions()' kerneldoc comment if you
- * are changing this array!
- */
-@@ -1027,6 +1062,13 @@ int parse_mtd_partitions(struct mtd_info
- {
- struct mtd_part_parser *parser;
- int ret = 0;
-+ const char *const *types_of = NULL;
-+
-+ if (data && data->of_node) {
-+ types_of = of_get_probes(data->of_node);
-+ if (types_of != NULL)
-+ types = types_of;
-+ }
-
- if (!types)
- types = default_mtd_part_types;
-@@ -1045,6 +1087,7 @@ int parse_mtd_partitions(struct mtd_info
- break;
- }
- }
-+ kfree(types_of);
- return ret;
- }
-
--- /dev/null
+From 173b0add0cff6558f950c0cb1eacfb729d482711 Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Sun, 17 May 2015 18:48:38 +0200
+Subject: [PATCH 4/8] mtd: part: add generic parsing of linux,part-probe
+
+This moves the linux,part-probe device tree parsing code from
+physmap_of.c to mtdpart.c. Now all drivers can use this feature by just
+providing a reference to their device tree node in struct
+mtd_part_parser_data.
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+---
+ Documentation/devicetree/bindings/mtd/nand.txt | 16 ++++++++++
+ drivers/mtd/maps/physmap_of.c | 40 +-----------------------
+ drivers/mtd/mtdpart.c | 43 ++++++++++++++++++++++++++
+ 3 files changed, 60 insertions(+), 39 deletions(-)
+
+--- a/Documentation/devicetree/bindings/mtd/nand.txt
++++ b/Documentation/devicetree/bindings/mtd/nand.txt
+@@ -12,6 +12,22 @@
+ - nand-ecc-step-size: integer representing the number of data bytes
+ that are covered by a single ECC step.
+
++- linux,part-probe: list of name as strings of the partition parser
++ which should be used to parse the partition table.
++ They will be tried in the specified ordering and
++ the next one will be used if the previous one
++ failed.
++
++ Example: linux,part-probe = "cmdlinepart", "ofpart";
++
++ This is also the default value, which will be used
++ if this attribute is not specified. It could be
++ that the flash driver in use overwrote the default
++ value and uses some other default.
++
++ Possible values are: bcm47xxpart, afs, ar7part,
++ ofoldpart, ofpart, bcm63xxpart, RedBoot, cmdlinepart
++
+ The ECC strength and ECC step size properties define the correction capability
+ of a controller. Together, they say a controller can correct "{strength} bit
+ errors per {size} bytes".
+--- a/drivers/mtd/maps/physmap_of.c
++++ b/drivers/mtd/maps/physmap_of.c
+@@ -114,45 +114,9 @@ static struct mtd_info *obsolete_probe(s
+ static const char * const part_probe_types_def[] = {
+ "cmdlinepart", "RedBoot", "ofpart", "ofoldpart", NULL };
+
+-static const char * const *of_get_probes(struct device_node *dp)
+-{
+- const char *cp;
+- int cplen;
+- unsigned int l;
+- unsigned int count;
+- const char **res;
+-
+- cp = of_get_property(dp, "linux,part-probe", &cplen);
+- if (cp == NULL)
+- return part_probe_types_def;
+-
+- count = 0;
+- for (l = 0; l != cplen; l++)
+- if (cp[l] == 0)
+- count++;
+-
+- res = kzalloc((count + 1)*sizeof(*res), GFP_KERNEL);
+- count = 0;
+- while (cplen > 0) {
+- res[count] = cp;
+- l = strlen(cp) + 1;
+- cp += l;
+- cplen -= l;
+- count++;
+- }
+- return res;
+-}
+-
+-static void of_free_probes(const char * const *probes)
+-{
+- if (probes != part_probe_types_def)
+- kfree(probes);
+-}
+-
+ static struct of_device_id of_flash_match[];
+ static int of_flash_probe(struct platform_device *dev)
+ {
+- const char * const *part_probe_types;
+ const struct of_device_id *match;
+ struct device_node *dp = dev->dev.of_node;
+ struct resource res;
+@@ -302,10 +266,8 @@ static int of_flash_probe(struct platfor
+ goto err_out;
+
+ ppdata.of_node = dp;
+- part_probe_types = of_get_probes(dp);
+- mtd_device_parse_register(info->cmtd, part_probe_types, &ppdata,
++ mtd_device_parse_register(info->cmtd, part_probe_types_def, &ppdata,
+ NULL, 0);
+- of_free_probes(part_probe_types);
+
+ kfree(mtd_list);
+
+--- a/drivers/mtd/mtdpart.c
++++ b/drivers/mtd/mtdpart.c
+@@ -29,6 +29,7 @@
+ #include <linux/kmod.h>
+ #include <linux/mtd/mtd.h>
+ #include <linux/mtd/partitions.h>
++#include <linux/of.h>
+ #include <linux/err.h>
+
+ #include "mtdcore.h"
+@@ -702,6 +703,40 @@ void deregister_mtd_parser(struct mtd_pa
+ EXPORT_SYMBOL_GPL(deregister_mtd_parser);
+
+ /*
++ * Parses the linux,part-probe device tree property.
++ * When a non null value is returned it has to be freed with kfree() by
++ * the caller.
++ */
++static const char * const *of_get_probes(struct device_node *dp)
++{
++ const char *cp;
++ int cplen;
++ unsigned int l;
++ unsigned int count;
++ const char **res;
++
++ cp = of_get_property(dp, "linux,part-probe", &cplen);
++ if (cp == NULL)
++ return NULL;
++
++ count = 0;
++ for (l = 0; l != cplen; l++)
++ if (cp[l] == 0)
++ count++;
++
++ res = kzalloc((count + 1) * sizeof(*res), GFP_KERNEL);
++ count = 0;
++ while (cplen > 0) {
++ res[count] = cp;
++ l = strlen(cp) + 1;
++ cp += l;
++ cplen -= l;
++ count++;
++ }
++ return res;
++}
++
++/*
+ * Do not forget to update 'parse_mtd_partitions()' kerneldoc comment if you
+ * are changing this array!
+ */
+@@ -737,6 +772,13 @@ int parse_mtd_partitions(struct mtd_info
+ {
+ struct mtd_part_parser *parser;
+ int ret = 0;
++ const char *const *types_of = NULL;
++
++ if (data && data->of_node) {
++ types_of = of_get_probes(data->of_node);
++ if (types_of != NULL)
++ types = types_of;
++ }
+
+ if (!types)
+ types = default_mtd_part_types;
+@@ -755,6 +797,7 @@ int parse_mtd_partitions(struct mtd_info
+ break;
+ }
+ }
++ kfree(types_of);
+ return ret;
+ }
+
depends on m
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
-@@ -29,9 +29,11 @@
- #include <linux/kmod.h>
+@@ -30,9 +30,11 @@
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
+ #include <linux/of.h>
+#include <linux/magic.h>
#include <linux/err.h>
/* Our partition linked list */
static LIST_HEAD(mtd_partitions);
-@@ -45,13 +47,14 @@ struct mtd_part {
+@@ -46,13 +48,14 @@ struct mtd_part {
struct list_head list;
};
/*
* MTD methods which simply translate the effective address and pass through
* to the _real_ device.
-@@ -547,8 +550,10 @@ out_register:
+@@ -548,8 +551,10 @@ out_register:
return slave;
}
{
struct mtd_partition part;
struct mtd_part *p, *new;
-@@ -580,21 +585,24 @@ int mtd_add_partition(struct mtd_info *m
+@@ -581,21 +586,24 @@ int mtd_add_partition(struct mtd_info *m
end = offset + length;
mutex_lock(&mtd_partitions_mutex);
return ret;
err_inv:
-@@ -604,6 +612,12 @@ err_inv:
+@@ -605,6 +613,12 @@ err_inv:
}
EXPORT_SYMBOL_GPL(mtd_add_partition);
int mtd_del_partition(struct mtd_info *master, int partno)
{
struct mtd_part *slave, *next;
-@@ -627,6 +641,35 @@ int mtd_del_partition(struct mtd_info *m
+@@ -628,6 +642,35 @@ int mtd_del_partition(struct mtd_info *m
}
EXPORT_SYMBOL_GPL(mtd_del_partition);
/*
* 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
-@@ -656,6 +699,7 @@ int add_mtd_partitions(struct mtd_info *
+@@ -657,6 +700,7 @@ int add_mtd_partitions(struct mtd_info *
mutex_unlock(&mtd_partitions_mutex);
add_mtd_device(&slave->mtd);
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
-@@ -729,6 +729,30 @@ static struct mtd_part_parser *get_parti
+@@ -730,6 +730,30 @@ static struct mtd_part_parser *get_parti
#define put_partition_parser(p) do { module_put((p)->owner); } while (0)
void register_mtd_parser(struct mtd_part_parser *p)
{
spin_lock(&part_parser_lock);
-@@ -802,6 +826,38 @@ int parse_mtd_partitions(struct mtd_info
+@@ -845,6 +869,38 @@ int parse_mtd_partitions(struct mtd_info
return ret;
}
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
-@@ -641,6 +641,37 @@ int mtd_del_partition(struct mtd_info *m
+@@ -642,6 +642,37 @@ int mtd_del_partition(struct mtd_info *m
}
EXPORT_SYMBOL_GPL(mtd_del_partition);
#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
#define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME
#else
-@@ -649,6 +680,7 @@ EXPORT_SYMBOL_GPL(mtd_del_partition);
+@@ -650,6 +681,7 @@ EXPORT_SYMBOL_GPL(mtd_del_partition);
static void split_firmware(struct mtd_info *master, struct mtd_part *part)
{
}
void __weak arch_split_mtd_part(struct mtd_info *master, const char *name,
-@@ -663,6 +695,12 @@ static void mtd_partition_split(struct m
+@@ -664,6 +696,12 @@ static void mtd_partition_split(struct m
if (rootfs_found)
return;
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
-@@ -445,14 +445,12 @@ static struct mtd_part *allocate_partiti
+@@ -446,14 +446,12 @@ static struct mtd_part *allocate_partiti
if (slave->offset == MTDPART_OFS_APPEND)
slave->offset = cur_offset;
if (slave->offset == MTDPART_OFS_NXTBLK) {
}
if (slave->offset == MTDPART_OFS_RETAIN) {
slave->offset = cur_offset;
-@@ -672,6 +670,17 @@ run_parsers_by_type(struct mtd_part *sla
+@@ -673,6 +671,17 @@ run_parsers_by_type(struct mtd_part *sla
return nr_parts;
}
#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
#define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME
#else
-@@ -913,6 +922,24 @@ int mtd_is_partition(const struct mtd_in
+@@ -956,6 +965,24 @@ int mtd_is_partition(const struct mtd_in
}
EXPORT_SYMBOL_GPL(mtd_is_partition);
endmenu
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
-@@ -681,6 +681,37 @@ mtd_pad_erasesize(struct mtd_info *mtd,
+@@ -682,6 +682,37 @@ mtd_pad_erasesize(struct mtd_info *mtd,
return len;
}
#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
#define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME
#else
-@@ -689,7 +720,14 @@ mtd_pad_erasesize(struct mtd_info *mtd,
+@@ -690,7 +721,14 @@ mtd_pad_erasesize(struct mtd_info *mtd,
static void split_firmware(struct mtd_info *master, struct mtd_part *part)
{
default y
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
-@@ -681,6 +681,47 @@ mtd_pad_erasesize(struct mtd_info *mtd,
+@@ -682,6 +682,47 @@ mtd_pad_erasesize(struct mtd_info *mtd,
return len;
}
#define UBOOT_MAGIC 0x27051956
static void split_uimage(struct mtd_info *master, struct mtd_part *part)
-@@ -743,7 +784,10 @@ static void mtd_partition_split(struct m
+@@ -744,7 +785,10 @@ static void mtd_partition_split(struct m
return;
if (!strcmp(part->mtd.name, "rootfs")) {
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
-@@ -35,6 +35,8 @@
+@@ -36,6 +36,8 @@
#include "mtdcore.h"
#include "mtdsplit/mtdsplit.h"
/* Our partition linked list */
static LIST_HEAD(mtd_partitions);
static DEFINE_MUTEX(mtd_partitions_mutex);
-@@ -233,13 +235,61 @@ static int part_erase(struct mtd_info *m
+@@ -234,13 +236,61 @@ static int part_erase(struct mtd_info *m
struct mtd_part *part = PART(mtd);
int ret;
return ret;
}
-@@ -247,7 +297,25 @@ void mtd_erase_callback(struct erase_inf
+@@ -248,7 +298,25 @@ void mtd_erase_callback(struct erase_inf
{
if (instr->mtd->_erase == part_erase) {
struct mtd_part *part = PART(instr->mtd);
if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
instr->fail_addr -= part->offset;
instr->addr -= part->offset;
-@@ -514,17 +582,20 @@ static struct mtd_part *allocate_partiti
+@@ -515,17 +583,20 @@ static struct mtd_part *allocate_partiti
if ((slave->mtd.flags & MTD_WRITEABLE) &&
mtd_mod_by_eb(slave->offset, &slave->mtd)) {
/* Doesn't start on a boundary of major erase size */
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
-@@ -334,7 +334,14 @@ static int part_lock(struct mtd_info *mt
+@@ -335,7 +335,14 @@ static int part_lock(struct mtd_info *mt
static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
{
struct mtd_part *part = PART(mtd);
--- /dev/null
+From 173b0add0cff6558f950c0cb1eacfb729d482711 Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Sun, 17 May 2015 18:48:38 +0200
+Subject: [PATCH 4/8] mtd: part: add generic parsing of linux,part-probe
+
+This moves the linux,part-probe device tree parsing code from
+physmap_of.c to mtdpart.c. Now all drivers can use this feature by just
+providing a reference to their device tree node in struct
+mtd_part_parser_data.
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+---
+ Documentation/devicetree/bindings/mtd/nand.txt | 16 ++++++++++
+ drivers/mtd/maps/physmap_of.c | 40 +-----------------------
+ drivers/mtd/mtdpart.c | 43 ++++++++++++++++++++++++++
+ 3 files changed, 60 insertions(+), 39 deletions(-)
+
+--- a/Documentation/devicetree/bindings/mtd/nand.txt
++++ b/Documentation/devicetree/bindings/mtd/nand.txt
+@@ -12,6 +12,22 @@
+ - nand-ecc-step-size: integer representing the number of data bytes
+ that are covered by a single ECC step.
+
++- linux,part-probe: list of name as strings of the partition parser
++ which should be used to parse the partition table.
++ They will be tried in the specified ordering and
++ the next one will be used if the previous one
++ failed.
++
++ Example: linux,part-probe = "cmdlinepart", "ofpart";
++
++ This is also the default value, which will be used
++ if this attribute is not specified. It could be
++ that the flash driver in use overwrote the default
++ value and uses some other default.
++
++ Possible values are: bcm47xxpart, afs, ar7part,
++ ofoldpart, ofpart, bcm63xxpart, RedBoot, cmdlinepart
++
+ The ECC strength and ECC step size properties define the correction capability
+ of a controller. Together, they say a controller can correct "{strength} bit
+ errors per {size} bytes".
+--- a/drivers/mtd/maps/physmap_of.c
++++ b/drivers/mtd/maps/physmap_of.c
+@@ -112,45 +112,9 @@ static struct mtd_info *obsolete_probe(s
+ static const char * const part_probe_types_def[] = {
+ "cmdlinepart", "RedBoot", "ofpart", "ofoldpart", NULL };
+
+-static const char * const *of_get_probes(struct device_node *dp)
+-{
+- const char *cp;
+- int cplen;
+- unsigned int l;
+- unsigned int count;
+- const char **res;
+-
+- cp = of_get_property(dp, "linux,part-probe", &cplen);
+- if (cp == NULL)
+- return part_probe_types_def;
+-
+- count = 0;
+- for (l = 0; l != cplen; l++)
+- if (cp[l] == 0)
+- count++;
+-
+- res = kzalloc((count + 1)*sizeof(*res), GFP_KERNEL);
+- count = 0;
+- while (cplen > 0) {
+- res[count] = cp;
+- l = strlen(cp) + 1;
+- cp += l;
+- cplen -= l;
+- count++;
+- }
+- return res;
+-}
+-
+-static void of_free_probes(const char * const *probes)
+-{
+- if (probes != part_probe_types_def)
+- kfree(probes);
+-}
+-
+ static struct of_device_id of_flash_match[];
+ static int of_flash_probe(struct platform_device *dev)
+ {
+- const char * const *part_probe_types;
+ const struct of_device_id *match;
+ struct device_node *dp = dev->dev.of_node;
+ struct resource res;
+@@ -310,10 +274,8 @@ static int of_flash_probe(struct platfor
+ goto err_out;
+
+ ppdata.of_node = dp;
+- part_probe_types = of_get_probes(dp);
+- mtd_device_parse_register(info->cmtd, part_probe_types, &ppdata,
++ mtd_device_parse_register(info->cmtd, part_probe_types_def, &ppdata,
+ NULL, 0);
+- of_free_probes(part_probe_types);
+
+ kfree(mtd_list);
+
+--- a/drivers/mtd/mtdpart.c
++++ b/drivers/mtd/mtdpart.c
+@@ -29,6 +29,7 @@
+ #include <linux/kmod.h>
+ #include <linux/mtd/mtd.h>
+ #include <linux/mtd/partitions.h>
++#include <linux/of.h>
+ #include <linux/err.h>
+ #include <linux/kconfig.h>
+
+@@ -719,6 +720,40 @@ void deregister_mtd_parser(struct mtd_pa
+ EXPORT_SYMBOL_GPL(deregister_mtd_parser);
+
+ /*
++ * Parses the linux,part-probe device tree property.
++ * When a non null value is returned it has to be freed with kfree() by
++ * the caller.
++ */
++static const char * const *of_get_probes(struct device_node *dp)
++{
++ const char *cp;
++ int cplen;
++ unsigned int l;
++ unsigned int count;
++ const char **res;
++
++ cp = of_get_property(dp, "linux,part-probe", &cplen);
++ if (cp == NULL)
++ return NULL;
++
++ count = 0;
++ for (l = 0; l != cplen; l++)
++ if (cp[l] == 0)
++ count++;
++
++ res = kzalloc((count + 1) * sizeof(*res), GFP_KERNEL);
++ count = 0;
++ while (cplen > 0) {
++ res[count] = cp;
++ l = strlen(cp) + 1;
++ cp += l;
++ cplen -= l;
++ count++;
++ }
++ return res;
++}
++
++/*
+ * Do not forget to update 'parse_mtd_partitions()' kerneldoc comment if you
+ * are changing this array!
+ */
+@@ -754,6 +789,13 @@ int parse_mtd_partitions(struct mtd_info
+ {
+ struct mtd_part_parser *parser;
+ int ret = 0;
++ const char *const *types_of = NULL;
++
++ if (data && data->of_node) {
++ types_of = of_get_probes(data->of_node);
++ if (types_of != NULL)
++ types = types_of;
++ }
+
+ if (!types)
+ types = default_mtd_part_types;
+@@ -772,6 +814,7 @@ int parse_mtd_partitions(struct mtd_info
+ break;
+ }
+ }
++ kfree(types_of);
+ return ret;
+ }
+
depends on m
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
-@@ -29,10 +29,12 @@
+@@ -29,11 +29,13 @@
#include <linux/kmod.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
+#include <linux/magic.h>
+ #include <linux/of.h>
#include <linux/err.h>
#include <linux/kconfig.h>
/* Our partition linked list */
static LIST_HEAD(mtd_partitions);
-@@ -46,13 +48,14 @@ struct mtd_part {
+@@ -47,13 +49,14 @@ struct mtd_part {
struct list_head list;
};
/*
* MTD methods which simply translate the effective address and pass through
* to the _real_ device.
-@@ -578,8 +581,10 @@ static int mtd_add_partition_attrs(struc
+@@ -579,8 +582,10 @@ static int mtd_add_partition_attrs(struc
return ret;
}
{
struct mtd_partition part;
struct mtd_part *new;
-@@ -611,6 +616,7 @@ int mtd_add_partition(struct mtd_info *m
+@@ -612,6 +617,7 @@ int mtd_add_partition(struct mtd_info *m
mutex_unlock(&mtd_partitions_mutex);
add_mtd_device(&new->mtd);
mtd_add_partition_attrs(new);
-@@ -618,6 +624,12 @@ int mtd_add_partition(struct mtd_info *m
+@@ -619,6 +625,12 @@ int mtd_add_partition(struct mtd_info *m
}
EXPORT_SYMBOL_GPL(mtd_add_partition);
int mtd_del_partition(struct mtd_info *master, int partno)
{
struct mtd_part *slave, *next;
-@@ -643,6 +655,35 @@ int mtd_del_partition(struct mtd_info *m
+@@ -644,6 +656,35 @@ int mtd_del_partition(struct mtd_info *m
}
EXPORT_SYMBOL_GPL(mtd_del_partition);
/*
* 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
-@@ -672,6 +713,7 @@ int add_mtd_partitions(struct mtd_info *
+@@ -673,6 +714,7 @@ int add_mtd_partitions(struct mtd_info *
mutex_unlock(&mtd_partitions_mutex);
add_mtd_device(&slave->mtd);
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
-@@ -744,6 +744,30 @@ static struct mtd_part_parser *get_parti
+@@ -745,6 +745,30 @@ static struct mtd_part_parser *get_parti
#define put_partition_parser(p) do { module_put((p)->owner); } while (0)
void register_mtd_parser(struct mtd_part_parser *p)
{
spin_lock(&part_parser_lock);
-@@ -817,6 +841,38 @@ int parse_mtd_partitions(struct mtd_info
+@@ -860,6 +884,38 @@ int parse_mtd_partitions(struct mtd_info
return ret;
}
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
-@@ -655,6 +655,37 @@ int mtd_del_partition(struct mtd_info *m
+@@ -656,6 +656,37 @@ int mtd_del_partition(struct mtd_info *m
}
EXPORT_SYMBOL_GPL(mtd_del_partition);
#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
#define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME
#else
-@@ -663,6 +694,7 @@ EXPORT_SYMBOL_GPL(mtd_del_partition);
+@@ -664,6 +695,7 @@ EXPORT_SYMBOL_GPL(mtd_del_partition);
static void split_firmware(struct mtd_info *master, struct mtd_part *part)
{
}
void __weak arch_split_mtd_part(struct mtd_info *master, const char *name,
-@@ -677,6 +709,12 @@ static void mtd_partition_split(struct m
+@@ -678,6 +710,12 @@ static void mtd_partition_split(struct m
if (rootfs_found)
return;
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
-@@ -452,14 +452,12 @@ static struct mtd_part *allocate_partiti
+@@ -453,14 +453,12 @@ static struct mtd_part *allocate_partiti
if (slave->offset == MTDPART_OFS_APPEND)
slave->offset = cur_offset;
if (slave->offset == MTDPART_OFS_NXTBLK) {
}
if (slave->offset == MTDPART_OFS_RETAIN) {
slave->offset = cur_offset;
-@@ -686,6 +684,17 @@ run_parsers_by_type(struct mtd_part *sla
+@@ -687,6 +685,17 @@ run_parsers_by_type(struct mtd_part *sla
return nr_parts;
}
#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
#define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME
#else
-@@ -928,6 +937,24 @@ int mtd_is_partition(const struct mtd_in
+@@ -971,6 +980,24 @@ int mtd_is_partition(const struct mtd_in
}
EXPORT_SYMBOL_GPL(mtd_is_partition);
endmenu
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
-@@ -695,6 +695,37 @@ mtd_pad_erasesize(struct mtd_info *mtd,
+@@ -696,6 +696,37 @@ mtd_pad_erasesize(struct mtd_info *mtd,
return len;
}
#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
#define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME
#else
-@@ -703,7 +734,14 @@ mtd_pad_erasesize(struct mtd_info *mtd,
+@@ -704,7 +735,14 @@ mtd_pad_erasesize(struct mtd_info *mtd,
static void split_firmware(struct mtd_info *master, struct mtd_part *part)
{
default y
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
-@@ -695,6 +695,47 @@ mtd_pad_erasesize(struct mtd_info *mtd,
+@@ -696,6 +696,47 @@ mtd_pad_erasesize(struct mtd_info *mtd,
return len;
}
#define UBOOT_MAGIC 0x27051956
static void split_uimage(struct mtd_info *master, struct mtd_part *part)
-@@ -757,7 +798,10 @@ static void mtd_partition_split(struct m
+@@ -758,7 +799,10 @@ static void mtd_partition_split(struct m
return;
if (!strcmp(part->mtd.name, "rootfs")) {
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
-@@ -36,6 +36,8 @@
+@@ -37,6 +37,8 @@
#include "mtdcore.h"
#include "mtdsplit/mtdsplit.h"
/* Our partition linked list */
static LIST_HEAD(mtd_partitions);
static DEFINE_MUTEX(mtd_partitions_mutex);
-@@ -234,13 +236,61 @@ static int part_erase(struct mtd_info *m
+@@ -235,13 +237,61 @@ static int part_erase(struct mtd_info *m
struct mtd_part *part = PART(mtd);
int ret;
return ret;
}
-@@ -248,7 +298,25 @@ void mtd_erase_callback(struct erase_inf
+@@ -249,7 +299,25 @@ void mtd_erase_callback(struct erase_inf
{
if (instr->mtd->_erase == part_erase) {
struct mtd_part *part = PART(instr->mtd);
if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
instr->fail_addr -= part->offset;
instr->addr -= part->offset;
-@@ -521,17 +589,20 @@ static struct mtd_part *allocate_partiti
+@@ -522,17 +590,20 @@ static struct mtd_part *allocate_partiti
if ((slave->mtd.flags & MTD_WRITEABLE) &&
mtd_mod_by_eb(slave->offset, &slave->mtd)) {
/* Doesn't start on a boundary of major erase size */
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
-@@ -335,7 +335,14 @@ static int part_lock(struct mtd_info *mt
+@@ -336,7 +336,14 @@ static int part_lock(struct mtd_info *mt
static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
{
struct mtd_part *part = PART(mtd);