Skip to content

Commit cc01e60

Browse files
Boris BREZILLONcomputersforpeace
authored andcommitted
mtd: nand: diskonchip: remove custom 'erased check' implementation
The diskonchip driver is manually checking for 'erased pages' while correcting ECC bytes. This logic can now done by the core infrastructure, and can thus be removed from this driver. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
1 parent bc29c95 commit cc01e60

File tree

1 file changed

+3
-35
lines changed

1 file changed

+3
-35
lines changed

drivers/mtd/nand/diskonchip.c

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ struct doc_priv {
7474
int (*late_init)(struct mtd_info *mtd);
7575
};
7676

77-
/* This is the syndrome computed by the HW ecc generator upon reading an empty
78-
page, one with all 0xff for data and stored ecc code. */
79-
static u_char empty_read_syndrome[6] = { 0x26, 0xff, 0x6d, 0x47, 0x73, 0x7a };
80-
8177
/* This is the ecc value computed by the HW ecc generator upon writing an empty
8278
page, one with all 0xff for data. */
8379
static u_char empty_write_ecc[6] = { 0x4b, 0x00, 0xe2, 0x0e, 0x93, 0xf7 };
@@ -912,7 +908,6 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat,
912908
void __iomem *docptr = doc->virtadr;
913909
uint8_t calc_ecc[6];
914910
volatile u_char dummy;
915-
int emptymatch = 1;
916911

917912
/* flush the pipeline */
918913
if (DoC_is_2000(doc)) {
@@ -936,37 +931,9 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat,
936931
calc_ecc[i] = ReadDOC_(docptr, DoC_Mplus_ECCSyndrome0 + i);
937932
else
938933
calc_ecc[i] = ReadDOC_(docptr, DoC_ECCSyndrome0 + i);
939-
if (calc_ecc[i] != empty_read_syndrome[i])
940-
emptymatch = 0;
941-
}
942-
/* If emptymatch=1, the read syndrome is consistent with an
943-
all-0xff data and stored ecc block. Check the stored ecc. */
944-
if (emptymatch) {
945-
for (i = 0; i < 6; i++) {
946-
if (read_ecc[i] == 0xff)
947-
continue;
948-
emptymatch = 0;
949-
break;
950-
}
951934
}
952-
/* If emptymatch still =1, check the data block. */
953-
if (emptymatch) {
954-
/* Note: this somewhat expensive test should not be triggered
955-
often. It could be optimized away by examining the data in
956-
the readbuf routine, and remembering the result. */
957-
for (i = 0; i < 512; i++) {
958-
if (dat[i] == 0xff)
959-
continue;
960-
emptymatch = 0;
961-
break;
962-
}
963-
}
964-
/* If emptymatch still =1, this is almost certainly a freshly-
965-
erased block, in which case the ECC will not come out right.
966-
We'll suppress the error and tell the caller everything's
967-
OK. Because it is. */
968-
if (!emptymatch)
969-
ret = doc_ecc_decode(rs_decoder, dat, calc_ecc);
935+
936+
ret = doc_ecc_decode(rs_decoder, dat, calc_ecc);
970937
if (ret > 0)
971938
printk(KERN_ERR "doc200x_correct_data corrected %d errors\n", ret);
972939
}
@@ -1586,6 +1553,7 @@ static int __init doc_probe(unsigned long physadr)
15861553
nand->ecc.size = 512;
15871554
nand->ecc.bytes = 6;
15881555
nand->ecc.strength = 2;
1556+
nand->ecc.options = NAND_ECC_GENERIC_ERASED_CHECK;
15891557
nand->bbt_options = NAND_BBT_USE_FLASH;
15901558
/* Skip the automatic BBT scan so we can run it manually */
15911559
nand->options |= NAND_SKIP_BBTSCAN;

0 commit comments

Comments
 (0)