diff options
-rw-r--r-- | nanddump.c | 16 | ||||
-rw-r--r-- | nandwrite.c | 14 |
2 files changed, 15 insertions, 15 deletions
@@ -171,7 +171,7 @@ int main(int argc, char **argv) { unsigned long ofs, end_addr = 0; unsigned long long blockstart = 1; - int i, fd, ofd, bs, badblock = 0; + int ret, i, fd, ofd, bs, badblock = 0; struct mtd_oob_buf oob = {0, 16, oobbuf}; mtd_info_t meminfo; char pretty_buf[80]; @@ -208,9 +208,12 @@ int main(int argc, char **argv) oob.length = meminfo.oobsize; if (noecc) { - switch (ioctl(fd, MTDFILEMODE, (void *) MTD_MODE_RAW)) { - - case -ENOTTY: + ret = ioctl(fd, MTDFILEMODE, (void *) MTD_MODE_RAW); + if (ret == 0) { + oobinfochanged = 2; + } else { + switch (errno) { + case ENOTTY: if (ioctl (fd, MEMGETOOBSEL, &old_oobinfo) != 0) { perror ("MEMGETOOBSEL"); close (fd); @@ -223,14 +226,11 @@ int main(int argc, char **argv) } oobinfochanged = 1; break; - - case 0: - oobinfochanged = 2; - break; default: perror ("MTDFILEMODE"); close (fd); exit (1); + } } } else { diff --git a/nandwrite.c b/nandwrite.c index f4c399d..f74581d 100644 --- a/nandwrite.c +++ b/nandwrite.c @@ -271,9 +271,12 @@ int main(int argc, char **argv) } if (noecc) { - switch (ioctl(fd, MTDFILEMODE, (void *) MTD_MODE_RAW)) { - - case -ENOTTY: + ret = ioctl(fd, MTDFILEMODE, (void *) MTD_MODE_RAW); + if (ret == 0) { + oobinfochanged = 2; + } else { + switch (errno) { + case ENOTTY: if (ioctl (fd, MEMGETOOBSEL, &old_oobinfo) != 0) { perror ("MEMGETOOBSEL"); close (fd); @@ -286,14 +289,11 @@ int main(int argc, char **argv) } oobinfochanged = 1; break; - - case 0: - oobinfochanged = 2; - break; default: perror ("MTDFILEMODE"); close (fd); exit (1); + } } } |