kernel: backport 2 mtd partitioning fixes
[openwrt/staging/wigyori.git] / target / linux / generic / pending-4.14 / 411-mtd-partial_eraseblock_write.patch
index a9950831057a83fa3e80308c70aec866c89e9d90..3b862dae61d851f0f7b5709084aa4c021adc5716 100644 (file)
@@ -19,7 +19,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  /* Our partition linked list */
  static LIST_HEAD(mtd_partitions);
  static DEFINE_MUTEX(mtd_partitions_mutex);
-@@ -246,13 +248,61 @@ static int part_erase(struct mtd_info *m
+@@ -255,13 +257,61 @@ static int part_erase(struct mtd_info *m
        struct mtd_part *part = mtd_to_part(mtd);
        int ret;
  
@@ -81,7 +81,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        return ret;
  }
  
-@@ -260,6 +310,25 @@ void mtd_erase_callback(struct erase_inf
+@@ -269,6 +319,25 @@ void mtd_erase_callback(struct erase_inf
  {
        if (instr->mtd->_erase == part_erase) {
                struct mtd_part *part = mtd_to_part(instr->mtd);
@@ -107,7 +107,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  
                if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
                        instr->fail_addr -= part->offset;
-@@ -574,19 +643,22 @@ static struct mtd_part *allocate_partiti
+@@ -584,19 +653,22 @@ static struct mtd_part *allocate_partiti
        remainder = do_div(tmp, wr_alignment);
        if ((slave->mtd.flags & MTD_WRITEABLE) && remainder) {
                /* Doesn't start on a boundary of major erase size */
@@ -123,8 +123,8 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
 +                      slave->mtd.erasesize = slave->mtd.size;
        }
  
--      tmp = slave->mtd.size;
-+      tmp = slave->offset + slave->mtd.size;
+-      tmp = part_absolute_offset(parent) + slave->mtd.size;
++      tmp = part_absolute_offset(parent) + slave->offset + slave->mtd.size;
        remainder = do_div(tmp, wr_alignment);
        if ((slave->mtd.flags & MTD_WRITEABLE) && remainder) {
 -              slave->mtd.flags &= ~MTD_WRITEABLE;