Skip to content

Commit 6a918ba

Browse files
mike-dunnDavid Woodhouse
authored andcommitted
mtd: flash drivers set ecc strength
Flash device drivers initialize 'ecc_strength' in struct mtd_info, which is the maximum number of bit errors that can be corrected in one writesize region. Drivers using the nand interface intitialize 'strength' in struct nand_ecc_ctrl, which is the maximum number of bit errors that can be corrected in one ecc step. Nand infrastructure code translates this to 'ecc_strength'. Also for nand drivers, the nand infrastructure code sets ecc.strength for ecc modes NAND_ECC_SOFT, NAND_ECC_SOFT_BCH, and NAND_ECC_NONE. It is set in the driver for all other modes. Signed-off-by: Mike Dunn <mikedunn@newsguy.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent 1d0b95b commit 6a918ba

31 files changed

Lines changed: 63 additions & 1 deletion

‎drivers/mtd/devices/doc2000.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ void DoC2k_init(struct mtd_info *mtd)
564564
mtd->flags = MTD_CAP_NANDFLASH;
565565
mtd->writebufsize = mtd->writesize = 512;
566566
mtd->oobsize = 16;
567+
mtd->ecc_strength = 2;
567568
mtd->owner = THIS_MODULE;
568569
mtd->_erase = doc_erase;
569570
mtd->_read = doc_read;

‎drivers/mtd/devices/doc2001.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ void DoCMil_init(struct mtd_info *mtd)
348348
mtd->erasesize = 0x2000;
349349
mtd->writebufsize = mtd->writesize = 512;
350350
mtd->oobsize = 16;
351+
mtd->ecc_strength = 2;
351352
mtd->owner = THIS_MODULE;
352353
mtd->_erase = doc_erase;
353354
mtd->_read = doc_read;

‎drivers/mtd/devices/doc2001plus.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ void DoCMilPlus_init(struct mtd_info *mtd)
469469
mtd->flags = MTD_CAP_NANDFLASH;
470470
mtd->writebufsize = mtd->writesize = 512;
471471
mtd->oobsize = 16;
472+
mtd->ecc_strength = 2;
472473
mtd->owner = THIS_MODULE;
473474
mtd->_erase = doc_erase;
474475
mtd->_read = doc_read;

‎drivers/mtd/devices/docg3.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,6 +1832,7 @@ static void __init doc_set_driver_info(int chip_id, struct mtd_info *mtd)
18321832
mtd->_write_oob = doc_write_oob;
18331833
mtd->_block_isbad = doc_block_isbad;
18341834
mtd->ecclayout = &docg3_oobinfo;
1835+
mtd->ecc_strength = DOC_ECC_BCH_T;
18351836
}
18361837

18371838
/**

‎drivers/mtd/mtdpart.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ static struct mtd_part *allocate_partition(struct mtd_info *master,
516516
}
517517

518518
slave->mtd.ecclayout = master->ecclayout;
519+
slave->mtd.ecc_strength = master->ecc_strength;
519520
if (master->_block_isbad) {
520521
uint64_t offs = 0;
521522

‎drivers/mtd/nand/alauda.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ static int alauda_init_media(struct alauda *al)
591591
mtd->_block_isbad = alauda_isbad;
592592
mtd->priv = al;
593593
mtd->owner = THIS_MODULE;
594+
mtd->ecc_strength = 1;
594595

595596
err = mtd_device_register(mtd, NULL, 0);
596597
if (err) {

‎drivers/mtd/nand/atmel_nand.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev)
554554
nand_chip->ecc.hwctl = atmel_nand_hwctl;
555555
nand_chip->ecc.read_page = atmel_nand_read_page;
556556
nand_chip->ecc.bytes = 4;
557+
nand_chip->ecc.strength = 1;
557558
}
558559

559560
nand_chip->chip_delay = 20; /* 20us command delay time */

‎drivers/mtd/nand/bcm_umi_nand.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,14 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
476476
largepage_bbt.options = NAND_BBT_SCAN2NDPAGE;
477477
this->badblock_pattern = &largepage_bbt;
478478
}
479+
480+
/*
481+
* FIXME: ecc strength value of 6 bits per 512 bytes of data is a
482+
* conservative guess, given 13 ecc bytes and using bch alg.
483+
* (Assume Galois field order m=15 to allow a margin of error.)
484+
*/
485+
this->ecc.strength = 6;
486+
479487
#endif
480488

481489
/* Now finish off the scan, now that ecc.layout has been initialized. */

‎drivers/mtd/nand/bf5xx_nand.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,9 +702,11 @@ static int bf5xx_nand_scan(struct mtd_info *mtd)
702702
if (likely(mtd->writesize >= 512)) {
703703
chip->ecc.size = 512;
704704
chip->ecc.bytes = 6;
705+
chip->ecc.strength = 2;
705706
} else {
706707
chip->ecc.size = 256;
707708
chip->ecc.bytes = 3;
709+
chip->ecc.strength = 1;
708710
bfin_write_NFC_CTL(bfin_read_NFC_CTL() & ~(1 << NFC_PG_SIZE_OFFSET));
709711
SSYNC();
710712
}

‎drivers/mtd/nand/cafe_nand.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ static int __devinit cafe_nand_probe(struct pci_dev *pdev,
783783
cafe->nand.ecc.mode = NAND_ECC_HW_SYNDROME;
784784
cafe->nand.ecc.size = mtd->writesize;
785785
cafe->nand.ecc.bytes = 14;
786+
cafe->nand.ecc.strength = 4;
786787
cafe->nand.ecc.hwctl = (void *)cafe_nand_bug;
787788
cafe->nand.ecc.calculate = (void *)cafe_nand_bug;
788789
cafe->nand.ecc.correct = (void *)cafe_nand_bug;

0 commit comments

Comments
 (0)