Merge tag 'u-boot-imx-20211020' of https://source.denx.de/u-boot/custodians/u-boot-imx
[platform/kernel/u-boot.git] / drivers / mtd / cfi_mtd.c
index bbb71a1..78293ca 100644 (file)
@@ -1,33 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2008 Semihalf
  *
  * Written by: Piotr Ziecik <kosmo@semihalf.com>
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
  */
 
 #include <common.h>
+#include <dma.h>
 #include <flash.h>
 #include <malloc.h>
 
-#include <asm/errno.h>
+#include <linux/errno.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/concat.h>
 #include <mtd/cfi_flash.h>
@@ -88,7 +71,8 @@ static int cfi_mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
        flash_info_t *fi = mtd->priv;
        u_char *f = (u_char*)(fi->start[0]) + from;
 
-       memcpy(buf, f, len);
+       if (dma_memcpy(buf, f, len) < 0)
+               memcpy(buf, f, len);
        *retlen = len;
 
        return 0;
@@ -243,6 +227,7 @@ int cfi_mtd_init(void)
                mtd->flags              = MTD_CAP_NORFLASH;
                mtd->size               = fi->size;
                mtd->writesize          = 1;
+               mtd->writebufsize       = mtd->writesize;
 
                mtd->_erase             = cfi_mtd_erase;
                mtd->_read              = cfi_mtd_read;