xen: Port Xen grant table driver from mini-os
[platform/kernel/u-boot.git] / drivers / dfu / dfu_nand.c
index 6dc9ff7..b8d24d2 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * dfu_nand.c -- DFU for NAND routines.
  *
@@ -6,11 +7,10 @@
  * Based on dfu_mmc.c which is:
  * Copyright (C) 2012 Samsung Electronics
  * author: Lukasz Majewski <l.majewski@samsung.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
+#include <log.h>
 #include <malloc.h>
 #include <errno.h>
 #include <div64.h>
@@ -51,6 +51,7 @@ static int nand_block_op(enum dfu_op op, struct dfu_entity *dfu,
                                         lim, buf);
        } else {
                nand_erase_options_t opts;
+               int write_flags = WITH_WR_VERIFY;
 
                memset(&opts, 0, sizeof(opts));
                opts.offset = start;
@@ -63,8 +64,12 @@ static int nand_block_op(enum dfu_op op, struct dfu_entity *dfu,
                if (ret)
                        return ret;
                /* then write */
+#ifdef CONFIG_DFU_NAND_TRIMFFS
+               if (dfu->data.nand.ubi)
+                       write_flags |= WITH_DROP_FFS;
+#endif
                ret = nand_write_skip_bad(mtd, start, &count, &actual,
-                                         lim, buf, WITH_WR_VERIFY);
+                                         lim, buf, write_flags);
        }
 
        if (ret != 0) {
@@ -215,7 +220,7 @@ int dfu_fill_entity_nand(struct dfu_entity *dfu, char *devstr, char *s)
                part = simple_strtoul(s, &s, 10);
 
                sprintf(mtd_id, "%s%d,%d", "nand", dev, part - 1);
-               printf("using id '%s'\n", mtd_id);
+               debug("using id '%s'\n", mtd_id);
 
                mtdparts_init();