Closed LarsML closed 4 years ago
For an mtd device that goes all the way to 0x200000
:
Error log before fix:
mtd: erasing @0:0x140000-0x160000
mtd: erasing @0:0x160000-0x180000
mtd: erasing @0:0x180000-0x1a0000
mtd: erasing @0:0x1a0000-0x1c0000
mtd: erasing @0:0x1c0000-0x1e0000
mtd: erasing @0:0x1e0000-0x200000
mtd: erase stepping bounds
mtd: Failed to erase block@0x1e0000
mtd: mtd_write_page failed
Failed to write safe page
Error log after fix:
mtd: erasing @0:0x140000-0x160000
mtd: erasing @0:0x160000-0x180000
mtd: erasing @0:0x180000-0x1a0000
mtd: erasing @0:0x1a0000-0x1c0000
mtd: erasing @0:0x1c0000-0x1e0000
mtd: erasing @0:0x1e0000-0x200000
mtd: We write one page for save guard. *
Thanks, will merge the patch.
In the event where the mtd_erase function also needs to erase the last block of an mtd device, the erasing goes well but the ofs check causes the function to fail even though the erasing of the block went well.
This commit ensures that checking whether ofs does not overrun the mtd size happens as early as possible, thus allowing the mtd_erase function to return properly when everything went right in erasing the last block of an mtd device.