]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
Merge branch 'master' of git://www.denx.de/git/u-boot-nand-flash
authorWolfgang Denk <wd@denx.de>
Wed, 9 Jul 2008 22:59:04 +0000 (00:59 +0200)
committerWolfgang Denk <wd@denx.de>
Wed, 9 Jul 2008 22:59:04 +0000 (00:59 +0200)
common/env_nand.c
cpu/arm926ejs/davinci/nand.c
drivers/mtd/nand/nand_base.c
drivers/mtd/nand/nand_bbt.c
drivers/mtd/onenand/onenand_base.c
drivers/mtd/onenand/onenand_bbt.c
include/linux/mtd/mtd.h
include/nand.h

index 3890b84948bf798c12838dda577e18c1ba4d98f9..104f0856af2a3af7254d06451c47bee4485e89df 100644 (file)
@@ -95,8 +95,8 @@ uchar env_get_char_spec (int index)
 /* this is called before nand_init()
  * so we can't read Nand to validate env data.
  * Mark it OK for now. env_relocate() in env_common.c
- * will call our relocate function which will does
- * the real validation.
+ * will call our relocate function which does the real
+ * validation.
  *
  * When using a NAND boot image (like sequoia_nand), the environment
  * can be embedded or attached to the U-Boot image in NAND flash. This way
@@ -246,7 +246,7 @@ int saveenv(void)
 
        puts ("Writing to Nand... ");
        total = CFG_ENV_SIZE;
-       if (writeenv(CFG_ENV_OFFSET, env_ptr)) {
+       if (writeenv(CFG_ENV_OFFSET, (u_char *) env_ptr)) {
                puts("FAILED!\n");
                return 1;
        }
@@ -349,7 +349,7 @@ void env_relocate_spec (void)
        int ret;
 
        total = CFG_ENV_SIZE;
-       ret = readenv(CFG_ENV_OFFSET, env_ptr);
+       ret = readenv(CFG_ENV_OFFSET, (u_char *) env_ptr);
        if (ret || total != CFG_ENV_SIZE)
                return use_default();
 
index ffc770fd1b9f7eb160f58cc5188587ead0c0a71a..36468e6c3a00920d95a9c0f08c2e75e7bf160d87 100644 (file)
@@ -240,7 +240,8 @@ static int nand_davinci_compare_ecc(u_int8_t *ecc_nand, u_int8_t *ecc_calc, u_in
                        return 0;
                case 1:
                        /* Uncorrectable error */
-                       DEBUG (MTD_DEBUG_LEVEL0, "ECC UNCORRECTED_ERROR 1\n");
+                       MTDDEBUG (MTD_DEBUG_LEVEL0,
+                                 "ECC UNCORRECTED_ERROR 1\n");
                        return(-1);
                case 12:
                        /* Correctable error */
@@ -256,7 +257,9 @@ static int nand_davinci_compare_ecc(u_int8_t *ecc_nand, u_int8_t *ecc_calc, u_in
 
                        find_bit = (ecc_bit[5] << 2) + (ecc_bit[3] << 1) + ecc_bit[1];
 
-                       DEBUG (MTD_DEBUG_LEVEL0, "Correcting single bit ECC error at offset: %d, bit: %d\n", find_byte, find_bit);
+                       MTDDEBUG (MTD_DEBUG_LEVEL0, "Correcting single bit ECC "
+                                 "error at offset: %d, bit: %d\n",
+                                 find_byte, find_bit);
 
                        page_data[find_byte] ^= (1 << find_bit);
 
@@ -266,7 +269,8 @@ static int nand_davinci_compare_ecc(u_int8_t *ecc_nand, u_int8_t *ecc_calc, u_in
                                if (ecc_calc[0] == 0 && ecc_calc[1] == 0 && ecc_calc[2] == 0)
                                        return(0);
                        }
-                       DEBUG (MTD_DEBUG_LEVEL0, "UNCORRECTED_ERROR default\n");
+                       MTDDEBUG (MTD_DEBUG_LEVEL0,
+                                 "UNCORRECTED_ERROR default\n");
                        return(-1);
        }
 }
index 740d3fcc3737e637c731daa93ca4e93fd737b8d3..6416d1529e9d1440d4f89042cc2502ff1006b36f 100644 (file)
@@ -962,7 +962,9 @@ static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int pa
                status = this->waitfunc (mtd, this, FL_WRITING);
                /* See if device thinks it succeeded */
                if (status & 0x01) {
-                       DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write, page 0x%08x, ", __FUNCTION__, page);
+                       MTDDEBUG (MTD_DEBUG_LEVEL0,
+                                 "%s: Failed write, page 0x%08x, ",
+                                 __FUNCTION__, page);
                        return -EIO;
                }
        } else {
@@ -1010,7 +1012,9 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int
                for (j = 0; j < eccsteps; j++) {
                        /* Loop through and verify the data */
                        if (this->verify_buf(mtd, &this->data_poi[datidx], mtd->eccsize)) {
-                               DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page);
+                               MTDDEBUG (MTD_DEBUG_LEVEL0, "%s: "
+                                         "Failed write verify, page 0x%08x ",
+                                         __FUNCTION__, page);
                                goto out;
                        }
                        datidx += mtd->eccsize;
@@ -1018,7 +1022,9 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int
                        if (!hweccbytes)
                                continue;
                        if (this->verify_buf(mtd, &this->oob_buf[oobofs], hweccbytes)) {
-                               DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page);
+                               MTDDEBUG (MTD_DEBUG_LEVEL0, "%s: "
+                                         "Failed write verify, page 0x%08x ",
+                                         __FUNCTION__, page);
                                goto out;
                        }
                        oobofs += hweccbytes;
@@ -1029,7 +1035,9 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int
                 */
                if (oobmode) {
                        if (this->verify_buf(mtd, &oob_buf[oobofs], mtd->oobsize - hweccbytes * eccsteps)) {
-                               DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page);
+                               MTDDEBUG (MTD_DEBUG_LEVEL0, "%s: "
+                                         "Failed write verify, page 0x%08x ",
+                                         __FUNCTION__, page);
                                goto out;
                        }
                } else {
@@ -1042,9 +1050,11 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int
                                for (i = 0; i < ecccnt; i++) {
                                        int idx = oobsel->eccpos[i];
                                        if (oobdata[idx] != oob_buf[oobofs + idx] ) {
-                                               DEBUG (MTD_DEBUG_LEVEL0,
+                                               MTDDEBUG (MTD_DEBUG_LEVEL0,
                                                "%s: Failed ECC write "
-                                               "verify, page 0x%08x, " "%6i bytes were succesful\n", __FUNCTION__, page, i);
+                                               "verify, page 0x%08x, "
+                                               "%6i bytes were succesful\n",
+                                               __FUNCTION__, page, i);
                                                goto out;
                                        }
                                }
@@ -1131,11 +1141,13 @@ static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
        int     oobreadlen;
 
 
-       DEBUG (MTD_DEBUG_LEVEL3, "nand_read_ecc: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
+       MTDDEBUG (MTD_DEBUG_LEVEL3, "nand_read_ecc: 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, "nand_read_ecc: Attempt read beyond end of device\n");
+               MTDDEBUG (MTD_DEBUG_LEVEL0,
+                         "nand_read_ecc: Attempt read beyond end of device\n");
                *retlen = 0;
                return -EINVAL;
        }
@@ -1252,7 +1264,7 @@ static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
                                         * generator for an error, reads back the syndrome and
                                         * does the error correction on the fly */
                                        if (this->correct_data(mtd, &data_poi[datidx], &oob_data[i], &ecc_code[i]) == -1) {
-                                               DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: "
+                                               MTDDEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: "
                                                        "Failed ECC read, page 0x%08x on chip %d\n", page, chipnr);
                                                ecc_failed++;
                                        }
@@ -1291,7 +1303,9 @@ static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
                        }
 
                        if (ecc_status == -1) {
-                               DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " "Failed ECC read, page 0x%08x\n", page);
+                               MTDDEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: "
+                                         "Failed ECC read, page 0x%08x\n",
+                                         page);
                                ecc_failed++;
                        }
                }
@@ -1388,7 +1402,8 @@ static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t
        struct nand_chip *this = mtd->priv;
        int     blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1;
 
-       DEBUG (MTD_DEBUG_LEVEL3, "nand_read_oob: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
+       MTDDEBUG (MTD_DEBUG_LEVEL3, "nand_read_oob: from = 0x%08x, len = %i\n",
+                 (unsigned int) from, (int) len);
 
        /* Shift to get page */
        page = (int)(from >> this->page_shift);
@@ -1402,7 +1417,8 @@ static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t
 
        /* Do not allow reads past end of device */
        if ((from + len) > mtd->size) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_read_oob: Attempt read beyond end of device\n");
+               MTDDEBUG (MTD_DEBUG_LEVEL0,
+                         "nand_read_oob: Attempt read beyond end of device\n");
                *retlen = 0;
                return -EINVAL;
        }
@@ -1488,7 +1504,8 @@ int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len,
 
        /* Do not allow reads past end of device */
        if ((from + len) > mtd->size) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_read_raw: Attempt read beyond end of device\n");
+               MTDDEBUG (MTD_DEBUG_LEVEL0,
+                         "nand_read_raw: Attempt read beyond end of device\n");
                return -EINVAL;
        }
 
@@ -1626,14 +1643,16 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
        u_char *oobbuf, *bufstart;
        int     ppblock = (1 << (this->phys_erase_shift - this->page_shift));
 
-       DEBUG (MTD_DEBUG_LEVEL3, "nand_write_ecc: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len);
+       MTDDEBUG (MTD_DEBUG_LEVEL3, "nand_write_ecc: to = 0x%08x, len = %i\n",
+                 (unsigned int) to, (int) len);
 
        /* Initialize retlen, in case of early exit */
        *retlen = 0;
 
        /* Do not allow write past end of device */
        if ((to + len) > mtd->size) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: Attempt to write past end of page\n");
+               MTDDEBUG (MTD_DEBUG_LEVEL0,
+                         "nand_write_ecc: Attempt to write past end of page\n");
                return -EINVAL;
        }
 
@@ -1695,7 +1714,8 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
                 */
                ret = nand_write_page (mtd, this, page, &oobbuf[oob], oobsel, (--numpages > 0));
                if (ret) {
-                       DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: write_page failed %d\n", ret);
+                       MTDDEBUG (MTD_DEBUG_LEVEL0,
+                                 "nand_write_ecc: write_page failed %d\n", ret);
                        goto out;
                }
                /* Next oob page */
@@ -1719,7 +1739,8 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
                                page - startpage,
                                oobbuf, oobsel, chipnr, (eccbuf != NULL));
                        if (ret) {
-                               DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret);
+                               MTDDEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: "
+                                         "verify_pages failed %d\n", ret);
                                goto out;
                        }
                        *retlen = written;
@@ -1752,7 +1773,8 @@ cmp:
        if (!ret)
                *retlen = written;
        else
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret);
+               MTDDEBUG (MTD_DEBUG_LEVEL0,
+                         "nand_write_ecc: verify_pages failed %d\n", ret);
 
 out:
        /* Deselect and wake up anyone waiting on the device */
@@ -1777,7 +1799,8 @@ static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t *
        int column, page, status, ret = -EIO, chipnr;
        struct nand_chip *this = mtd->priv;
 
-       DEBUG (MTD_DEBUG_LEVEL3, "nand_write_oob: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len);
+       MTDDEBUG (MTD_DEBUG_LEVEL3, "nand_write_oob: to = 0x%08x, len = %i\n",
+                 (unsigned int) to, (int) len);
 
        /* Shift to get page */
        page = (int) (to >> this->page_shift);
@@ -1791,7 +1814,8 @@ static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t *
 
        /* Do not allow write past end of page */
        if ((column + len) > mtd->oobsize) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: Attempt to write past end of page\n");
+               MTDDEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: "
+                         "Attempt to write past end of page\n");
                return -EINVAL;
        }
 
@@ -1821,8 +1845,9 @@ static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t *
                this->cmdfunc (mtd, NAND_CMD_SEQIN, mtd->oobblock, page & this->pagemask);
                if (!ffchars) {
                        if (!(ffchars = kmalloc (mtd->oobsize, GFP_KERNEL))) {
-                               DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: "
-                                          "No memory for padding array, need %d bytes", mtd->oobsize);
+                               MTDDEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: "
+                                         "No memory for padding array, "
+                                         "need %d bytes", mtd->oobsize);
                                ret = -ENOMEM;
                                goto out;
                        }
@@ -1847,7 +1872,8 @@ static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t *
 
        /* See if device thinks it succeeded */
        if (status & 0x01) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: " "Failed write, page 0x%08x\n", page);
+               MTDDEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: "
+                         "Failed write, page 0x%08x\n", page);
                ret = -EIO;
                goto out;
        }
@@ -1859,7 +1885,8 @@ static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t *
        this->cmdfunc (mtd, NAND_CMD_READOOB, column, page & this->pagemask);
 
        if (this->verify_buf(mtd, buf, len)) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: " "Failed write verify, page 0x%08x\n", page);
+               MTDDEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: "
+                         "Failed write verify, page 0x%08x\n", page);
                ret = -EIO;
                goto out;
        }
@@ -1919,12 +1946,14 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig
        for (i = 0; i < count; i++)
                total_len += (int) vecs[i].iov_len;
 
-       DEBUG (MTD_DEBUG_LEVEL3,
-              "nand_writev: to = 0x%08x, len = %i, count = %ld\n", (unsigned int) to, (unsigned int) total_len, count);
+       MTDDEBUG (MTD_DEBUG_LEVEL3,
+                 "nand_writev: to = 0x%08x, len = %i, count = %ld\n",
+                 (unsigned int) to, (unsigned int) total_len, count);
 
        /* Do not allow write past end of page */
        if ((to + total_len) > mtd->size) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_writev: Attempted write past end of device\n");
+               MTDDEBUG (MTD_DEBUG_LEVEL0,
+                         "nand_writev: Attempted write past end of device\n");
                return -EINVAL;
        }
 
@@ -2117,24 +2146,26 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb
        int page, len, status, pages_per_block, ret, chipnr;
        struct nand_chip *this = mtd->priv;
 
-       DEBUG (MTD_DEBUG_LEVEL3,
-              "nand_erase: start = 0x%08x, len = %i\n", (unsigned int) instr->addr, (unsigned int) instr->len);
+       MTDDEBUG (MTD_DEBUG_LEVEL3, "nand_erase: start = 0x%08x, len = %i\n",
+                 (unsigned int) instr->addr, (unsigned int) instr->len);
 
        /* Start address must align on block boundary */
        if (instr->addr & ((1 << this->phys_erase_shift) - 1)) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Unaligned address\n");
+               MTDDEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Unaligned address\n");
                return -EINVAL;
        }
 
        /* Length must align on block boundary */
        if (instr->len & ((1 << this->phys_erase_shift) - 1)) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Length not block aligned\n");
+               MTDDEBUG (MTD_DEBUG_LEVEL0,
+                         "nand_erase: Length not block aligned\n");
                return -EINVAL;
        }
 
        /* Do not allow erase past end of device */
        if ((instr->len + instr->addr) > mtd->size) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Erase past end of device\n");
+               MTDDEBUG (MTD_DEBUG_LEVEL0,
+                         "nand_erase: Erase past end of device\n");
                return -EINVAL;
        }
 
@@ -2156,7 +2187,8 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb
        /* Check the WP bit */
        /* Check, if it is write protected */
        if (nand_check_wp(mtd)) {
-               DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Device is write protected!!!\n");
+               MTDDEBUG (MTD_DEBUG_LEVEL0,
+                         "nand_erase: Device is write protected!!!\n");
                instr->state = MTD_ERASE_FAILED;
                goto erase_exit;
        }
@@ -2186,7 +2218,8 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb
 
                /* See if block erase succeeded */
                if (status & 0x01) {
-                       DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: " "Failed erase, page 0x%08x\n", page);
+                       MTDDEBUG (MTD_DEBUG_LEVEL0, "nand_erase: "
+                                 "Failed erase, page 0x%08x\n", page);
                        instr->state = MTD_ERASE_FAILED;
                        instr->fail_addr = (page << this->page_shift);
                        goto erase_exit;
@@ -2229,7 +2262,7 @@ static void nand_sync (struct mtd_info *mtd)
 {
        struct nand_chip *this = mtd->priv;
 
-       DEBUG (MTD_DEBUG_LEVEL3, "nand_sync: called\n");
+       MTDDEBUG (MTD_DEBUG_LEVEL3, "nand_sync: called\n");
 
        /* Grab the lock and see if the device is available */
        nand_get_device (this, mtd, FL_SYNCING);
index eff76d717ca3970f2c82c6fd12f34482a22a546e..a97743b45e80d08568d5f6f9406d35197049ef93 100644 (file)
@@ -1038,8 +1038,8 @@ int nand_isbad_bbt (struct mtd_info *mtd, loff_t offs, int allowbbt)
        block = (int) (offs >> (this->bbt_erase_shift - 1));
        res = (this->bbt[block >> 3] >> (block & 0x06)) & 0x03;
 
-       DEBUG (MTD_DEBUG_LEVEL2, "nand_isbad_bbt(): bbt info for offs 0x%08x: (block %d) 0x%02x\n",
-               (unsigned int)offs, res, block >> 1);
+       MTDDEBUG (MTD_DEBUG_LEVEL2, "nand_isbad_bbt(): bbt info for offs 0x%08x: "
+                 "(block %d) 0x%02x\n", (unsigned int)offs, res, block >> 1);
 
        switch ((int)res) {
        case 0x00:      return 0;
index d1b9f8f5464e0e380e96bb5eecf7ca3e1b9ccd00..d32e38255805ed423f972e0f5c2e793602e60570 100644 (file)
@@ -293,22 +293,22 @@ static int onenand_wait(struct mtd_info *mtd, int state)
        ctrl = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);
 
        if (ctrl & ONENAND_CTRL_ERROR) {
-               DEBUG(MTD_DEBUG_LEVEL0,
-                     "onenand_wait: controller error = 0x%04x\n", ctrl);
+               MTDDEBUG (MTD_DEBUG_LEVEL0,
+                         "onenand_wait: controller error = 0x%04x\n", ctrl);
                return -EAGAIN;
        }
 
        if (ctrl & ONENAND_CTRL_LOCK) {
-               DEBUG(MTD_DEBUG_LEVEL0,
-                     "onenand_wait: it's locked error = 0x%04x\n", ctrl);
+               MTDDEBUG (MTD_DEBUG_LEVEL0,
+                         "onenand_wait: it's locked error = 0x%04x\n", ctrl);
                return -EIO;
        }
 
        if (interrupt & ONENAND_INT_READ) {
                ecc = this->read_word(this->base + ONENAND_REG_ECC_STATUS);
                if (ecc & ONENAND_ECC_2BIT_ALL) {
-                       DEBUG(MTD_DEBUG_LEVEL0,
-                             "onenand_wait: ECC error = 0x%04x\n", ecc);
+                       MTDDEBUG (MTD_DEBUG_LEVEL0,
+                                 "onenand_wait: ECC error = 0x%04x\n", ecc);
                        return -EBADMSG;
                }
        }
@@ -524,13 +524,14 @@ static int onenand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
        int thislen;
        int ret = 0;
 
-       DEBUG(MTD_DEBUG_LEVEL3, "onenand_read_ecc: from = 0x%08x, len = %i\n",
-             (unsigned int)from, (int)len);
+       MTDDEBUG (MTD_DEBUG_LEVEL3, "onenand_read_ecc: "
+                 "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");
+               MTDDEBUG (MTD_DEBUG_LEVEL0, "onenand_read_ecc: "
+                         "Attempt read beyond end of device\n");
                *retlen = 0;
                return -EINVAL;
        }
@@ -561,8 +562,8 @@ 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);
+                       MTDDEBUG (MTD_DEBUG_LEVEL0,
+                                 "onenand_read_ecc: read failed = %d\n", ret);
                        break;
                }
 
@@ -615,16 +616,17 @@ int onenand_read_oob(struct mtd_info *mtd, loff_t from, size_t len,
        int read = 0, thislen, column;
        int ret = 0;
 
-       DEBUG(MTD_DEBUG_LEVEL3, "onenand_read_oob: from = 0x%08x, len = %i\n",
-             (unsigned int)from, (int)len);
+       MTDDEBUG (MTD_DEBUG_LEVEL3, "onenand_read_oob: "
+                 "from = 0x%08x, len = %i\n",
+                 (unsigned int)from, (int)len);
 
        /* Initialize return length value */
        *retlen = 0;
 
        /* Do not allow reads past end of device */
        if (unlikely((from + len) > mtd->size)) {
-               DEBUG(MTD_DEBUG_LEVEL0,
-                     "onenand_read_oob: Attempt read beyond end of device\n");
+               MTDDEBUG (MTD_DEBUG_LEVEL0, "onenand_read_oob: "
+                         "Attempt read beyond end of device\n");
                return -EINVAL;
        }
 
@@ -652,8 +654,8 @@ int onenand_read_oob(struct mtd_info *mtd, loff_t from, size_t len,
                        break;
 
                if (ret) {
-                       DEBUG(MTD_DEBUG_LEVEL0,
-                             "onenand_read_oob: read failed = %d\n", ret);
+                       MTDDEBUG (MTD_DEBUG_LEVEL0,
+                                 "onenand_read_oob: read failed = %d\n", ret);
                        break;
                }
 
@@ -733,23 +735,24 @@ static int onenand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
        int written = 0;
        int ret = 0;
 
-       DEBUG(MTD_DEBUG_LEVEL3, "onenand_write_ecc: to = 0x%08x, len = %i\n",
-             (unsigned int)to, (int)len);
+       MTDDEBUG (MTD_DEBUG_LEVEL3, "onenand_write_ecc: "
+                 "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");
+               MTDDEBUG (MTD_DEBUG_LEVEL0, "onenand_write_ecc: "
+                         "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");
+               MTDDEBUG (MTD_DEBUG_LEVEL0, "onenand_write_ecc: "
+                         "Attempt to write not page aligned data\n");
                return -EINVAL;
        }
 
@@ -772,8 +775,8 @@ static int onenand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
 
                ret = this->wait(mtd, FL_WRITING);
                if (ret) {
-                       DEBUG(MTD_DEBUG_LEVEL0,
-                             "onenand_write_ecc: write filaed %d\n", ret);
+                       MTDDEBUG (MTD_DEBUG_LEVEL0,
+                                 "onenand_write_ecc: write filaed %d\n", ret);
                        break;
                }
 
@@ -782,8 +785,8 @@ 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, block, page);
                if (ret) {
-                       DEBUG(MTD_DEBUG_LEVEL0,
-                             "onenand_write_ecc: verify failed %d\n", ret);
+                       MTDDEBUG (MTD_DEBUG_LEVEL0,
+                                 "onenand_write_ecc: verify failed %d\n", ret);
                        break;
                }
 
@@ -836,16 +839,17 @@ int onenand_write_oob(struct mtd_info *mtd, loff_t to, size_t len,
        int column, status;
        int written = 0;
 
-       DEBUG(MTD_DEBUG_LEVEL3, "onenand_write_oob: to = 0x%08x, len = %i\n",
-             (unsigned int)to, (int)len);
+       MTDDEBUG (MTD_DEBUG_LEVEL3, "onenand_write_oob: "
+                 "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_oob: Attempt write to past end of device\n");
+               MTDDEBUG (MTD_DEBUG_LEVEL0, "onenand_write_oob: "
+                         "Attempt write to past end of device\n");
                return -EINVAL;
        }
 
@@ -904,28 +908,29 @@ int onenand_erase(struct mtd_info *mtd, struct erase_info *instr)
        int len;
        int ret = 0;
 
-       DEBUG(MTD_DEBUG_LEVEL3, "onenand_erase: start = 0x%08x, len = %i\n",
-             (unsigned int)instr->addr, (unsigned int)instr->len);
+       MTDDEBUG (MTD_DEBUG_LEVEL3, "onenand_erase: start = 0x%08x, len = %i\n",
+                 (unsigned int)instr->addr, (unsigned int)instr->len);
 
        block_size = (1 << this->erase_shift);
 
        /* Start address must align on block boundary */
        if (unlikely(instr->addr & (block_size - 1))) {
-               DEBUG(MTD_DEBUG_LEVEL0, "onenand_erase: Unaligned address\n");
+               MTDDEBUG (MTD_DEBUG_LEVEL0,
+                         "onenand_erase: Unaligned address\n");
                return -EINVAL;
        }
 
        /* Length must align on block boundary */
        if (unlikely(instr->len & (block_size - 1))) {
-               DEBUG(MTD_DEBUG_LEVEL0,
-                     "onenand_erase: Length not block aligned\n");
+               MTDDEBUG (MTD_DEBUG_LEVEL0,
+                         "onenand_erase: Length not block aligned\n");
                return -EINVAL;
        }
 
        /* Do not allow erase past end of device */
        if (unlikely((instr->len + instr->addr) > mtd->size)) {
-               DEBUG(MTD_DEBUG_LEVEL0,
-                     "onenand_erase: Erase past end of device\n");
+               MTDDEBUG (MTD_DEBUG_LEVEL0,
+                         "onenand_erase: Erase past end of device\n");
                return -EINVAL;
        }
 
@@ -950,12 +955,12 @@ int onenand_erase(struct mtd_info *mtd, struct erase_info *instr)
                /* Check, if it is write protected */
                if (ret) {
                        if (ret == -EPERM)
-                               DEBUG(MTD_DEBUG_LEVEL0,
-                                     "onenand_erase: Device is write protected!!!\n");
+                               MTDDEBUG (MTD_DEBUG_LEVEL0, "onenand_erase: "
+                                         "Device is write protected!!!\n");
                        else
-                               DEBUG(MTD_DEBUG_LEVEL0,
-                                     "onenand_erase: Failed erase, block %d\n",
-                                     (unsigned)(addr >> this->erase_shift));
+                               MTDDEBUG (MTD_DEBUG_LEVEL0, "onenand_erase: "
+                                         "Failed erase, block %d\n",
+                                         (unsigned)(addr >> this->erase_shift));
                        instr->state = MTD_ERASE_FAILED;
                        instr->fail_addr = addr;
                        goto erase_exit;
@@ -988,7 +993,7 @@ int onenand_erase(struct mtd_info *mtd, struct erase_info *instr)
  */
 void onenand_sync(struct mtd_info *mtd)
 {
-       DEBUG(MTD_DEBUG_LEVEL3, "onenand_sync: called\n");
+       MTDDEBUG (MTD_DEBUG_LEVEL3, "onenand_sync: called\n");
 
        /* Grab the lock and see if the device is available */
        onenand_get_device(mtd, FL_SYNCING);
index 5a610ee5ea8b3fc381da19104112f227ce82e176..87344ab65f194e7c204657ba7790d694f8a82911 100644 (file)
@@ -156,9 +156,9 @@ static int onenand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt)
        block = (int)(offs >> (bbm->bbt_erase_shift - 1));
        res = (bbm->bbt[block >> 3] >> (block & 0x06)) & 0x03;
 
-       DEBUG(MTD_DEBUG_LEVEL2,
-             "onenand_isbad_bbt: bbt info for offs 0x%08x: (block %d) 0x%02x\n",
-             (unsigned int)offs, block >> 1, res);
+       MTDDEBUG (MTD_DEBUG_LEVEL2,
+                 "onenand_isbad_bbt: bbt info for offs 0x%08x: (block %d) 0x%02x\n",
+                 (unsigned int)offs, block >> 1, res);
 
        switch ((int)res) {
        case 0x00:
index 71cb2d5c3b285995dbdc8fcb9b8a7dc70eeb294a..05ba375a825412d4f00ace1fd722f90aaf3e4b1f 100644 (file)
@@ -201,13 +201,13 @@ static inline void mtd_erase_callback(struct erase_info *instr)
 #define MTD_DEBUG_LEVEL3       (3)     /* Noisy   */
 
 #ifdef CONFIG_MTD_DEBUG
-#define DEBUG(n, args...)                              \
+#define MTDDEBUG(n, args...)                           \
        do {                                            \
                if (n <= CONFIG_MTD_DEBUG_VERBOSE)      \
                        printk(KERN_INFO args);         \
        } while(0)
 #else /* CONFIG_MTD_DEBUG */
-#define DEBUG(n, args...) do { } while(0)
+#define MTDDEBUG(n, args...) do { } while(0)
 
 #endif /* CONFIG_MTD_DEBUG */
 
index 247d3465dbb0b140e4cb14fe242022ae0995ca0b..e1285cdae97a9ddbda2955bb7facb069aa6981d7 100644 (file)
@@ -24,6 +24,9 @@
 #ifndef _NAND_H_
 #define _NAND_H_
 
+extern void nand_init(void);
+
+#ifndef CFG_NAND_LEGACY
 #include <linux/mtd/compat.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
@@ -32,7 +35,6 @@ typedef struct mtd_info nand_info_t;
 
 extern int nand_curr_device;
 extern nand_info_t nand_info[];
-extern void nand_init(void);
 
 static inline int nand_read(nand_info_t *info, off_t ofs, size_t *len, u_char *buf)
 {
@@ -122,4 +124,5 @@ int nand_get_lock_status(nand_info_t *meminfo, ulong offset);
 void board_nand_select_device(struct nand_chip *nand, int chip);
 #endif
 
+#endif /* !CFG_NAND_LEGACY */
 #endif