From f5b47ef5112326b06fd875982379769c55a71703 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Fri, 9 Dec 2016 02:47:41 +0100 Subject: 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 Reviewed-by: Boris Brezillon Signed-off-by: David Oberhollenzer --- nand-utils/nandwrite.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'nand-utils') 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) { -- cgit v1.2.3