diff options
author | Ladislav Michl <ladis@linux-mips.org> | 2018-10-28 22:22:57 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-12-14 20:20:27 +0100 |
commit | 3c9c9a6fee481e7d365455625e69f398680127e8 (patch) | |
tree | 820954ae2b81f249f02893e8b1a641839b34caf6 /drivers | |
parent | ec17281b690b9884558e185721cc3b77c3e2a1ff (diff) | |
download | barebox-3c9c9a6fee481e7d365455625e69f398680127e8.tar.gz barebox-3c9c9a6fee481e7d365455625e69f398680127e8.tar.xz |
mtd: nand: Request strength instead of bytes for soft BCH
Linux commits e0377cdebaf3 and 438320dd34a4 combined and adapted
for Barebox:
Previously, we requested that drivers pass ecc.size and ecc.bytes when
using NAND_ECC_SOFT_BCH. However, a driver is likely to only know the ECC
strength required for its NAND, so each driver would need to perform a
strength-to-bytes calculation.
Avoid duplicating this calculation in each driver by asking drivers to
pass ecc.size and ecc.strength so that the strength-to-bytes calculation
need only be implemented once.
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index ecbf6c992e..faf8f2aea2 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -3698,15 +3698,18 @@ int nand_scan_tail(struct mtd_info *mtd) chip->ecc.read_oob = nand_read_oob_std; chip->ecc.write_oob = nand_write_oob_std; /* - * Board driver should supply ecc.size and ecc.bytes values to - * select how many bits are correctable; see nand_bch_init() - * for details. Otherwise, default to 4 bits for large page - * devices. + * Board driver should supply ecc.size and ecc.strength values + * to select how many bits are correctable. Otherwise, default + * to 4 bits for large page devices. */ if (!chip->ecc.size && (mtd->oobsize >= 64)) { chip->ecc.size = 512; - chip->ecc.bytes = 7; + chip->ecc.strength = 4; } + + /* See nand_bch_init() for details. */ + chip->ecc.bytes = DIV_ROUND_UP( + chip->ecc.strength * fls(8 * chip->ecc.size), 8); chip->ecc.priv = nand_bch_init(mtd, chip->ecc.size, chip->ecc.bytes, @@ -3715,8 +3718,6 @@ int nand_scan_tail(struct mtd_info *mtd) pr_warn("BCH ECC initialization failed!\n"); BUG(); } - chip->ecc.strength = - chip->ecc.bytes * 8 / fls(8 * chip->ecc.size); break; #endif #ifdef CONFIG_NAND_ECC_NONE |