aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/onenand/onenand_bbt.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/onenand/onenand_bbt.c')
-rw-r--r--drivers/mtd/onenand/onenand_bbt.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/mtd/onenand/onenand_bbt.c b/drivers/mtd/onenand/onenand_bbt.c
index 1b00dac3d7d6..98f8fd1c6375 100644
--- a/drivers/mtd/onenand/onenand_bbt.c
+++ b/drivers/mtd/onenand/onenand_bbt.c
@@ -93,13 +93,15 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
93 ret = onenand_do_read_oob(mtd, from + j * mtd->writesize + bd->offs, 93 ret = onenand_do_read_oob(mtd, from + j * mtd->writesize + bd->offs,
94 readlen, &retlen, &buf[0]); 94 readlen, &retlen, &buf[0]);
95 95
96 if (ret) 96 /* If it is a initial bad block, just ignore it */
97 if (ret && !(ret & ONENAND_CTRL_LOAD))
97 return ret; 98 return ret;
98 99
99 if (check_short_pattern(&buf[j * scanlen], scanlen, mtd->writesize, bd)) { 100 if (check_short_pattern(&buf[j * scanlen], scanlen, mtd->writesize, bd)) {
100 bbm->bbt[i >> 3] |= 0x03 << (i & 0x6); 101 bbm->bbt[i >> 3] |= 0x03 << (i & 0x6);
101 printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n", 102 printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n",
102 i >> 1, (unsigned int) from); 103 i >> 1, (unsigned int) from);
104 mtd->ecc_stats.badblocks++;
103 break; 105 break;
104 } 106 }
105 } 107 }
@@ -177,14 +179,12 @@ int onenand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
177 int len, ret = 0; 179 int len, ret = 0;
178 180
179 len = mtd->size >> (this->erase_shift + 2); 181 len = mtd->size >> (this->erase_shift + 2);
180 /* Allocate memory (2bit per block) */ 182 /* Allocate memory (2bit per block) and clear the memory bad block table */
181 bbm->bbt = kmalloc(len, GFP_KERNEL); 183 bbm->bbt = kzalloc(len, GFP_KERNEL);
182 if (!bbm->bbt) { 184 if (!bbm->bbt) {
183 printk(KERN_ERR "onenand_scan_bbt: Out of memory\n"); 185 printk(KERN_ERR "onenand_scan_bbt: Out of memory\n");
184 return -ENOMEM; 186 return -ENOMEM;
185 } 187 }
186 /* Clear the memory bad block table */
187 memset(bbm->bbt, 0x00, len);
188 188
189 /* Set the bad block position */ 189 /* Set the bad block position */
190 bbm->badblockpos = ONENAND_BADBLOCK_POS; 190 bbm->badblockpos = ONENAND_BADBLOCK_POS;
@@ -230,14 +230,12 @@ int onenand_default_bbt(struct mtd_info *mtd)
230 struct onenand_chip *this = mtd->priv; 230 struct onenand_chip *this = mtd->priv;
231 struct bbm_info *bbm; 231 struct bbm_info *bbm;
232 232
233 this->bbm = kmalloc(sizeof(struct bbm_info), GFP_KERNEL); 233 this->bbm = kzalloc(sizeof(struct bbm_info), GFP_KERNEL);
234 if (!this->bbm) 234 if (!this->bbm)
235 return -ENOMEM; 235 return -ENOMEM;
236 236
237 bbm = this->bbm; 237 bbm = this->bbm;
238 238
239 memset(bbm, 0, sizeof(struct bbm_info));
240
241 /* 1KB page has same configuration as 2KB page */ 239 /* 1KB page has same configuration as 2KB page */
242 if (!bbm->badblock_pattern) 240 if (!bbm->badblock_pattern)
243 bbm->badblock_pattern = &largepage_memorybased; 241 bbm->badblock_pattern = &largepage_memorybased;