+ blockstart = mtdoffset & ~(meminfo.erasesize - 1);
+ if (blockstart != mtdoffset) {
+ unsigned tmp;
+ /* mtdoffset is in the middle of an erase block, verify that
+ * this block is OK. Advance mtdoffset only if this block is
+ * bad.
+ */
+ tmp = next_good_eraseblock(fd, &meminfo, blockstart);
+ if (tmp != blockstart) /* bad block(s), advance mtdoffset */
+ mtdoffset = tmp;
+ }
+