Commit 7cf9c19a authored by Boris Brezillon's avatar Boris Brezillon

mtd: nand: bch: switch to mtd_ooblayout_ops

Replace the nand_ecclayout definition by the equivalent mtd_ooblayout_ops
definition.
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
parent 41b207a7
...@@ -4294,6 +4294,21 @@ int nand_scan_tail(struct mtd_info *mtd) ...@@ -4294,6 +4294,21 @@ int nand_scan_tail(struct mtd_info *mtd)
ecc->strength = 4; ecc->strength = 4;
} }
/*
* if no ecc placement scheme was provided pickup the default
* large page one.
*/
if (!mtd->ooblayout) {
/* handle large page devices only */
if (mtd->oobsize < 64) {
WARN(1, "OOB layout is required when using software BCH on small pages\n");
ret = -EINVAL;
goto err_free;
}
mtd_set_ooblayout(mtd, &nand_ooblayout_lp_ops);
}
/* See nand_bch_init() for details. */ /* See nand_bch_init() for details. */
ecc->bytes = 0; ecc->bytes = 0;
ecc->priv = nand_bch_init(mtd); ecc->priv = nand_bch_init(mtd);
......
...@@ -32,13 +32,11 @@ ...@@ -32,13 +32,11 @@
/** /**
* struct nand_bch_control - private NAND BCH control structure * struct nand_bch_control - private NAND BCH control structure
* @bch: BCH control structure * @bch: BCH control structure
* @ecclayout: private ecc layout for this BCH configuration
* @errloc: error location array * @errloc: error location array
* @eccmask: XOR ecc mask, allows erased pages to be decoded as valid * @eccmask: XOR ecc mask, allows erased pages to be decoded as valid
*/ */
struct nand_bch_control { struct nand_bch_control {
struct bch_control *bch; struct bch_control *bch;
struct nand_ecclayout ecclayout;
unsigned int *errloc; unsigned int *errloc;
unsigned char *eccmask; unsigned char *eccmask;
}; };
...@@ -124,7 +122,6 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd) ...@@ -124,7 +122,6 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
{ {
struct nand_chip *nand = mtd_to_nand(mtd); struct nand_chip *nand = mtd_to_nand(mtd);
unsigned int m, t, eccsteps, i; unsigned int m, t, eccsteps, i;
struct nand_ecclayout *layout = nand->ecc.layout;
struct nand_bch_control *nbc = NULL; struct nand_bch_control *nbc = NULL;
unsigned char *erased_page; unsigned char *erased_page;
unsigned int eccsize = nand->ecc.size; unsigned int eccsize = nand->ecc.size;
...@@ -161,35 +158,19 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd) ...@@ -161,35 +158,19 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
eccsteps = mtd->writesize/eccsize; eccsteps = mtd->writesize/eccsize;
/* if no ecc placement scheme was provided, build one */ /*
if (!layout) { * Rely on the default ecclayout to ooblayout wrapper provided by MTD
* core if ecc.layout is not NULL.
/* handle large page devices only */ * FIXME: this should be removed when all callers have moved to the
if (mtd->oobsize < 64) { * mtd_ooblayout_ops approach.
printk(KERN_WARNING "must provide an oob scheme for " */
"oobsize %d\n", mtd->oobsize); mtd_set_ecclayout(mtd, nand->ecc.layout);
goto fail;
}
layout = &nbc->ecclayout;
layout->eccbytes = eccsteps*eccbytes;
/* reserve 2 bytes for bad block marker */ /* Check that we have an oob layout description. */
if (layout->eccbytes+2 > mtd->oobsize) { if (!mtd->ooblayout) {
printk(KERN_WARNING "no suitable oob scheme available " pr_warn("missing oob scheme");
"for oobsize %d eccbytes %u\n", mtd->oobsize,
eccbytes);
goto fail; goto fail;
} }
/* put ecc bytes at oob tail */
for (i = 0; i < layout->eccbytes; i++)
layout->eccpos[i] = mtd->oobsize-layout->eccbytes+i;
layout->oobfree[0].offset = 2;
layout->oobfree[0].length = mtd->oobsize-2-layout->eccbytes;
nand->ecc.layout = layout;
}
/* sanity checks */ /* sanity checks */
if (8*(eccsize+eccbytes) >= (1 << m)) { if (8*(eccsize+eccbytes) >= (1 << m)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment