/* Our partition linked list */
static LIST_HEAD(mtd_partitions);
-@@ -47,13 +49,14 @@ struct mtd_part {
+@@ -47,6 +49,8 @@ struct mtd_part {
struct list_head list;
};
/*
* Given a pointer to the MTD object in the mtd_part structure, we can retrieve
* the pointer to that structure with this macro.
- */
- #define PART(x) ((struct mtd_part *)(x))
-
--
- /*
- * MTD methods which simply translate the effective address and pass through
- * to the _real_ device.
-@@ -579,8 +582,10 @@ static int mtd_add_partition_attrs(struc
- return ret;
- }
-
--int mtd_add_partition(struct mtd_info *master, const char *name,
-- long long offset, long long length)
-+
-+static int
-+__mtd_add_partition(struct mtd_info *master, const char *name,
-+ long long offset, long long length, bool dup_check)
- {
- struct mtd_partition part;
- struct mtd_part *new;
-@@ -612,6 +617,7 @@ int mtd_add_partition(struct mtd_info *m
+@@ -612,6 +616,7 @@ int mtd_add_partition(struct mtd_info *m
mutex_unlock(&mtd_partitions_mutex);
add_mtd_device(&new->mtd);
mtd_add_partition_attrs(new);
-@@ -619,6 +625,12 @@ int mtd_add_partition(struct mtd_info *m
- }
- EXPORT_SYMBOL_GPL(mtd_add_partition);
-
-+int mtd_add_partition(struct mtd_info *master, const char *name,
-+ long long offset, long long length)
-+{
-+ return __mtd_add_partition(master, name, offset, length, true);
-+}
-+
- int mtd_del_partition(struct mtd_info *master, int partno)
- {
- struct mtd_part *slave, *next;
-@@ -644,6 +656,35 @@ int mtd_del_partition(struct mtd_info *m
+@@ -644,6 +649,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
-@@ -675,6 +716,7 @@ int add_mtd_partitions(struct mtd_info *
+@@ -675,6 +709,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
-@@ -747,6 +747,30 @@ static struct mtd_part_parser *get_parti
+@@ -740,6 +740,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);
-@@ -875,6 +899,38 @@ int parse_mtd_partitions(struct mtd_info
+@@ -868,6 +892,38 @@ int parse_mtd_partitions(struct mtd_info
return err;
}
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
-@@ -656,6 +656,37 @@ int mtd_del_partition(struct mtd_info *m
+@@ -649,6 +649,36 @@ int mtd_del_partition(struct mtd_info *m
}
EXPORT_SYMBOL_GPL(mtd_del_partition);
+ /* adjust partition offsets */
+ parts[i].offset += slave->offset;
+
-+ __mtd_add_partition(slave->master,
-+ parts[i].name,
-+ parts[i].offset,
-+ parts[i].size,
-+ false);
++ mtd_add_partition(slave->master,
++ parts[i].name,
++ parts[i].offset,
++ parts[i].size);
+ }
+
+ kfree(parts);
#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
#define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME
#else
-@@ -664,6 +695,7 @@ EXPORT_SYMBOL_GPL(mtd_del_partition);
+@@ -657,6 +687,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,
-@@ -678,6 +710,12 @@ static void mtd_partition_split(struct m
+@@ -671,6 +702,12 @@ static void mtd_partition_split(struct m
if (rootfs_found)
return;
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
-@@ -453,14 +453,12 @@ static struct mtd_part *allocate_partiti
+@@ -454,14 +454,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;
-@@ -687,6 +685,17 @@ run_parsers_by_type(struct mtd_part *sla
+@@ -679,6 +677,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
-@@ -986,6 +995,24 @@ int mtd_is_partition(const struct mtd_in
+@@ -978,6 +987,24 @@ int mtd_is_partition(const struct mtd_in
}
EXPORT_SYMBOL_GPL(mtd_is_partition);
/* Our partition linked list */
static LIST_HEAD(mtd_partitions);
static DEFINE_MUTEX(mtd_partitions_mutex);
-@@ -235,13 +237,61 @@ static int part_erase(struct mtd_info *m
+@@ -236,13 +238,61 @@ static int part_erase(struct mtd_info *m
struct mtd_part *part = PART(mtd);
int ret;
return ret;
}
-@@ -249,7 +299,25 @@ void mtd_erase_callback(struct erase_inf
+@@ -250,7 +300,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;
-@@ -522,17 +590,20 @@ static struct mtd_part *allocate_partiti
+@@ -523,17 +591,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
-@@ -336,7 +336,14 @@ static int part_lock(struct mtd_info *mt
+@@ -337,7 +337,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);