ar71xx: keep the RouterBOARD Power LED in On state
[oweals/openwrt.git] / target / linux / generic / patches-4.9 / 412-mtd-partial_eraseblock_unlock.patch
1 --- a/drivers/mtd/mtdpart.c
2 +++ b/drivers/mtd/mtdpart.c
3 @@ -343,7 +343,16 @@ static int part_lock(struct mtd_info *mt
4  static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
5  {
6         struct mtd_part *part = mtd_to_part(mtd);
7 -       return part->parent->_unlock(part->parent, ofs + part->offset, len);
8 +
9 +       ofs += part->offset;
10 +
11 +       if (mtd->flags & MTD_ERASE_PARTIAL) {
12 +               /* round up len to next erasesize and round down offset to prev block */
13 +               len = (mtd_div_by_eb(len, part->parent) + 1) * part->parent->erasesize;
14 +               ofs &= ~(part->parent->erasesize - 1);
15 +       }
16 +
17 +       return part->parent->_unlock(part->parent, ofs, len);
18  }
19  
20  static int part_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)