[PATCH 2/3] nandwrite: replace erase loop with mtd_erase_multi
David Oberhollenzer
david.oberhollenzer at sigma-star.at
Thu Jan 12 02:28:27 PST 2017
Signed-off-by: David Oberhollenzer <david.oberhollenzer at sigma-star.at>
---
nand-utils/nandwrite.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/nand-utils/nandwrite.c b/nand-utils/nandwrite.c
index 998c68c..22c741d 100644
--- a/nand-utils/nandwrite.c
+++ b/nand-utils/nandwrite.c
@@ -540,7 +540,6 @@ int main(int argc, char * const argv[])
}
if (ret) {
- long long i;
if (errno != EIO) {
sys_errmsg("%s: MTD write failure", mtd_device);
goto closeall;
@@ -551,13 +550,13 @@ int main(int argc, char * const argv[])
fprintf(stderr, "Erasing failed write from %#08llx to %#08llx\n",
blockstart, blockstart + ebsize_aligned - 1);
- for (i = blockstart; i < blockstart + ebsize_aligned; i += mtd.eb_size) {
- if (mtd_erase(mtd_desc, &mtd, fd, i / mtd.eb_size)) {
- int errno_tmp = errno;
- sys_errmsg("%s: MTD Erase failure", mtd_device);
- if (errno_tmp != EIO)
- goto closeall;
- }
+
+ if (mtd_erase_multi(mtd_desc, &mtd, fd,
+ blockstart / mtd.eb_size, blockalign)) {
+ int errno_tmp = errno;
+ sys_errmsg("%s: MTD Erase failure", mtd_device);
+ if (errno_tmp != EIO)
+ goto closeall;
}
if (markbad) {
--
2.10.2
More information about the linux-mtd
mailing list