diff options
Diffstat (limited to 'drivers/mtd/nand/nand_ecc.c')
-rw-r--r-- | drivers/mtd/nand/nand_ecc.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/drivers/mtd/nand/nand_ecc.c b/drivers/mtd/nand/nand_ecc.c index c0cb87d6d16e..db7ae9d6a296 100644 --- a/drivers/mtd/nand/nand_ecc.c +++ b/drivers/mtd/nand/nand_ecc.c | |||
@@ -417,22 +417,22 @@ int nand_calculate_ecc(struct mtd_info *mtd, const unsigned char *buf, | |||
417 | EXPORT_SYMBOL(nand_calculate_ecc); | 417 | EXPORT_SYMBOL(nand_calculate_ecc); |
418 | 418 | ||
419 | /** | 419 | /** |
420 | * nand_correct_data - [NAND Interface] Detect and correct bit error(s) | 420 | * __nand_correct_data - [NAND Interface] Detect and correct bit error(s) |
421 | * @mtd: MTD block structure | ||
422 | * @buf: raw data read from the chip | 421 | * @buf: raw data read from the chip |
423 | * @read_ecc: ECC from the chip | 422 | * @read_ecc: ECC from the chip |
424 | * @calc_ecc: the ECC calculated from raw data | 423 | * @calc_ecc: the ECC calculated from raw data |
424 | * @eccsize: data bytes per ecc step (256 or 512) | ||
425 | * | 425 | * |
426 | * Detect and correct a 1 bit error for 256/512 byte block | 426 | * Detect and correct a 1 bit error for eccsize byte block |
427 | */ | 427 | */ |
428 | int nand_correct_data(struct mtd_info *mtd, unsigned char *buf, | 428 | int __nand_correct_data(unsigned char *buf, |
429 | unsigned char *read_ecc, unsigned char *calc_ecc) | 429 | unsigned char *read_ecc, unsigned char *calc_ecc, |
430 | unsigned int eccsize) | ||
430 | { | 431 | { |
431 | unsigned char b0, b1, b2, bit_addr; | 432 | unsigned char b0, b1, b2, bit_addr; |
432 | unsigned int byte_addr; | 433 | unsigned int byte_addr; |
433 | /* 256 or 512 bytes/ecc */ | 434 | /* 256 or 512 bytes/ecc */ |
434 | const uint32_t eccsize_mult = | 435 | const uint32_t eccsize_mult = eccsize >> 8; |
435 | (((struct nand_chip *)mtd->priv)->ecc.size) >> 8; | ||
436 | 436 | ||
437 | /* | 437 | /* |
438 | * b0 to b2 indicate which bit is faulty (if any) | 438 | * b0 to b2 indicate which bit is faulty (if any) |
@@ -495,6 +495,23 @@ int nand_correct_data(struct mtd_info *mtd, unsigned char *buf, | |||
495 | printk(KERN_ERR "uncorrectable error : "); | 495 | printk(KERN_ERR "uncorrectable error : "); |
496 | return -1; | 496 | return -1; |
497 | } | 497 | } |
498 | EXPORT_SYMBOL(__nand_correct_data); | ||
499 | |||
500 | /** | ||
501 | * nand_correct_data - [NAND Interface] Detect and correct bit error(s) | ||
502 | * @mtd: MTD block structure | ||
503 | * @buf: raw data read from the chip | ||
504 | * @read_ecc: ECC from the chip | ||
505 | * @calc_ecc: the ECC calculated from raw data | ||
506 | * | ||
507 | * Detect and correct a 1 bit error for 256/512 byte block | ||
508 | */ | ||
509 | int nand_correct_data(struct mtd_info *mtd, unsigned char *buf, | ||
510 | unsigned char *read_ecc, unsigned char *calc_ecc) | ||
511 | { | ||
512 | return __nand_correct_data(buf, read_ecc, calc_ecc, | ||
513 | ((struct nand_chip *)mtd->priv)->ecc.size); | ||
514 | } | ||
498 | EXPORT_SYMBOL(nand_correct_data); | 515 | EXPORT_SYMBOL(nand_correct_data); |
499 | 516 | ||
500 | MODULE_LICENSE("GPL"); | 517 | MODULE_LICENSE("GPL"); |