summaryrefslogtreecommitdiff
path: root/nand-utils
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2016-12-09 02:47:41 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2016-12-09 09:06:45 +0100
commitf5b47ef5112326b06fd875982379769c55a71703 (patch)
tree4380e15fc33cc96c28c298418b60fce140880fb0 /nand-utils
parentabbed09157dc42f11d54277ad895edaf357d92d8 (diff)
nandwrite: Factor out buffer checking code
Pull the buffer content checking code into separate function and simplify the code invoking it slightly. Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'nand-utils')
-rw-r--r--nand-utils/nandwrite.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/nand-utils/nandwrite.c b/nand-utils/nandwrite.c
index b376869..9602a6e 100644
--- a/nand-utils/nandwrite.c
+++ b/nand-utils/nandwrite.c
@@ -523,18 +523,8 @@ int main(int argc, char * const argv[])
}
}
- allffs = 0;
- if (skipallffs)
- {
- for (ii = 0; ii < mtd.min_io_size; ii += sizeof(uint32_t))
- {
- if (*(uint32_t*)(writebuf + ii) != 0xffffffff)
- break;
- }
- if (ii == mtd.min_io_size)
- allffs = 1;
- }
- if (!allffs) {
+ ret = 0;
+ if (!skipallffs || !buffer_check_pattern(writebuf, mtd.min_io_size, 0xff)) {
/* Write out data */
ret = mtd_write(mtd_desc, &mtd, fd, mtdoffset / mtd.eb_size,
mtdoffset % mtd.eb_size,
@@ -543,9 +533,8 @@ int main(int argc, char * const argv[])
writeoob ? oobbuf : NULL,
writeoob ? mtd.oob_size : 0,
write_mode);
- } else {
- ret = 0;
}
+
if (ret) {
long long i;
if (errno != EIO) {