mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-14 00:47:26 +00:00
NAND: Rename DEBUG to MTDDEBUG to avoid namespace pollution.
This is particularly problematic now that non-NAND-specific code is including <nand.h>, and thus all debugging code is being compiled regardless of whether it was requested, as reported by Scott McNutt <smcnutt@psyent.com>. Signed-off-by: Scott Wood <scottwood@freescale.com>
This commit is contained in:
parent
c956717ab2
commit
3167c5386e
6 changed files with 132 additions and 90 deletions
|
@ -240,7 +240,8 @@ static int nand_davinci_compare_ecc(u_int8_t *ecc_nand, u_int8_t *ecc_calc, u_in
|
||||||
return 0;
|
return 0;
|
||||||
case 1:
|
case 1:
|
||||||
/* Uncorrectable error */
|
/* Uncorrectable error */
|
||||||
DEBUG (MTD_DEBUG_LEVEL0, "ECC UNCORRECTED_ERROR 1\n");
|
MTDDEBUG (MTD_DEBUG_LEVEL0,
|
||||||
|
"ECC UNCORRECTED_ERROR 1\n");
|
||||||
return(-1);
|
return(-1);
|
||||||
case 12:
|
case 12:
|
||||||
/* Correctable error */
|
/* 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];
|
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);
|
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)
|
if (ecc_calc[0] == 0 && ecc_calc[1] == 0 && ecc_calc[2] == 0)
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
DEBUG (MTD_DEBUG_LEVEL0, "UNCORRECTED_ERROR default\n");
|
MTDDEBUG (MTD_DEBUG_LEVEL0,
|
||||||
|
"UNCORRECTED_ERROR default\n");
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
status = this->waitfunc (mtd, this, FL_WRITING);
|
||||||
/* See if device thinks it succeeded */
|
/* See if device thinks it succeeded */
|
||||||
if (status & 0x01) {
|
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;
|
return -EIO;
|
||||||
}
|
}
|
||||||
} else {
|
} 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++) {
|
for (j = 0; j < eccsteps; j++) {
|
||||||
/* Loop through and verify the data */
|
/* Loop through and verify the data */
|
||||||
if (this->verify_buf(mtd, &this->data_poi[datidx], mtd->eccsize)) {
|
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;
|
goto out;
|
||||||
}
|
}
|
||||||
datidx += mtd->eccsize;
|
datidx += mtd->eccsize;
|
||||||
|
@ -1018,7 +1022,9 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int
|
||||||
if (!hweccbytes)
|
if (!hweccbytes)
|
||||||
continue;
|
continue;
|
||||||
if (this->verify_buf(mtd, &this->oob_buf[oobofs], hweccbytes)) {
|
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;
|
goto out;
|
||||||
}
|
}
|
||||||
oobofs += hweccbytes;
|
oobofs += hweccbytes;
|
||||||
|
@ -1029,7 +1035,9 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int
|
||||||
*/
|
*/
|
||||||
if (oobmode) {
|
if (oobmode) {
|
||||||
if (this->verify_buf(mtd, &oob_buf[oobofs], mtd->oobsize - hweccbytes * eccsteps)) {
|
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;
|
goto out;
|
||||||
}
|
}
|
||||||
} else {
|
} 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++) {
|
for (i = 0; i < ecccnt; i++) {
|
||||||
int idx = oobsel->eccpos[i];
|
int idx = oobsel->eccpos[i];
|
||||||
if (oobdata[idx] != oob_buf[oobofs + idx] ) {
|
if (oobdata[idx] != oob_buf[oobofs + idx] ) {
|
||||||
DEBUG (MTD_DEBUG_LEVEL0,
|
MTDDEBUG (MTD_DEBUG_LEVEL0,
|
||||||
"%s: Failed ECC write "
|
"%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;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1131,11 +1141,13 @@ static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
|
||||||
int oobreadlen;
|
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 */
|
/* Do not allow reads past end of device */
|
||||||
if ((from + len) > mtd->size) {
|
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;
|
*retlen = 0;
|
||||||
return -EINVAL;
|
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
|
* generator for an error, reads back the syndrome and
|
||||||
* does the error correction on the fly */
|
* does the error correction on the fly */
|
||||||
if (this->correct_data(mtd, &data_poi[datidx], &oob_data[i], &ecc_code[i]) == -1) {
|
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);
|
"Failed ECC read, page 0x%08x on chip %d\n", page, chipnr);
|
||||||
ecc_failed++;
|
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) {
|
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++;
|
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;
|
struct nand_chip *this = mtd->priv;
|
||||||
int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1;
|
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 */
|
/* Shift to get page */
|
||||||
page = (int)(from >> this->page_shift);
|
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 */
|
/* Do not allow reads past end of device */
|
||||||
if ((from + len) > mtd->size) {
|
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;
|
*retlen = 0;
|
||||||
return -EINVAL;
|
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 */
|
/* Do not allow reads past end of device */
|
||||||
if ((from + len) > mtd->size) {
|
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;
|
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;
|
u_char *oobbuf, *bufstart;
|
||||||
int ppblock = (1 << (this->phys_erase_shift - this->page_shift));
|
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 */
|
/* Initialize retlen, in case of early exit */
|
||||||
*retlen = 0;
|
*retlen = 0;
|
||||||
|
|
||||||
/* Do not allow write past end of device */
|
/* Do not allow write past end of device */
|
||||||
if ((to + len) > mtd->size) {
|
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;
|
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));
|
ret = nand_write_page (mtd, this, page, &oobbuf[oob], oobsel, (--numpages > 0));
|
||||||
if (ret) {
|
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;
|
goto out;
|
||||||
}
|
}
|
||||||
/* Next oob page */
|
/* Next oob page */
|
||||||
|
@ -1719,7 +1739,8 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
|
||||||
page - startpage,
|
page - startpage,
|
||||||
oobbuf, oobsel, chipnr, (eccbuf != NULL));
|
oobbuf, oobsel, chipnr, (eccbuf != NULL));
|
||||||
if (ret) {
|
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;
|
goto out;
|
||||||
}
|
}
|
||||||
*retlen = written;
|
*retlen = written;
|
||||||
|
@ -1752,7 +1773,8 @@ cmp:
|
||||||
if (!ret)
|
if (!ret)
|
||||||
*retlen = written;
|
*retlen = written;
|
||||||
else
|
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:
|
out:
|
||||||
/* Deselect and wake up anyone waiting on the device */
|
/* 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;
|
int column, page, status, ret = -EIO, chipnr;
|
||||||
struct nand_chip *this = mtd->priv;
|
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 */
|
/* Shift to get page */
|
||||||
page = (int) (to >> this->page_shift);
|
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 */
|
/* Do not allow write past end of page */
|
||||||
if ((column + len) > mtd->oobsize) {
|
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;
|
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);
|
this->cmdfunc (mtd, NAND_CMD_SEQIN, mtd->oobblock, page & this->pagemask);
|
||||||
if (!ffchars) {
|
if (!ffchars) {
|
||||||
if (!(ffchars = kmalloc (mtd->oobsize, GFP_KERNEL))) {
|
if (!(ffchars = kmalloc (mtd->oobsize, GFP_KERNEL))) {
|
||||||
DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: "
|
MTDDEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: "
|
||||||
"No memory for padding array, need %d bytes", mtd->oobsize);
|
"No memory for padding array, "
|
||||||
|
"need %d bytes", mtd->oobsize);
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto out;
|
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 */
|
/* See if device thinks it succeeded */
|
||||||
if (status & 0x01) {
|
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;
|
ret = -EIO;
|
||||||
goto out;
|
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);
|
this->cmdfunc (mtd, NAND_CMD_READOOB, column, page & this->pagemask);
|
||||||
|
|
||||||
if (this->verify_buf(mtd, buf, len)) {
|
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;
|
ret = -EIO;
|
||||||
goto out;
|
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++)
|
for (i = 0; i < count; i++)
|
||||||
total_len += (int) vecs[i].iov_len;
|
total_len += (int) vecs[i].iov_len;
|
||||||
|
|
||||||
DEBUG (MTD_DEBUG_LEVEL3,
|
MTDDEBUG (MTD_DEBUG_LEVEL3,
|
||||||
"nand_writev: to = 0x%08x, len = %i, count = %ld\n", (unsigned int) to, (unsigned int) total_len, count);
|
"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 */
|
/* Do not allow write past end of page */
|
||||||
if ((to + total_len) > mtd->size) {
|
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;
|
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;
|
int page, len, status, pages_per_block, ret, chipnr;
|
||||||
struct nand_chip *this = mtd->priv;
|
struct nand_chip *this = mtd->priv;
|
||||||
|
|
||||||
DEBUG (MTD_DEBUG_LEVEL3,
|
MTDDEBUG (MTD_DEBUG_LEVEL3, "nand_erase: start = 0x%08x, len = %i\n",
|
||||||
"nand_erase: start = 0x%08x, len = %i\n", (unsigned int) instr->addr, (unsigned int) instr->len);
|
(unsigned int) instr->addr, (unsigned int) instr->len);
|
||||||
|
|
||||||
/* Start address must align on block boundary */
|
/* Start address must align on block boundary */
|
||||||
if (instr->addr & ((1 << this->phys_erase_shift) - 1)) {
|
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;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Length must align on block boundary */
|
/* Length must align on block boundary */
|
||||||
if (instr->len & ((1 << this->phys_erase_shift) - 1)) {
|
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;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do not allow erase past end of device */
|
/* Do not allow erase past end of device */
|
||||||
if ((instr->len + instr->addr) > mtd->size) {
|
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;
|
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 the WP bit */
|
||||||
/* Check, if it is write protected */
|
/* Check, if it is write protected */
|
||||||
if (nand_check_wp(mtd)) {
|
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;
|
instr->state = MTD_ERASE_FAILED;
|
||||||
goto erase_exit;
|
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 */
|
/* See if block erase succeeded */
|
||||||
if (status & 0x01) {
|
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->state = MTD_ERASE_FAILED;
|
||||||
instr->fail_addr = (page << this->page_shift);
|
instr->fail_addr = (page << this->page_shift);
|
||||||
goto erase_exit;
|
goto erase_exit;
|
||||||
|
@ -2229,7 +2262,7 @@ static void nand_sync (struct mtd_info *mtd)
|
||||||
{
|
{
|
||||||
struct nand_chip *this = mtd->priv;
|
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 */
|
/* Grab the lock and see if the device is available */
|
||||||
nand_get_device (this, mtd, FL_SYNCING);
|
nand_get_device (this, mtd, FL_SYNCING);
|
||||||
|
|
|
@ -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));
|
block = (int) (offs >> (this->bbt_erase_shift - 1));
|
||||||
res = (this->bbt[block >> 3] >> (block & 0x06)) & 0x03;
|
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",
|
MTDDEBUG (MTD_DEBUG_LEVEL2, "nand_isbad_bbt(): bbt info for offs 0x%08x: "
|
||||||
(unsigned int)offs, res, block >> 1);
|
"(block %d) 0x%02x\n", (unsigned int)offs, res, block >> 1);
|
||||||
|
|
||||||
switch ((int)res) {
|
switch ((int)res) {
|
||||||
case 0x00: return 0;
|
case 0x00: return 0;
|
||||||
|
|
|
@ -293,22 +293,22 @@ static int onenand_wait(struct mtd_info *mtd, int state)
|
||||||
ctrl = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);
|
ctrl = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);
|
||||||
|
|
||||||
if (ctrl & ONENAND_CTRL_ERROR) {
|
if (ctrl & ONENAND_CTRL_ERROR) {
|
||||||
DEBUG(MTD_DEBUG_LEVEL0,
|
MTDDEBUG (MTD_DEBUG_LEVEL0,
|
||||||
"onenand_wait: controller error = 0x%04x\n", ctrl);
|
"onenand_wait: controller error = 0x%04x\n", ctrl);
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctrl & ONENAND_CTRL_LOCK) {
|
if (ctrl & ONENAND_CTRL_LOCK) {
|
||||||
DEBUG(MTD_DEBUG_LEVEL0,
|
MTDDEBUG (MTD_DEBUG_LEVEL0,
|
||||||
"onenand_wait: it's locked error = 0x%04x\n", ctrl);
|
"onenand_wait: it's locked error = 0x%04x\n", ctrl);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interrupt & ONENAND_INT_READ) {
|
if (interrupt & ONENAND_INT_READ) {
|
||||||
ecc = this->read_word(this->base + ONENAND_REG_ECC_STATUS);
|
ecc = this->read_word(this->base + ONENAND_REG_ECC_STATUS);
|
||||||
if (ecc & ONENAND_ECC_2BIT_ALL) {
|
if (ecc & ONENAND_ECC_2BIT_ALL) {
|
||||||
DEBUG(MTD_DEBUG_LEVEL0,
|
MTDDEBUG (MTD_DEBUG_LEVEL0,
|
||||||
"onenand_wait: ECC error = 0x%04x\n", ecc);
|
"onenand_wait: ECC error = 0x%04x\n", ecc);
|
||||||
return -EBADMSG;
|
return -EBADMSG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -524,13 +524,14 @@ static int onenand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
|
||||||
int thislen;
|
int thislen;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
DEBUG(MTD_DEBUG_LEVEL3, "onenand_read_ecc: from = 0x%08x, len = %i\n",
|
MTDDEBUG (MTD_DEBUG_LEVEL3, "onenand_read_ecc: "
|
||||||
(unsigned int)from, (int)len);
|
"from = 0x%08x, len = %i\n",
|
||||||
|
(unsigned int)from, (int)len);
|
||||||
|
|
||||||
/* Do not allow reads past end of device */
|
/* Do not allow reads past end of device */
|
||||||
if ((from + len) > mtd->size) {
|
if ((from + len) > mtd->size) {
|
||||||
DEBUG(MTD_DEBUG_LEVEL0,
|
MTDDEBUG (MTD_DEBUG_LEVEL0, "onenand_read_ecc: "
|
||||||
"onenand_read_ecc: Attempt read beyond end of device\n");
|
"Attempt read beyond end of device\n");
|
||||||
*retlen = 0;
|
*retlen = 0;
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -561,8 +562,8 @@ static int onenand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
DEBUG(MTD_DEBUG_LEVEL0,
|
MTDDEBUG (MTD_DEBUG_LEVEL0,
|
||||||
"onenand_read_ecc: read failed = %d\n", ret);
|
"onenand_read_ecc: read failed = %d\n", ret);
|
||||||
break;
|
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 read = 0, thislen, column;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
DEBUG(MTD_DEBUG_LEVEL3, "onenand_read_oob: from = 0x%08x, len = %i\n",
|
MTDDEBUG (MTD_DEBUG_LEVEL3, "onenand_read_oob: "
|
||||||
(unsigned int)from, (int)len);
|
"from = 0x%08x, len = %i\n",
|
||||||
|
(unsigned int)from, (int)len);
|
||||||
|
|
||||||
/* Initialize return length value */
|
/* Initialize return length value */
|
||||||
*retlen = 0;
|
*retlen = 0;
|
||||||
|
|
||||||
/* Do not allow reads past end of device */
|
/* Do not allow reads past end of device */
|
||||||
if (unlikely((from + len) > mtd->size)) {
|
if (unlikely((from + len) > mtd->size)) {
|
||||||
DEBUG(MTD_DEBUG_LEVEL0,
|
MTDDEBUG (MTD_DEBUG_LEVEL0, "onenand_read_oob: "
|
||||||
"onenand_read_oob: Attempt read beyond end of device\n");
|
"Attempt read beyond end of device\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,8 +654,8 @@ int onenand_read_oob(struct mtd_info *mtd, loff_t from, size_t len,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
DEBUG(MTD_DEBUG_LEVEL0,
|
MTDDEBUG (MTD_DEBUG_LEVEL0,
|
||||||
"onenand_read_oob: read failed = %d\n", ret);
|
"onenand_read_oob: read failed = %d\n", ret);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,23 +735,24 @@ static int onenand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
|
||||||
int written = 0;
|
int written = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
DEBUG(MTD_DEBUG_LEVEL3, "onenand_write_ecc: to = 0x%08x, len = %i\n",
|
MTDDEBUG (MTD_DEBUG_LEVEL3, "onenand_write_ecc: "
|
||||||
(unsigned int)to, (int)len);
|
"to = 0x%08x, len = %i\n",
|
||||||
|
(unsigned int)to, (int)len);
|
||||||
|
|
||||||
/* Initialize retlen, in case of early exit */
|
/* Initialize retlen, in case of early exit */
|
||||||
*retlen = 0;
|
*retlen = 0;
|
||||||
|
|
||||||
/* Do not allow writes past end of device */
|
/* Do not allow writes past end of device */
|
||||||
if (unlikely((to + len) > mtd->size)) {
|
if (unlikely((to + len) > mtd->size)) {
|
||||||
DEBUG(MTD_DEBUG_LEVEL0,
|
MTDDEBUG (MTD_DEBUG_LEVEL0, "onenand_write_ecc: "
|
||||||
"onenand_write_ecc: Attempt write to past end of device\n");
|
"Attempt write to past end of device\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reject writes, which are not page aligned */
|
/* Reject writes, which are not page aligned */
|
||||||
if (unlikely(NOTALIGNED(to)) || unlikely(NOTALIGNED(len))) {
|
if (unlikely(NOTALIGNED(to)) || unlikely(NOTALIGNED(len))) {
|
||||||
DEBUG(MTD_DEBUG_LEVEL0,
|
MTDDEBUG (MTD_DEBUG_LEVEL0, "onenand_write_ecc: "
|
||||||
"onenand_write_ecc: Attempt to write not page aligned data\n");
|
"Attempt to write not page aligned data\n");
|
||||||
return -EINVAL;
|
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);
|
ret = this->wait(mtd, FL_WRITING);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
DEBUG(MTD_DEBUG_LEVEL0,
|
MTDDEBUG (MTD_DEBUG_LEVEL0,
|
||||||
"onenand_write_ecc: write filaed %d\n", ret);
|
"onenand_write_ecc: write filaed %d\n", ret);
|
||||||
break;
|
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 */
|
/* Only check verify write turn on */
|
||||||
ret = onenand_verify_page(mtd, (u_char *) buf, to, block, page);
|
ret = onenand_verify_page(mtd, (u_char *) buf, to, block, page);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
DEBUG(MTD_DEBUG_LEVEL0,
|
MTDDEBUG (MTD_DEBUG_LEVEL0,
|
||||||
"onenand_write_ecc: verify failed %d\n", ret);
|
"onenand_write_ecc: verify failed %d\n", ret);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -836,16 +839,17 @@ int onenand_write_oob(struct mtd_info *mtd, loff_t to, size_t len,
|
||||||
int column, status;
|
int column, status;
|
||||||
int written = 0;
|
int written = 0;
|
||||||
|
|
||||||
DEBUG(MTD_DEBUG_LEVEL3, "onenand_write_oob: to = 0x%08x, len = %i\n",
|
MTDDEBUG (MTD_DEBUG_LEVEL3, "onenand_write_oob: "
|
||||||
(unsigned int)to, (int)len);
|
"to = 0x%08x, len = %i\n",
|
||||||
|
(unsigned int)to, (int)len);
|
||||||
|
|
||||||
/* Initialize retlen, in case of early exit */
|
/* Initialize retlen, in case of early exit */
|
||||||
*retlen = 0;
|
*retlen = 0;
|
||||||
|
|
||||||
/* Do not allow writes past end of device */
|
/* Do not allow writes past end of device */
|
||||||
if (unlikely((to + len) > mtd->size)) {
|
if (unlikely((to + len) > mtd->size)) {
|
||||||
DEBUG(MTD_DEBUG_LEVEL0,
|
MTDDEBUG (MTD_DEBUG_LEVEL0, "onenand_write_oob: "
|
||||||
"onenand_write_oob: Attempt write to past end of device\n");
|
"Attempt write to past end of device\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -904,28 +908,29 @@ int onenand_erase(struct mtd_info *mtd, struct erase_info *instr)
|
||||||
int len;
|
int len;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
DEBUG(MTD_DEBUG_LEVEL3, "onenand_erase: start = 0x%08x, len = %i\n",
|
MTDDEBUG (MTD_DEBUG_LEVEL3, "onenand_erase: start = 0x%08x, len = %i\n",
|
||||||
(unsigned int)instr->addr, (unsigned int)instr->len);
|
(unsigned int)instr->addr, (unsigned int)instr->len);
|
||||||
|
|
||||||
block_size = (1 << this->erase_shift);
|
block_size = (1 << this->erase_shift);
|
||||||
|
|
||||||
/* Start address must align on block boundary */
|
/* Start address must align on block boundary */
|
||||||
if (unlikely(instr->addr & (block_size - 1))) {
|
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;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Length must align on block boundary */
|
/* Length must align on block boundary */
|
||||||
if (unlikely(instr->len & (block_size - 1))) {
|
if (unlikely(instr->len & (block_size - 1))) {
|
||||||
DEBUG(MTD_DEBUG_LEVEL0,
|
MTDDEBUG (MTD_DEBUG_LEVEL0,
|
||||||
"onenand_erase: Length not block aligned\n");
|
"onenand_erase: Length not block aligned\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do not allow erase past end of device */
|
/* Do not allow erase past end of device */
|
||||||
if (unlikely((instr->len + instr->addr) > mtd->size)) {
|
if (unlikely((instr->len + instr->addr) > mtd->size)) {
|
||||||
DEBUG(MTD_DEBUG_LEVEL0,
|
MTDDEBUG (MTD_DEBUG_LEVEL0,
|
||||||
"onenand_erase: Erase past end of device\n");
|
"onenand_erase: Erase past end of device\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -950,12 +955,12 @@ int onenand_erase(struct mtd_info *mtd, struct erase_info *instr)
|
||||||
/* Check, if it is write protected */
|
/* Check, if it is write protected */
|
||||||
if (ret) {
|
if (ret) {
|
||||||
if (ret == -EPERM)
|
if (ret == -EPERM)
|
||||||
DEBUG(MTD_DEBUG_LEVEL0,
|
MTDDEBUG (MTD_DEBUG_LEVEL0, "onenand_erase: "
|
||||||
"onenand_erase: Device is write protected!!!\n");
|
"Device is write protected!!!\n");
|
||||||
else
|
else
|
||||||
DEBUG(MTD_DEBUG_LEVEL0,
|
MTDDEBUG (MTD_DEBUG_LEVEL0, "onenand_erase: "
|
||||||
"onenand_erase: Failed erase, block %d\n",
|
"Failed erase, block %d\n",
|
||||||
(unsigned)(addr >> this->erase_shift));
|
(unsigned)(addr >> this->erase_shift));
|
||||||
instr->state = MTD_ERASE_FAILED;
|
instr->state = MTD_ERASE_FAILED;
|
||||||
instr->fail_addr = addr;
|
instr->fail_addr = addr;
|
||||||
goto erase_exit;
|
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)
|
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 */
|
/* Grab the lock and see if the device is available */
|
||||||
onenand_get_device(mtd, FL_SYNCING);
|
onenand_get_device(mtd, FL_SYNCING);
|
||||||
|
|
|
@ -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));
|
block = (int)(offs >> (bbm->bbt_erase_shift - 1));
|
||||||
res = (bbm->bbt[block >> 3] >> (block & 0x06)) & 0x03;
|
res = (bbm->bbt[block >> 3] >> (block & 0x06)) & 0x03;
|
||||||
|
|
||||||
DEBUG(MTD_DEBUG_LEVEL2,
|
MTDDEBUG (MTD_DEBUG_LEVEL2,
|
||||||
"onenand_isbad_bbt: bbt info for offs 0x%08x: (block %d) 0x%02x\n",
|
"onenand_isbad_bbt: bbt info for offs 0x%08x: (block %d) 0x%02x\n",
|
||||||
(unsigned int)offs, block >> 1, res);
|
(unsigned int)offs, block >> 1, res);
|
||||||
|
|
||||||
switch ((int)res) {
|
switch ((int)res) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
|
|
|
@ -201,13 +201,13 @@ static inline void mtd_erase_callback(struct erase_info *instr)
|
||||||
#define MTD_DEBUG_LEVEL3 (3) /* Noisy */
|
#define MTD_DEBUG_LEVEL3 (3) /* Noisy */
|
||||||
|
|
||||||
#ifdef CONFIG_MTD_DEBUG
|
#ifdef CONFIG_MTD_DEBUG
|
||||||
#define DEBUG(n, args...) \
|
#define MTDDEBUG(n, args...) \
|
||||||
do { \
|
do { \
|
||||||
if (n <= CONFIG_MTD_DEBUG_VERBOSE) \
|
if (n <= CONFIG_MTD_DEBUG_VERBOSE) \
|
||||||
printk(KERN_INFO args); \
|
printk(KERN_INFO args); \
|
||||||
} while(0)
|
} while(0)
|
||||||
#else /* CONFIG_MTD_DEBUG */
|
#else /* CONFIG_MTD_DEBUG */
|
||||||
#define DEBUG(n, args...) do { } while(0)
|
#define MTDDEBUG(n, args...) do { } while(0)
|
||||||
|
|
||||||
#endif /* CONFIG_MTD_DEBUG */
|
#endif /* CONFIG_MTD_DEBUG */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue