2
0

412-mtd-partial_eraseblock_unlock.patch 699 B

123456789101112131415161718
  1. --- a/drivers/mtd/mtdpart.c
  2. +++ b/drivers/mtd/mtdpart.c
  3. @@ -337,7 +337,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. static int part_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)