kernel: mtd: allow partial block erase
authorFelix Fietkau <nbd@openwrt.org>
Fri, 18 Jul 2014 14:36:38 +0000 (14:36 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Fri, 18 Jul 2014 14:36:38 +0000 (14:36 +0000)
This fixes error erasing partial mtd partition which does not start on
eraseblock boundary and allows using fconfig to configure redboot on
devices such as the Gateworks Cambria.

Signed-off-by: Maciej Skrzypek <maciej.skrzypek@flytronic.pl>
SVN-Revision: 41733

target/linux/generic/patches-3.10/411-mtd-partial_eraseblock_write.patch
target/linux/generic/patches-3.13/411-mtd-partial_eraseblock_write.patch
target/linux/generic/patches-3.14/411-mtd-partial_eraseblock_write.patch
target/linux/generic/patches-3.3/401-partial_eraseblock_write.patch
target/linux/generic/patches-3.6/401-partial_eraseblock_write.patch
target/linux/generic/patches-3.8/401-partial_eraseblock_write.patch
target/linux/generic/patches-3.9/401-partial_eraseblock_write.patch

index b7152110b2912b61bddbbd0e0b039063bcca6c32..940741120703954a9c44457602b5ab9bc9316c53 100644 (file)
@@ -9,7 +9,7 @@
  /* Our partition linked list */
  static LIST_HEAD(mtd_partitions);
  static DEFINE_MUTEX(mtd_partitions_mutex);
-@@ -231,13 +233,60 @@ static int part_erase(struct mtd_info *m
+@@ -231,13 +233,61 @@ static int part_erase(struct mtd_info *m
        struct mtd_part *part = PART(mtd);
        int ret;
  
@@ -33,6 +33,7 @@
 +                              part->master->erasesize,
 +                              &readlen, instr->erase_buf);
 +
++                      instr->len += instr->erase_buf_ofs;
 +                      instr->partial_start = true;
 +              } else {
 +                      mtd_ofs = part->offset + part->mtd.size;
@@ -70,7 +71,7 @@
        return ret;
  }
  
-@@ -245,7 +294,25 @@ void mtd_erase_callback(struct erase_inf
+@@ -245,7 +295,25 @@ void mtd_erase_callback(struct erase_inf
  {
        if (instr->mtd->_erase == part_erase) {
                struct mtd_part *part = PART(instr->mtd);
@@ -96,7 +97,7 @@
                if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
                        instr->fail_addr -= part->offset;
                instr->addr -= part->offset;
-@@ -503,18 +570,24 @@ static struct mtd_part *allocate_partiti
+@@ -503,18 +571,24 @@ 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 */
index 7facf0db1520aafd773c12e6e3ddaccf20519ebc..8da080b2ade89e36f1da84e7be28d63a3c572d8d 100644 (file)
@@ -9,7 +9,7 @@
  /* Our partition linked list */
  static LIST_HEAD(mtd_partitions);
  static DEFINE_MUTEX(mtd_partitions_mutex);
-@@ -231,13 +233,60 @@ static int part_erase(struct mtd_info *m
+@@ -231,13 +233,61 @@ static int part_erase(struct mtd_info *m
        struct mtd_part *part = PART(mtd);
        int ret;
  
@@ -33,6 +33,7 @@
 +                              part->master->erasesize,
 +                              &readlen, instr->erase_buf);
 +
++                      instr->len += instr->erase_buf_ofs;
 +                      instr->partial_start = true;
 +              } else {
 +                      mtd_ofs = part->offset + part->mtd.size;
@@ -70,7 +71,7 @@
        return ret;
  }
  
-@@ -245,7 +294,25 @@ void mtd_erase_callback(struct erase_inf
+@@ -245,7 +295,25 @@ void mtd_erase_callback(struct erase_inf
  {
        if (instr->mtd->_erase == part_erase) {
                struct mtd_part *part = PART(instr->mtd);
@@ -96,7 +97,7 @@
                if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
                        instr->fail_addr -= part->offset;
                instr->addr -= part->offset;
-@@ -503,18 +570,24 @@ static struct mtd_part *allocate_partiti
+@@ -503,18 +571,24 @@ 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 */
index 7facf0db1520aafd773c12e6e3ddaccf20519ebc..8da080b2ade89e36f1da84e7be28d63a3c572d8d 100644 (file)
@@ -9,7 +9,7 @@
  /* Our partition linked list */
  static LIST_HEAD(mtd_partitions);
  static DEFINE_MUTEX(mtd_partitions_mutex);
-@@ -231,13 +233,60 @@ static int part_erase(struct mtd_info *m
+@@ -231,13 +233,61 @@ static int part_erase(struct mtd_info *m
        struct mtd_part *part = PART(mtd);
        int ret;
  
@@ -33,6 +33,7 @@
 +                              part->master->erasesize,
 +                              &readlen, instr->erase_buf);
 +
++                      instr->len += instr->erase_buf_ofs;
 +                      instr->partial_start = true;
 +              } else {
 +                      mtd_ofs = part->offset + part->mtd.size;
@@ -70,7 +71,7 @@
        return ret;
  }
  
-@@ -245,7 +294,25 @@ void mtd_erase_callback(struct erase_inf
+@@ -245,7 +295,25 @@ void mtd_erase_callback(struct erase_inf
  {
        if (instr->mtd->_erase == part_erase) {
                struct mtd_part *part = PART(instr->mtd);
@@ -96,7 +97,7 @@
                if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
                        instr->fail_addr -= part->offset;
                instr->addr -= part->offset;
-@@ -503,18 +570,24 @@ static struct mtd_part *allocate_partiti
+@@ -503,18 +571,24 @@ 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 */
index 3b22cfcb25997a02e1257d30abadb33b8e4b3327..f9c1c5ea6d9367d5c243f839372940dc197fd86e 100644 (file)
@@ -9,7 +9,7 @@
  /* Our partition linked list */
  static LIST_HEAD(mtd_partitions);
  static DEFINE_MUTEX(mtd_partitions_mutex);
-@@ -252,13 +254,60 @@ static int part_erase(struct mtd_info *m
+@@ -252,13 +254,61 @@ static int part_erase(struct mtd_info *m
                return -EROFS;
        if (instr->addr >= mtd->size)
                return -EINVAL;
@@ -33,6 +33,7 @@
 +                              part->master->erasesize,
 +                              &readlen, instr->erase_buf);
 +
++                      instr->len += instr->erase_buf_ofs;
 +                      instr->partial_start = true;
 +              } else {
 +                      mtd_ofs = part->offset + part->mtd.size;
@@ -70,7 +71,7 @@
        return ret;
  }
  
-@@ -266,7 +315,25 @@ void mtd_erase_callback(struct erase_inf
+@@ -266,7 +316,25 @@ void mtd_erase_callback(struct erase_inf
  {
        if (instr->mtd->erase == part_erase) {
                struct mtd_part *part = PART(instr->mtd);
@@ -96,7 +97,7 @@
                if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
                        instr->fail_addr -= part->offset;
                instr->addr -= part->offset;
-@@ -537,18 +604,24 @@ static struct mtd_part *allocate_partiti
+@@ -537,18 +605,24 @@ 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 */
index f2fa3676fbf552fe6ab00758bb872adf31ce3adf..f367e1e9f6f2030afb6d4d56daaa2449a79846ea 100644 (file)
@@ -9,7 +9,7 @@
  /* Our partition linked list */
  static LIST_HEAD(mtd_partitions);
  static DEFINE_MUTEX(mtd_partitions_mutex);
-@@ -230,13 +232,60 @@ static int part_erase(struct mtd_info *m
+@@ -230,13 +232,61 @@ static int part_erase(struct mtd_info *m
        struct mtd_part *part = PART(mtd);
        int ret;
  
@@ -33,6 +33,7 @@
 +                              part->master->erasesize,
 +                              &readlen, instr->erase_buf);
 +
++                      instr->len += instr->erase_buf_ofs;
 +                      instr->partial_start = true;
 +              } else {
 +                      mtd_ofs = part->offset + part->mtd.size;
@@ -70,7 +71,7 @@
        return ret;
  }
  
-@@ -244,7 +293,25 @@ void mtd_erase_callback(struct erase_inf
+@@ -244,7 +294,25 @@ void mtd_erase_callback(struct erase_inf
  {
        if (instr->mtd->_erase == part_erase) {
                struct mtd_part *part = PART(instr->mtd);
@@ -96,7 +97,7 @@
                if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
                        instr->fail_addr -= part->offset;
                instr->addr -= part->offset;
-@@ -504,18 +571,24 @@ static struct mtd_part *allocate_partiti
+@@ -504,18 +572,24 @@ 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 */
index f2fa3676fbf552fe6ab00758bb872adf31ce3adf..f367e1e9f6f2030afb6d4d56daaa2449a79846ea 100644 (file)
@@ -9,7 +9,7 @@
  /* Our partition linked list */
  static LIST_HEAD(mtd_partitions);
  static DEFINE_MUTEX(mtd_partitions_mutex);
-@@ -230,13 +232,60 @@ static int part_erase(struct mtd_info *m
+@@ -230,13 +232,61 @@ static int part_erase(struct mtd_info *m
        struct mtd_part *part = PART(mtd);
        int ret;
  
@@ -33,6 +33,7 @@
 +                              part->master->erasesize,
 +                              &readlen, instr->erase_buf);
 +
++                      instr->len += instr->erase_buf_ofs;
 +                      instr->partial_start = true;
 +              } else {
 +                      mtd_ofs = part->offset + part->mtd.size;
@@ -70,7 +71,7 @@
        return ret;
  }
  
-@@ -244,7 +293,25 @@ void mtd_erase_callback(struct erase_inf
+@@ -244,7 +294,25 @@ void mtd_erase_callback(struct erase_inf
  {
        if (instr->mtd->_erase == part_erase) {
                struct mtd_part *part = PART(instr->mtd);
@@ -96,7 +97,7 @@
                if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
                        instr->fail_addr -= part->offset;
                instr->addr -= part->offset;
-@@ -504,18 +571,24 @@ static struct mtd_part *allocate_partiti
+@@ -504,18 +572,24 @@ 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 */
index f2fa3676fbf552fe6ab00758bb872adf31ce3adf..f367e1e9f6f2030afb6d4d56daaa2449a79846ea 100644 (file)
@@ -9,7 +9,7 @@
  /* Our partition linked list */
  static LIST_HEAD(mtd_partitions);
  static DEFINE_MUTEX(mtd_partitions_mutex);
-@@ -230,13 +232,60 @@ static int part_erase(struct mtd_info *m
+@@ -230,13 +232,61 @@ static int part_erase(struct mtd_info *m
        struct mtd_part *part = PART(mtd);
        int ret;
  
@@ -33,6 +33,7 @@
 +                              part->master->erasesize,
 +                              &readlen, instr->erase_buf);
 +
++                      instr->len += instr->erase_buf_ofs;
 +                      instr->partial_start = true;
 +              } else {
 +                      mtd_ofs = part->offset + part->mtd.size;
@@ -70,7 +71,7 @@
        return ret;
  }
  
-@@ -244,7 +293,25 @@ void mtd_erase_callback(struct erase_inf
+@@ -244,7 +294,25 @@ void mtd_erase_callback(struct erase_inf
  {
        if (instr->mtd->_erase == part_erase) {
                struct mtd_part *part = PART(instr->mtd);
@@ -96,7 +97,7 @@
                if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
                        instr->fail_addr -= part->offset;
                instr->addr -= part->offset;
-@@ -504,18 +571,24 @@ static struct mtd_part *allocate_partiti
+@@ -504,18 +572,24 @@ 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 */