diff options
author | Boris Brezillon <boris.brezillon@free-electrons.com> | 2016-02-03 13:59:47 -0500 |
---|---|---|
committer | Boris Brezillon <boris.brezillon@free-electrons.com> | 2016-05-05 17:51:39 -0400 |
commit | a8ed6e66f3b04d804fae425023aa4e7615dadab7 (patch) | |
tree | dcd18357d05e71bfd5aa8d72bd0ffce83b737747 | |
parent | ef5eeea6e911540bbf51a283fe0ffb7389cbe66a (diff) |
mtd: nand: cafe: switch to mtd_ooblayout_ops
Implementing the mtd_ooblayout_ops interface is the new way of exposing
ECC/OOB layout to MTD users.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
-rw-r--r-- | drivers/mtd/nand/cafe_nand.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c index e553aff68987..0b0c93702abb 100644 --- a/drivers/mtd/nand/cafe_nand.c +++ b/drivers/mtd/nand/cafe_nand.c | |||
@@ -459,10 +459,37 @@ static int cafe_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip, | |||
459 | return max_bitflips; | 459 | return max_bitflips; |
460 | } | 460 | } |
461 | 461 | ||
462 | static struct nand_ecclayout cafe_oobinfo_2048 = { | 462 | static int cafe_ooblayout_ecc(struct mtd_info *mtd, int section, |
463 | .eccbytes = 14, | 463 | struct mtd_oob_region *oobregion) |
464 | .eccpos = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, | 464 | { |
465 | .oobfree = {{14, 50}} | 465 | struct nand_chip *chip = mtd_to_nand(mtd); |
466 | |||
467 | if (section) | ||
468 | return -ERANGE; | ||
469 | |||
470 | oobregion->offset = 0; | ||
471 | oobregion->length = chip->ecc.total; | ||
472 | |||
473 | return 0; | ||
474 | } | ||
475 | |||
476 | static int cafe_ooblayout_free(struct mtd_info *mtd, int section, | ||
477 | struct mtd_oob_region *oobregion) | ||
478 | { | ||
479 | struct nand_chip *chip = mtd_to_nand(mtd); | ||
480 | |||
481 | if (section) | ||
482 | return -ERANGE; | ||
483 | |||
484 | oobregion->offset = chip->ecc.total; | ||
485 | oobregion->length = mtd->oobsize - chip->ecc.total; | ||
486 | |||
487 | return 0; | ||
488 | } | ||
489 | |||
490 | static const struct mtd_ooblayout_ops cafe_ooblayout_ops = { | ||
491 | .ecc = cafe_ooblayout_ecc, | ||
492 | .free = cafe_ooblayout_free, | ||
466 | }; | 493 | }; |
467 | 494 | ||
468 | /* Ick. The BBT code really ought to be able to work this bit out | 495 | /* Ick. The BBT code really ought to be able to work this bit out |
@@ -494,12 +521,6 @@ static struct nand_bbt_descr cafe_bbt_mirror_descr_2048 = { | |||
494 | .pattern = cafe_mirror_pattern_2048 | 521 | .pattern = cafe_mirror_pattern_2048 |
495 | }; | 522 | }; |
496 | 523 | ||
497 | static struct nand_ecclayout cafe_oobinfo_512 = { | ||
498 | .eccbytes = 14, | ||
499 | .eccpos = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, | ||
500 | .oobfree = {{14, 2}} | ||
501 | }; | ||
502 | |||
503 | static struct nand_bbt_descr cafe_bbt_main_descr_512 = { | 524 | static struct nand_bbt_descr cafe_bbt_main_descr_512 = { |
504 | .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE | 525 | .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
505 | | NAND_BBT_2BIT | NAND_BBT_VERSION, | 526 | | NAND_BBT_2BIT | NAND_BBT_VERSION, |
@@ -743,12 +764,11 @@ static int cafe_nand_probe(struct pci_dev *pdev, | |||
743 | cafe->ctl2 |= 1<<29; /* 2KiB page size */ | 764 | cafe->ctl2 |= 1<<29; /* 2KiB page size */ |
744 | 765 | ||
745 | /* Set up ECC according to the type of chip we found */ | 766 | /* Set up ECC according to the type of chip we found */ |
767 | mtd_set_ooblayout(mtd, &cafe_ooblayout_ops); | ||
746 | if (mtd->writesize == 2048) { | 768 | if (mtd->writesize == 2048) { |
747 | cafe->nand.ecc.layout = &cafe_oobinfo_2048; | ||
748 | cafe->nand.bbt_td = &cafe_bbt_main_descr_2048; | 769 | cafe->nand.bbt_td = &cafe_bbt_main_descr_2048; |
749 | cafe->nand.bbt_md = &cafe_bbt_mirror_descr_2048; | 770 | cafe->nand.bbt_md = &cafe_bbt_mirror_descr_2048; |
750 | } else if (mtd->writesize == 512) { | 771 | } else if (mtd->writesize == 512) { |
751 | cafe->nand.ecc.layout = &cafe_oobinfo_512; | ||
752 | cafe->nand.bbt_td = &cafe_bbt_main_descr_512; | 772 | cafe->nand.bbt_td = &cafe_bbt_main_descr_512; |
753 | cafe->nand.bbt_md = &cafe_bbt_mirror_descr_512; | 773 | cafe->nand.bbt_md = &cafe_bbt_mirror_descr_512; |
754 | } else { | 774 | } else { |