[PATCH v3 5/9] mtd: nand: Add a helper to retrieve the number of ECC bytes per step
Miquel Raynal
miquel.raynal at bootlin.com
Wed Jan 27 15:30:16 EST 2021
This operation is very common and deserves a helper. It of course only
works after the ECC engine initialization.
Signed-off-by: Miquel Raynal <miquel.raynal at bootlin.com>
---
include/linux/mtd/nand.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 8a0116396689..32fc7edf65b3 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -597,6 +597,16 @@ nanddev_get_ecc_nsteps(struct nand_device *nand)
return nand->ecc.ctx.nsteps;
}
+/**
+ * nanddev_get_ecc_bytes_per_step() - Extract the number of ECC bytes per step
+ * @nand: NAND device
+ */
+static inline unsigned int
+nanddev_get_ecc_bytes_per_step(struct nand_device *nand)
+{
+ return nand->ecc.ctx.total / nand->ecc.ctx.nsteps;
+}
+
/**
* nanddev_get_ecc_requirements() - Extract the ECC requirements from a NAND
* device
--
2.20.1
More information about the linux-mtd
mailing list