git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git]
/
drivers
/
mtd
/
onenand
/
onenand_bbt.c
diff --git
a/drivers/mtd/onenand/onenand_bbt.c
b/drivers/mtd/onenand/onenand_bbt.c
index
4510d33
..
98f8fd1
100644
(file)
--- a/
drivers/mtd/onenand/onenand_bbt.c
+++ b/
drivers/mtd/onenand/onenand_bbt.c
@@
-17,6
+17,9
@@
#include <linux/mtd/onenand.h>
#include <linux/mtd/compatmac.h>
#include <linux/mtd/onenand.h>
#include <linux/mtd/compatmac.h>
+extern int onenand_do_read_oob(struct mtd_info *mtd, loff_t from, size_t len,
+ size_t *retlen, u_char *buf);
+
/**
* check_short_pattern - [GENERIC] check if a pattern is in the buffer
* @param buf the buffer to search
/**
* check_short_pattern - [GENERIC] check if a pattern is in the buffer
* @param buf the buffer to search
@@
-87,16
+90,18
@@
static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
/* No need to read pages fully,
* just read required OOB bytes */
/* No need to read pages fully,
* just read required OOB bytes */
- ret =
mtd->read_oob(mtd, from + j * mtd->oobblock
+ bd->offs,
- readlen, &retlen, &buf[0]);
+ ret =
onenand_do_read_oob(mtd, from + j * mtd->writesize
+ bd->offs,
+
readlen, &retlen, &buf[0]);
- if (ret)
+ /* If it is a initial bad block, just ignore it */
+ if (ret && !(ret & ONENAND_CTRL_LOAD))
return ret;
return ret;
- if (check_short_pattern(&buf[j * scanlen], scanlen, mtd->
oobblock
, bd)) {
+ if (check_short_pattern(&buf[j * scanlen], scanlen, mtd->
writesize
, bd)) {
bbm->bbt[i >> 3] |= 0x03 << (i & 0x6);
printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n",
i >> 1, (unsigned int) from);
bbm->bbt[i >> 3] |= 0x03 << (i & 0x6);
printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n",
i >> 1, (unsigned int) from);
+ mtd->ecc_stats.badblocks++;
break;
}
}
break;
}
}
@@
-174,14
+179,12
@@
int onenand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
int len, ret = 0;
len = mtd->size >> (this->erase_shift + 2);
int len, ret = 0;
len = mtd->size >> (this->erase_shift + 2);
- /* Allocate memory (2bit per block) */
- bbm->bbt = k
m
alloc(len, GFP_KERNEL);
+ /* Allocate memory (2bit per block)
and clear the memory bad block table
*/
+ bbm->bbt = k
z
alloc(len, GFP_KERNEL);
if (!bbm->bbt) {
printk(KERN_ERR "onenand_scan_bbt: Out of memory\n");
return -ENOMEM;
}
if (!bbm->bbt) {
printk(KERN_ERR "onenand_scan_bbt: Out of memory\n");
return -ENOMEM;
}
- /* Clear the memory bad block table */
- memset(bbm->bbt, 0x00, len);
/* Set the bad block position */
bbm->badblockpos = ONENAND_BADBLOCK_POS;
/* Set the bad block position */
bbm->badblockpos = ONENAND_BADBLOCK_POS;
@@
-227,14
+230,12
@@
int onenand_default_bbt(struct mtd_info *mtd)
struct onenand_chip *this = mtd->priv;
struct bbm_info *bbm;
struct onenand_chip *this = mtd->priv;
struct bbm_info *bbm;
- this->bbm = k
m
alloc(sizeof(struct bbm_info), GFP_KERNEL);
+ this->bbm = k
z
alloc(sizeof(struct bbm_info), GFP_KERNEL);
if (!this->bbm)
return -ENOMEM;
bbm = this->bbm;
if (!this->bbm)
return -ENOMEM;
bbm = this->bbm;
- memset(bbm, 0, sizeof(struct bbm_info));
-
/* 1KB page has same configuration as 2KB page */
if (!bbm->badblock_pattern)
bbm->badblock_pattern = &largepage_memorybased;
/* 1KB page has same configuration as 2KB page */
if (!bbm->badblock_pattern)
bbm->badblock_pattern = &largepage_memorybased;