Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: nand: Create helpers to set/extract the ECC requirements

Despite its current name, the eccreq field actually encodes both the
NAND requirements and the final ECC configuration. That works fine when
using on-die ECC since those 2 concepts match perfectly, but it starts
being a problem as soon as we use on-host ECC engines, where we're not
guaranteed to have a perfect match.

Let's hide the ECC requirements access behind helpers so we can later
split those 2 concepts. As the structures have not been clarified yet,
these helpers access the same internal variable as
nanddev_get_ecc_conf() for now.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200827085208.16276-14-miquel.raynal@bootlin.com

+24
+24
include/linux/mtd/nand.h
··· 533 533 return &nand->eccreq; 534 534 } 535 535 536 + /** 537 + * nanddev_get_ecc_requirements() - Extract the ECC requirements from a NAND 538 + * device 539 + * @nand: NAND device 540 + */ 541 + static inline const struct nand_ecc_props * 542 + nanddev_get_ecc_requirements(struct nand_device *nand) 543 + { 544 + return &nand->eccreq; 545 + } 546 + 547 + /** 548 + * nanddev_set_ecc_requirements() - Assign the ECC requirements of a NAND 549 + * device 550 + * @nand: NAND device 551 + * @reqs: Requirements 552 + */ 553 + static inline void 554 + nanddev_set_ecc_requirements(struct nand_device *nand, 555 + const struct nand_ecc_props *reqs) 556 + { 557 + nand->eccreq = *reqs; 558 + } 559 + 536 560 int nanddev_init(struct nand_device *nand, const struct nand_ops *ops, 537 561 struct module *owner); 538 562 void nanddev_cleanup(struct nand_device *nand);