]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
mtd: nand: add generic helpers to check, match, maximize ECC settings
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Wed, 7 Jun 2017 11:52:10 +0000 (20:52 +0900)
committerBoris Brezillon <boris.brezillon@free-electrons.com>
Sat, 10 Jun 2017 11:40:07 +0000 (13:40 +0200)
commit2c8f8afa7f92acb07641bf95b940d384ed1d0294
tree39000f65267ba3f008c312d7d21bac6096197240
parentdf8b97024e6d28e98066696619e2084bbda4e40e
mtd: nand: add generic helpers to check, match, maximize ECC settings

Driver are responsible for setting up ECC parameters correctly.
Those include:
  - Check if ECC parameters specified (usually by DT) are valid
  - Meet the chip's ECC requirement
  - Maximize ECC strength if NAND_ECC_MAXIMIZE flag is set

The logic can be generalized by factoring out common code.

This commit adds 3 helpers to the NAND framework:
nand_check_ecc_caps - Check if preset step_size and strength are valid
nand_match_ecc_req - Match the chip's requirement
nand_maximize_ecc - Maximize the ECC strength

To use the helpers above, a driver needs to provide:
  - Data array of supported ECC step size and strength
  - A hook that calculates ECC bytes from the combination of
    step_size and strength.

By using those helpers, code duplication among drivers will be
reduced.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
drivers/mtd/nand/nand_base.c
include/linux/mtd/nand.h