kernel: drop unneeded modification of mtd_add_partition function

In old days mtd_add_partition was checking for partitions overlapping
which was breaking our splitting feature. We had to modify this function
by adding an extra bool dup_check parameter. Upstream commit:
3a434f66e6da ("mtd: part: Remove partition overlap checks")
removed that check so we don't need our modification anymore.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>

SVN-Revision: 47748
lede-17.01
Rafał Miłecki 2015-12-04 09:33:08 +00:00
parent 416243107b
commit 304c3411ba
6 changed files with 20 additions and 54 deletions

View File

@ -40,7 +40,7 @@
/* 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;
};
@ -49,27 +49,7 @@
/*
* 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);
@ -77,20 +57,7 @@
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);
@ -126,7 +93,7 @@
/*
* 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);

View File

@ -11,7 +11,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
--- 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)
@ -42,7 +42,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
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;
}

View File

@ -1,6 +1,6 @@
--- 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);
@ -23,11 +23,10 @@
+ /* 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);
@ -38,7 +37,7 @@
#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)
{
@ -46,7 +45,7 @@
}
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;

View File

@ -1,6 +1,6 @@
--- 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) {
@ -18,7 +18,7 @@
}
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;
}
@ -36,7 +36,7 @@
#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);

View File

@ -9,7 +9,7 @@
/* 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;
@ -71,7 +71,7 @@
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);
@ -97,7 +97,7 @@
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 */

View File

@ -1,6 +1,6 @@
--- 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);