diff options
author | Thomas Gleixner <tglx@cruncher.tec.linutronix.de> | 2006-05-29 18:37:34 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@cruncher.tec.linutronix.de> | 2006-05-29 18:37:34 -0400 |
commit | f1a28c02843efcfcc41982149880bac3ac180234 (patch) | |
tree | b15ca1a140e463ef3cde6b9a8591e7be172ee1f1 /drivers/mtd/nand | |
parent | 9a1fcdfd4bee27c418424cac47abf7c049541297 (diff) |
[MTD] NAND Expose the new raw mode function and status info to userspace
The raw read/write access to NAND (without ECC) has been changed in the
NAND rework. Expose the new way - setting the file mode via ioctl - to
userspace. Also allow to read out the ecc statistics information so userspace
tools can see that bitflips happened and whether errors where correctable
or not. Also expose the number of bad blocks for the partition, so nandwrite
can check if the data fits into the parition before writing to it.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 26 | ||||
-rw-r--r-- | drivers/mtd/nand/nand_bbt.c | 3 |
2 files changed, 19 insertions, 10 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 7a3a44907715..ea6d2c334aed 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -347,7 +347,7 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
347 | { | 347 | { |
348 | struct nand_chip *chip = mtd->priv; | 348 | struct nand_chip *chip = mtd->priv; |
349 | uint8_t buf[2] = { 0, 0 }; | 349 | uint8_t buf[2] = { 0, 0 }; |
350 | int block; | 350 | int block, ret; |
351 | 351 | ||
352 | /* Get block number */ | 352 | /* Get block number */ |
353 | block = ((int)ofs) >> chip->bbt_erase_shift; | 353 | block = ((int)ofs) >> chip->bbt_erase_shift; |
@@ -356,16 +356,22 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
356 | 356 | ||
357 | /* Do we have a flash based bad block table ? */ | 357 | /* Do we have a flash based bad block table ? */ |
358 | if (chip->options & NAND_USE_FLASH_BBT) | 358 | if (chip->options & NAND_USE_FLASH_BBT) |
359 | return nand_update_bbt(mtd, ofs); | 359 | ret = nand_update_bbt(mtd, ofs); |
360 | 360 | else { | |
361 | /* We write two bytes, so we dont have to mess with 16 bit access */ | 361 | /* We write two bytes, so we dont have to mess with 16 bit |
362 | ofs += mtd->oobsize; | 362 | * access |
363 | chip->ops.len = 2; | 363 | */ |
364 | chip->ops.datbuf = NULL; | 364 | ofs += mtd->oobsize; |
365 | chip->ops.oobbuf = buf; | 365 | chip->ops.len = 2; |
366 | chip->ops.ooboffs = chip->badblockpos & ~0x01; | 366 | chip->ops.datbuf = NULL; |
367 | chip->ops.oobbuf = buf; | ||
368 | chip->ops.ooboffs = chip->badblockpos & ~0x01; | ||
367 | 369 | ||
368 | return nand_do_write_oob(mtd, ofs, &chip->ops); | 370 | ret = nand_do_write_oob(mtd, ofs, &chip->ops); |
371 | } | ||
372 | if (!ret) | ||
373 | mtd->ecc_stats.badblocks++; | ||
374 | return ret; | ||
369 | } | 375 | } |
370 | 376 | ||
371 | /** | 377 | /** |
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c index 480c3cbf9bf9..a612c4ea8194 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c | |||
@@ -176,6 +176,7 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, | |||
176 | printk(KERN_DEBUG "nand_read_bbt: Reserved block at 0x%08x\n", | 176 | printk(KERN_DEBUG "nand_read_bbt: Reserved block at 0x%08x\n", |
177 | ((offs << 2) + (act >> 1)) << this->bbt_erase_shift); | 177 | ((offs << 2) + (act >> 1)) << this->bbt_erase_shift); |
178 | this->bbt[offs + (act >> 3)] |= 0x2 << (act & 0x06); | 178 | this->bbt[offs + (act >> 3)] |= 0x2 << (act & 0x06); |
179 | mtd->ecc_stats.bbtblocks++; | ||
179 | continue; | 180 | continue; |
180 | } | 181 | } |
181 | /* Leave it for now, if its matured we can move this | 182 | /* Leave it for now, if its matured we can move this |
@@ -187,6 +188,7 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, | |||
187 | this->bbt[offs + (act >> 3)] |= 0x3 << (act & 0x06); | 188 | this->bbt[offs + (act >> 3)] |= 0x3 << (act & 0x06); |
188 | else | 189 | else |
189 | this->bbt[offs + (act >> 3)] |= 0x1 << (act & 0x06); | 190 | this->bbt[offs + (act >> 3)] |= 0x1 << (act & 0x06); |
191 | mtd->ecc_stats.badblocks++; | ||
190 | } | 192 | } |
191 | } | 193 | } |
192 | totlen -= len; | 194 | totlen -= len; |
@@ -431,6 +433,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, | |||
431 | this->bbt[i >> 3] |= 0x03 << (i & 0x6); | 433 | this->bbt[i >> 3] |= 0x03 << (i & 0x6); |
432 | printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n", | 434 | printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n", |
433 | i >> 1, (unsigned int)from); | 435 | i >> 1, (unsigned int)from); |
436 | mtd->ecc_stats.badblocks++; | ||
434 | } | 437 | } |
435 | 438 | ||
436 | i += 2; | 439 | i += 2; |