]> www.infradead.org Git - mtd-utils.git/commitdiff
nandwrite: merge `mtd_write_oob' and `mtd_write' calls
authorBrian Norris <computersforpeace@gmail.com>
Wed, 31 Aug 2011 20:00:35 +0000 (13:00 -0700)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Sun, 11 Sep 2011 13:11:41 +0000 (16:11 +0300)
Now that `mtd_write' can write to both OOB and data regions, we need to
perform our `mtd_write' call only once.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
nandwrite.c

index 33a3b8fb345129a11420742c17d359e13b8ccf7b..a78b0b68c12d6198bba1da28cffe56b1c83b3c6b 100644 (file)
@@ -534,17 +534,17 @@ int main(int argc, char * const argv[])
                        } else {
                                memcpy(oobbuf, oobreadbuf, mtd.oob_size);
                        }
-                       /* Write OOB data first, as ecc will be placed in there */
-                       if (mtd_write_oob(mtd_desc, &mtd, fd, mtdoffset,
-                                               mtd.oob_size, oobbuf)) {
-                               sys_errmsg("%s: MTD writeoob failure", mtd_device);
-                               goto closeall;
-                       }
                }
 
-               /* Write out the Page data */
-               if (!onlyoob && mtd_write(mtd_desc, &mtd, fd, mtdoffset / mtd.eb_size, mtdoffset % mtd.eb_size,
-                                       writebuf, mtd.min_io_size, NULL, 0, 0)) {
+               /* Write out data */
+               ret = mtd_write(mtd_desc, &mtd, fd, mtdoffset / mtd.eb_size,
+                               mtdoffset % mtd.eb_size,
+                               onlyoob ? NULL : writebuf,
+                               onlyoob ? 0 : mtd.min_io_size,
+                               writeoob ? oobbuf : NULL,
+                               writeoob ? mtd.oob_size : 0,
+                               noecc ? MTD_OPS_RAW : MTD_OPS_PLACE_OOB);
+               if (ret) {
                        int i;
                        if (errno != EIO) {
                                sys_errmsg("%s: MTD write failure", mtd_device);