kernel: update kernel 3.18 to version 3.18.23
[openwrt/staging/chunkeey.git] / target / linux / generic / patches-3.18 / 412-mtd-partial_eraseblock_unlock.patch
1 --- a/drivers/mtd/mtdpart.c
2 +++ b/drivers/mtd/mtdpart.c
3 @@ -335,7 +335,14 @@ 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 = PART(mtd);
7 - return part->master->_unlock(part->master, ofs + part->offset, len);
8 +
9 + ofs += part->offset;
10 + if (mtd->flags & MTD_ERASE_PARTIAL) {
11 + /* round up len to next erasesize and round down offset to prev block */
12 + len = (mtd_div_by_eb(len, part->master) + 1) * part->master->erasesize;
13 + ofs &= ~(part->master->erasesize - 1);
14 + }
15 + return part->master->_unlock(part->master, ofs, len);
16 }
17
18 static int part_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)