The following is the reposting of patch with v2 version indication based on comment on "[PATCH 1/2]" (also in the attachment).
Subject: [PATCH v2 2/2] mtd: rawnand: fsl_ifc: use bit-wise majority to
recover the contents of ONFI parameter
Per ONFI specification (Rev. 4.0), if all parameter pages have invalid
CRC values, the bit-wise majority may be used to recover the contents of
the parameter pages from the parameter page copies present.
Signed-off-by: Jane Wan <Jane.Wan@xxxxxxxxx>
---
drivers/mtd/nand/raw/nand_base.c | 36 ++++++++++++++++++++++++++++++------
1 file changed, 30 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index 72f3a89..464c4fb 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
+ pr_info("Recover ONFI params with bit-wise majority\n");
+ for (j = 0; j < pagesize; j++) {
+ v = 0;
+ for (k = 0; k < 8; k++) {
+ m = 0;
+ for (l = 0; l < 3; l++)
+ m += GET_BIT(k, buf[l*pagesize + j]);
+ if (m > 1)
+ v |= BIT(k);
+ }
+ ((u8 *)p)[j] = v;
+ }