]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/mtd/onenand/onenand_base.c
Merge branch 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/roland/infiniband
[linux-2.6-omap-h63xx.git] / drivers / mtd / onenand / onenand_base.c
index fe5b48997275a34e5a4182a153367886c8437a81..84ec40d254386f366a3d4e2f92ad54cda2663eb9 100644 (file)
@@ -23,8 +23,7 @@
 /**
  * onenand_oob_64 - oob info for large (2KB) page
  */
-static struct nand_oobinfo onenand_oob_64 = {
-       .useecc         = MTD_NANDECC_AUTOPLACE,
+static struct nand_ecclayout onenand_oob_64 = {
        .eccbytes       = 20,
        .eccpos         = {
                8, 9, 10, 11, 12,
@@ -41,8 +40,7 @@ static struct nand_oobinfo onenand_oob_64 = {
 /**
  * onenand_oob_32 - oob info for middle (1KB) page
  */
-static struct nand_oobinfo onenand_oob_32 = {
-       .useecc         = MTD_NANDECC_AUTOPLACE,
+static struct nand_ecclayout onenand_oob_32 = {
        .eccbytes       = 10,
        .eccpos         = {
                8, 9, 10, 11, 12,
@@ -354,7 +352,7 @@ static inline int onenand_bufferram_offset(struct mtd_info *mtd, int area)
 
        if (ONENAND_CURRENT_BUFFERRAM(this)) {
                if (area == ONENAND_DATARAM)
-                       return mtd->oobblock;
+                       return mtd->writesize;
                if (area == ONENAND_SPARERAM)
                        return mtd->oobsize;
        }
@@ -597,31 +595,28 @@ static void onenand_release_device(struct mtd_info *mtd)
 }
 
 /**
- * onenand_read_ecc - [MTD Interface] Read data with ECC
+ * onenand_read - [MTD Interface] Read data from flash
  * @param mtd          MTD device structure
  * @param from         offset to read from
  * @param len          number of bytes to read
  * @param retlen       pointer to variable to store the number of read bytes
  * @param buf          the databuffer to put data
- * @param oob_buf      filesystem supplied oob data buffer
- * @param oobsel       oob selection structure
  *
- * OneNAND read with ECC
- */
-static int onenand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
-       size_t *retlen, u_char *buf,
-       u_char *oob_buf, struct nand_oobinfo *oobsel)
+ * Read with ecc
+*/
+static int onenand_read(struct mtd_info *mtd, loff_t from, size_t len,
+       size_t *retlen, u_char *buf)
 {
        struct onenand_chip *this = mtd->priv;
        int read = 0, column;
        int thislen;
        int ret = 0;
 
-       DEBUG(MTD_DEBUG_LEVEL3, "onenand_read_ecc: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
+       DEBUG(MTD_DEBUG_LEVEL3, "onenand_read: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
 
        /* Do not allow reads past end of device */
        if ((from + len) > mtd->size) {
-               DEBUG(MTD_DEBUG_LEVEL0, "onenand_read_ecc: Attempt read beyond end of device\n");
+               DEBUG(MTD_DEBUG_LEVEL0, "onenand_read: Attempt read beyond end of device\n");
                *retlen = 0;
                return -EINVAL;
        }
@@ -632,14 +627,14 @@ static int onenand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
        /* TODO handling oob */
 
        while (read < len) {
-               thislen = min_t(int, mtd->oobblock, len - read);
+               thislen = min_t(int, mtd->writesize, len - read);
 
-               column = from & (mtd->oobblock - 1);
-               if (column + thislen > mtd->oobblock)
-                       thislen = mtd->oobblock - column;
+               column = from & (mtd->writesize - 1);
+               if (column + thislen > mtd->writesize)
+                       thislen = mtd->writesize - column;
 
                if (!onenand_check_bufferram(mtd, from)) {
-                       this->command(mtd, ONENAND_CMD_READ, from, mtd->oobblock);
+                       this->command(mtd, ONENAND_CMD_READ, from, mtd->writesize);
 
                        ret = this->wait(mtd, FL_READING);
                        /* First copy data and check return value for ECC handling */
@@ -654,7 +649,7 @@ static int onenand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
                        break;
 
                if (ret) {
-                       DEBUG(MTD_DEBUG_LEVEL0, "onenand_read_ecc: read failed = %d\n", ret);
+                       DEBUG(MTD_DEBUG_LEVEL0, "onenand_read: read failed = %d\n", ret);
                        goto out;
                }
 
@@ -676,23 +671,7 @@ out:
 }
 
 /**
- * onenand_read - [MTD Interface] MTD compability function for onenand_read_ecc
- * @param mtd          MTD device structure
- * @param from         offset to read from
- * @param len          number of bytes to read
- * @param retlen       pointer to variable to store the number of read bytes
- * @param buf          the databuffer to put data
- *
- * This function simply calls onenand_read_ecc with oob buffer and oobsel = NULL
-*/
-static int onenand_read(struct mtd_info *mtd, loff_t from, size_t len,
-       size_t *retlen, u_char *buf)
-{
-       return onenand_read_ecc(mtd, from, len, retlen, buf, NULL, NULL);
-}
-
-/**
- * onenand_read_oob - [MTD Interface] OneNAND read out-of-band
+ * onenand_do_read_oob - [MTD Interface] OneNAND read out-of-band
  * @param mtd          MTD device structure
  * @param from         offset to read from
  * @param len          number of bytes to read
@@ -701,8 +680,8 @@ static int onenand_read(struct mtd_info *mtd, loff_t from, size_t len,
  *
  * OneNAND read out-of-band data from the spare area
  */
-static int onenand_read_oob(struct mtd_info *mtd, loff_t from, size_t len,
-       size_t *retlen, u_char *buf)
+int onenand_do_read_oob(struct mtd_info *mtd, loff_t from, size_t len,
+                       size_t *retlen, u_char *buf)
 {
        struct onenand_chip *this = mtd->priv;
        int read = 0, thislen, column;
@@ -752,7 +731,7 @@ static int onenand_read_oob(struct mtd_info *mtd, loff_t from, size_t len,
                /* Read more? */
                if (read < len) {
                        /* Page size */
-                       from += mtd->oobblock;
+                       from += mtd->writesize;
                        column = 0;
                }
        }
@@ -765,6 +744,21 @@ out:
        return ret;
 }
 
+/**
+ * onenand_read_oob - [MTD Interface] NAND write data and/or out-of-band
+ * @mtd:       MTD device structure
+ * @from:      offset to read from
+ * @ops:       oob operation description structure
+ */
+static int onenand_read_oob(struct mtd_info *mtd, loff_t from,
+                           struct mtd_oob_ops *ops)
+{
+       BUG_ON(ops->mode != MTD_OOB_PLACE);
+
+       return onenand_do_read_oob(mtd, from + ops->ooboffs, ops->len,
+                                  &ops->retlen, ops->oobbuf);
+}
+
 #ifdef CONFIG_MTD_ONENAND_VERIFY_WRITE
 /**
  * onenand_verify_oob - [GENERIC] verify the oob contents after a write
@@ -809,7 +803,7 @@ static int onenand_verify_page(struct mtd_info *mtd, u_char *buf, loff_t addr)
        void __iomem *dataram0, *dataram1;
        int ret = 0;
 
-       this->command(mtd, ONENAND_CMD_READ, addr, mtd->oobblock);
+       this->command(mtd, ONENAND_CMD_READ, addr, mtd->writesize);
 
        ret = this->wait(mtd, FL_READING);
        if (ret)
@@ -819,9 +813,9 @@ static int onenand_verify_page(struct mtd_info *mtd, u_char *buf, loff_t addr)
 
        /* Check, if the two dataram areas are same */
        dataram0 = this->base + ONENAND_DATARAM;
-       dataram1 = dataram0 + mtd->oobblock;
+       dataram1 = dataram0 + mtd->writesize;
 
-       if (memcmp(dataram0, dataram1, mtd->oobblock))
+       if (memcmp(dataram0, dataram1, mtd->writesize))
                return -EBADMSG;
 
        return 0;
@@ -831,42 +825,39 @@ static int onenand_verify_page(struct mtd_info *mtd, u_char *buf, loff_t addr)
 #define onenand_verify_oob(...)                (0)
 #endif
 
-#define NOTALIGNED(x)  ((x & (mtd->oobblock - 1)) != 0)
+#define NOTALIGNED(x)  ((x & (mtd->writesize - 1)) != 0)
 
 /**
- * onenand_write_ecc - [MTD Interface] OneNAND write with ECC
+ * onenand_write - [MTD Interface] write buffer to FLASH
  * @param mtd          MTD device structure
  * @param to           offset to write to
  * @param len          number of bytes to write
  * @param retlen       pointer to variable to store the number of written bytes
  * @param buf          the data to write
- * @param eccbuf       filesystem supplied oob data buffer
- * @param oobsel       oob selection structure
  *
- * OneNAND write with ECC
+ * Write with ECC
  */
-static int onenand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
-       size_t *retlen, const u_char *buf,
-       u_char *eccbuf, struct nand_oobinfo *oobsel)
+static int onenand_write(struct mtd_info *mtd, loff_t to, size_t len,
+       size_t *retlen, const u_char *buf)
 {
        struct onenand_chip *this = mtd->priv;
        int written = 0;
        int ret = 0;
 
-       DEBUG(MTD_DEBUG_LEVEL3, "onenand_write_ecc: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len);
+       DEBUG(MTD_DEBUG_LEVEL3, "onenand_write: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len);
 
        /* Initialize retlen, in case of early exit */
        *retlen = 0;
 
        /* Do not allow writes past end of device */
        if (unlikely((to + len) > mtd->size)) {
-               DEBUG(MTD_DEBUG_LEVEL0, "onenand_write_ecc: Attempt write to past end of device\n");
+               DEBUG(MTD_DEBUG_LEVEL0, "onenand_write: Attempt write to past end of device\n");
                return -EINVAL;
        }
 
        /* Reject writes, which are not page aligned */
         if (unlikely(NOTALIGNED(to)) || unlikely(NOTALIGNED(len))) {
-                DEBUG(MTD_DEBUG_LEVEL0, "onenand_write_ecc: Attempt to write not page aligned data\n");
+                DEBUG(MTD_DEBUG_LEVEL0, "onenand_write: Attempt to write not page aligned data\n");
                 return -EINVAL;
         }
 
@@ -875,20 +866,20 @@ static int onenand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
 
        /* Loop until all data write */
        while (written < len) {
-               int thislen = min_t(int, mtd->oobblock, len - written);
+               int thislen = min_t(int, mtd->writesize, len - written);
 
-               this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->oobblock);
+               this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->writesize);
 
                this->write_bufferram(mtd, ONENAND_DATARAM, buf, 0, thislen);
                this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize);
 
-               this->command(mtd, ONENAND_CMD_PROG, to, mtd->oobblock);
+               this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize);
 
                onenand_update_bufferram(mtd, to, 1);
 
                ret = this->wait(mtd, FL_WRITING);
                if (ret) {
-                       DEBUG(MTD_DEBUG_LEVEL0, "onenand_write_ecc: write filaed %d\n", ret);
+                       DEBUG(MTD_DEBUG_LEVEL0, "onenand_write: write filaed %d\n", ret);
                        goto out;
                }
 
@@ -897,7 +888,7 @@ static int onenand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
                /* Only check verify write turn on */
                ret = onenand_verify_page(mtd, (u_char *) buf, to);
                if (ret) {
-                       DEBUG(MTD_DEBUG_LEVEL0, "onenand_write_ecc: verify failed %d\n", ret);
+                       DEBUG(MTD_DEBUG_LEVEL0, "onenand_write: verify failed %d\n", ret);
                        goto out;
                }
 
@@ -918,24 +909,7 @@ out:
 }
 
 /**
- * onenand_write - [MTD Interface] compability function for onenand_write_ecc
- * @param mtd          MTD device structure
- * @param to           offset to write to
- * @param len          number of bytes to write
- * @param retlen       pointer to variable to store the number of written bytes
- * @param buf          the data to write
- *
- * This function simply calls onenand_write_ecc
- * with oob buffer and oobsel = NULL
- */
-static int onenand_write(struct mtd_info *mtd, loff_t to, size_t len,
-       size_t *retlen, const u_char *buf)
-{
-       return onenand_write_ecc(mtd, to, len, retlen, buf, NULL, NULL);
-}
-
-/**
- * onenand_write_oob - [MTD Interface] OneNAND write out-of-band
+ * onenand_do_write_oob - [Internal] OneNAND write out-of-band
  * @param mtd          MTD device structure
  * @param to           offset to write to
  * @param len          number of bytes to write
@@ -944,8 +918,8 @@ static int onenand_write(struct mtd_info *mtd, loff_t to, size_t len,
  *
  * OneNAND write out-of-band
  */
-static int onenand_write_oob(struct mtd_info *mtd, loff_t to, size_t len,
-       size_t *retlen, const u_char *buf)
+static int onenand_do_write_oob(struct mtd_info *mtd, loff_t to, size_t len,
+                               size_t *retlen, const u_char *buf)
 {
        struct onenand_chip *this = mtd->priv;
        int column, ret = 0;
@@ -1014,141 +988,18 @@ out:
 }
 
 /**
- * onenand_writev_ecc - [MTD Interface] write with iovec with ecc
- * @param mtd          MTD device structure
- * @param vecs         the iovectors to write
- * @param count                number of vectors
- * @param to           offset to write to
- * @param retlen       pointer to variable to store the number of written bytes
- * @param eccbuf       filesystem supplied oob data buffer
- * @param oobsel       oob selection structure
- *
- * OneNAND write with iovec with ecc
+ * onenand_write_oob - [MTD Interface] NAND write data and/or out-of-band
+ * @mtd:       MTD device structure
+ * @from:      offset to read from
+ * @ops:       oob operation description structure
  */
-static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
-       unsigned long count, loff_t to, size_t *retlen,
-       u_char *eccbuf, struct nand_oobinfo *oobsel)
+static int onenand_write_oob(struct mtd_info *mtd, loff_t to,
+                            struct mtd_oob_ops *ops)
 {
-       struct onenand_chip *this = mtd->priv;
-       unsigned char *pbuf;
-       size_t total_len, len;
-       int i, written = 0;
-       int ret = 0;
-
-       /* Preset written len for early exit */
-       *retlen = 0;
+       BUG_ON(ops->mode != MTD_OOB_PLACE);
 
-       /* Calculate total length of data */
-       total_len = 0;
-       for (i = 0; i < count; i++)
-               total_len += vecs[i].iov_len;
-
-       DEBUG(MTD_DEBUG_LEVEL3, "onenand_writev_ecc: to = 0x%08x, len = %i, count = %ld\n", (unsigned int) to, (unsigned int) total_len, count);
-
-       /* Do not allow write past end of the device */
-       if (unlikely((to + total_len) > mtd->size)) {
-               DEBUG(MTD_DEBUG_LEVEL0, "onenand_writev_ecc: Attempted write past end of device\n");
-               return -EINVAL;
-       }
-
-       /* Reject writes, which are not page aligned */
-        if (unlikely(NOTALIGNED(to)) || unlikely(NOTALIGNED(total_len))) {
-                DEBUG(MTD_DEBUG_LEVEL0, "onenand_writev_ecc: Attempt to write not page aligned data\n");
-                return -EINVAL;
-        }
-
-       /* Grab the lock and see if the device is available */
-       onenand_get_device(mtd, FL_WRITING);
-
-       /* TODO handling oob */
-
-       /* Loop until all keve's data has been written */
-       len = 0;
-       while (count) {
-               pbuf = this->page_buf;
-               /*
-                * If the given tuple is >= pagesize then
-                * write it out from the iov
-                */
-               if ((vecs->iov_len - len) >= mtd->oobblock) {
-                       pbuf = vecs->iov_base + len;
-
-                       len += mtd->oobblock;
-
-                       /* Check, if we have to switch to the next tuple */
-                       if (len >= (int) vecs->iov_len) {
-                               vecs++;
-                               len = 0;
-                               count--;
-                       }
-               } else {
-                       int cnt = 0, thislen;
-                       while (cnt < mtd->oobblock) {
-                               thislen = min_t(int, mtd->oobblock - cnt, vecs->iov_len - len);
-                               memcpy(this->page_buf + cnt, vecs->iov_base + len, thislen);
-                               cnt += thislen;
-                               len += thislen;
-
-                               /* Check, if we have to switch to the next tuple */
-                               if (len >= (int) vecs->iov_len) {
-                                       vecs++;
-                                       len = 0;
-                                       count--;
-                               }
-                       }
-               }
-
-               this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->oobblock);
-
-               this->write_bufferram(mtd, ONENAND_DATARAM, pbuf, 0, mtd->oobblock);
-               this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize);
-
-               this->command(mtd, ONENAND_CMD_PROG, to, mtd->oobblock);
-
-               onenand_update_bufferram(mtd, to, 1);
-
-               ret = this->wait(mtd, FL_WRITING);
-               if (ret) {
-                       DEBUG(MTD_DEBUG_LEVEL0, "onenand_writev_ecc: write failed %d\n", ret);
-                       goto out;
-               }
-
-
-               /* Only check verify write turn on */
-               ret = onenand_verify_page(mtd, (u_char *) pbuf, to);
-               if (ret) {
-                       DEBUG(MTD_DEBUG_LEVEL0, "onenand_writev_ecc: verify failed %d\n", ret);
-                       goto out;
-               }
-
-               written += mtd->oobblock;
-
-               to += mtd->oobblock;
-       }
-
-out:
-       /* Deselect and wakt up anyone waiting on the device */
-       onenand_release_device(mtd);
-
-       *retlen = written;
-
-       return 0;
-}
-
-/**
- * onenand_writev - [MTD Interface] compabilty function for onenand_writev_ecc
- * @param mtd          MTD device structure
- * @param vecs         the iovectors to write
- * @param count                number of vectors
- * @param to           offset to write to
- * @param retlen       pointer to variable to store the number of written bytes
- *
- * OneNAND write with kvec. This just calls the ecc function
- */
-static int onenand_writev(struct mtd_info *mtd, const struct kvec *vecs,
-       unsigned long count, loff_t to, size_t *retlen)
-{
-       return onenand_writev_ecc(mtd, vecs, count, to, retlen, NULL, NULL);
+       return onenand_do_write_oob(mtd, to + ops->ooboffs, ops->len,
+                                   &ops->retlen, ops->oobbuf);
 }
 
 /**
@@ -1317,7 +1168,7 @@ static int onenand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
 
         /* We write two bytes, so we dont have to mess with 16 bit access */
         ofs += mtd->oobsize + (bbm->badblockpos & ~0x01);
-        return mtd->write_oob(mtd, ofs , 2, &retlen, buf);
+        return onenand_do_write_oob(mtd, ofs , 2, &retlen, buf);
 }
 
 /**
@@ -1467,11 +1318,11 @@ static int do_otp_write(struct mtd_info *mtd, loff_t from, size_t len,
        int ret;
 
        /* Force buffer page aligned */
-       if (len < mtd->oobblock) {
+       if (len < mtd->writesize) {
                memcpy(this->page_buf, buf, len);
-               memset(this->page_buf + len, 0xff, mtd->oobblock - len);
+               memset(this->page_buf + len, 0xff, mtd->writesize - len);
                pbuf = this->page_buf;
-               len = mtd->oobblock;
+               len = mtd->writesize;
        }
 
        /* Enter OTP access mode */
@@ -1507,7 +1358,7 @@ static int do_otp_lock(struct mtd_info *mtd, loff_t from, size_t len,
        this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0);
        this->wait(mtd, FL_OTPING);
 
-       ret = mtd->write_oob(mtd, from, len, retlen, buf);
+       ret = onenand_do_write_oob(mtd, from, len, retlen, buf);
 
        /* Exit OTP access mode */
        this->command(mtd, ONENAND_CMD_RESET, 0, 0);
@@ -1546,12 +1397,12 @@ static int onenand_otp_walk(struct mtd_info *mtd, loff_t from, size_t len,
                otp_pages = 10;
 
        if (mode == MTD_OTP_FACTORY) {
-               from += mtd->oobblock * otp_pages;
+               from += mtd->writesize * otp_pages;
                otp_pages = 64 - otp_pages;
        }
 
        /* Check User/Factory boundary */
-       if (((mtd->oobblock * otp_pages) - (from + len)) < 0)
+       if (((mtd->writesize * otp_pages) - (from + len)) < 0)
                return 0;
 
        while (len > 0 && otp_pages > 0) {
@@ -1564,10 +1415,10 @@ static int onenand_otp_walk(struct mtd_info *mtd, loff_t from, size_t len,
 
                        otpinfo = (struct otp_info *) buf;
                        otpinfo->start = from;
-                       otpinfo->length = mtd->oobblock;
+                       otpinfo->length = mtd->writesize;
                        otpinfo->locked = 0;
 
-                       from += mtd->oobblock;
+                       from += mtd->writesize;
                        buf += sizeof(struct otp_info);
                        *retlen += sizeof(struct otp_info);
                } else {
@@ -1811,15 +1662,15 @@ static int onenand_probe(struct mtd_info *mtd)
 
        /* OneNAND page size & block size */
        /* The data buffer size is equal to page size */
-       mtd->oobblock = this->read_word(this->base + ONENAND_REG_DATA_BUFFER_SIZE);
-       mtd->oobsize = mtd->oobblock >> 5;
+       mtd->writesize = this->read_word(this->base + ONENAND_REG_DATA_BUFFER_SIZE);
+       mtd->oobsize = mtd->writesize >> 5;
        /* Pagers per block is always 64 in OneNAND */
-       mtd->erasesize = mtd->oobblock << 6;
+       mtd->erasesize = mtd->writesize << 6;
 
        this->erase_shift = ffs(mtd->erasesize) - 1;
-       this->page_shift = ffs(mtd->oobblock) - 1;
+       this->page_shift = ffs(mtd->writesize) - 1;
        this->ppb_shift = (this->erase_shift - this->page_shift);
-       this->page_mask = (mtd->erasesize / mtd->oobblock) - 1;
+       this->page_mask = (mtd->erasesize / mtd->writesize) - 1;
 
        /* REVIST: Multichip handling */
 
@@ -1909,7 +1760,7 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
        /* Allocate buffers, if necessary */
        if (!this->page_buf) {
                size_t len;
-               len = mtd->oobblock + mtd->oobsize;
+               len = mtd->writesize + mtd->oobsize;
                this->page_buf = kmalloc(len, GFP_KERNEL);
                if (!this->page_buf) {
                        printk(KERN_ERR "onenand_scan(): Can't allocate page_buf\n");
@@ -1924,34 +1775,32 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
 
        switch (mtd->oobsize) {
        case 64:
-               this->autooob = &onenand_oob_64;
+               this->ecclayout = &onenand_oob_64;
                break;
 
        case 32:
-               this->autooob = &onenand_oob_32;
+               this->ecclayout = &onenand_oob_32;
                break;
 
        default:
                printk(KERN_WARNING "No OOB scheme defined for oobsize %d\n",
                        mtd->oobsize);
                /* To prevent kernel oops */
-               this->autooob = &onenand_oob_32;
+               this->ecclayout = &onenand_oob_32;
                break;
        }
 
-       memcpy(&mtd->oobinfo, this->autooob, sizeof(mtd->oobinfo));
+       mtd->ecclayout = this->ecclayout;
 
        /* Fill in remaining MTD driver data */
        mtd->type = MTD_NANDFLASH;
-       mtd->flags = MTD_CAP_NANDFLASH | MTD_ECC;
+       mtd->flags = MTD_CAP_NANDFLASH;
        mtd->ecctype = MTD_ECC_SW;
        mtd->erase = onenand_erase;
        mtd->point = NULL;
        mtd->unpoint = NULL;
        mtd->read = onenand_read;
        mtd->write = onenand_write;
-       mtd->read_ecc = onenand_read_ecc;
-       mtd->write_ecc = onenand_write_ecc;
        mtd->read_oob = onenand_read_oob;
        mtd->write_oob = onenand_write_oob;
 #ifdef CONFIG_MTD_ONENAND_OTP
@@ -1962,10 +1811,6 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
        mtd->write_user_prot_reg = onenand_write_user_prot_reg;
        mtd->lock_user_prot_reg = onenand_lock_user_prot_reg;
 #endif
-       mtd->readv = NULL;
-       mtd->readv_ecc = NULL;
-       mtd->writev = onenand_writev;
-       mtd->writev_ecc = onenand_writev_ecc;
        mtd->sync = onenand_sync;
        mtd->lock = NULL;
        mtd->unlock = onenand_unlock;