Skip to content

Commit 3316c8e

Browse files
committed
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
1 parent 9a333a7 commit 3316c8e

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

‎include/linux/mtd/nand.h‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,30 @@ nanddev_get_ecc_conf(struct nand_device *nand)
533533
return &nand->eccreq;
534534
}
535535

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+
536560
int nanddev_init(struct nand_device *nand, const struct nand_ops *ops,
537561
struct module *owner);
538562
void nanddev_cleanup(struct nand_device *nand);

0 commit comments

Comments
 (0)