aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2006-10-27 08:40:51 -0400
committerDavid Woodhouse <dwmw2@infradead.org>2006-10-27 08:40:51 -0400
commit7608194c4ae454fab23b8d940986eeb9c58c3478 (patch)
treeab8b29e7c864c9888b20695a85df2cee9410bcd9 /drivers/mtd/nand
parentb478c775a0c306c84215a1138e49fab540b94a5d (diff)
[MTD] NAND: Add ECC debugging for CAFÉ
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/cafe_ecc.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/drivers/mtd/nand/cafe_ecc.c b/drivers/mtd/nand/cafe_ecc.c
index 46214602d205..2d29265cc904 100644
--- a/drivers/mtd/nand/cafe_ecc.c
+++ b/drivers/mtd/nand/cafe_ecc.c
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/module.h>
22#include <linux/errno.h> 23#include <linux/errno.h>
23 24
24static unsigned short gf4096_mul(unsigned short, unsigned short); 25static unsigned short gf4096_mul(unsigned short, unsigned short);
@@ -1322,16 +1323,43 @@ void correct_12bit_symbol(unsigned char *buf, unsigned short sym,
1322 buf[2+(3*(sym-2))/2] ^= (val >> 8); 1323 buf[2+(3*(sym-2))/2] ^= (val >> 8);
1323 buf[3+(3*(sym-2))/2] ^= (val & 0xff); 1324 buf[3+(3*(sym-2))/2] ^= (val & 0xff);
1324 } 1325 }
1325
1326
1327} 1326}
1328 1327
1328static int debugecc = 0;
1329module_param(debugecc, int, 0644);
1330
1329int cafe_correct_ecc(unsigned char *buf, 1331int cafe_correct_ecc(unsigned char *buf,
1330 unsigned short *chk_syndrome_list) 1332 unsigned short *chk_syndrome_list)
1331{ 1333{
1332 unsigned short err_info[9]; 1334 unsigned short err_info[9];
1333 int i; 1335 int i;
1334 1336
1337 if (debugecc) {
1338 printk(KERN_WARNING "cafe_correct_ecc invoked. Syndromes %x %x %x %x %x %x %x %x\n",
1339 chk_syndrome_list[0], chk_syndrome_list[1],
1340 chk_syndrome_list[2], chk_syndrome_list[3],
1341 chk_syndrome_list[4], chk_syndrome_list[5],
1342 chk_syndrome_list[6], chk_syndrome_list[7]);
1343 for (i=0; i < 2048; i+=16) {
1344 printk(KERN_WARNING "D %04x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
1345 i,
1346 buf[i], buf[i+1], buf[i+2], buf[i+3],
1347 buf[i+4], buf[i+5], buf[i+6], buf[i+7],
1348 buf[i+8], buf[i+9], buf[i+10], buf[i+11],
1349 buf[i+12], buf[i+13], buf[i+14], buf[i+15]);
1350 }
1351 for ( ; i < 2112; i+=16) {
1352 printk(KERN_WARNING "O %02x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
1353 i - 2048,
1354 buf[i], buf[i+1], buf[i+2], buf[i+3],
1355 buf[i+4], buf[i+5], buf[i+6], buf[i+7],
1356 buf[i+8], buf[i+9], buf[i+10], buf[i+11],
1357 buf[i+12], buf[i+13], buf[i+14], buf[i+15]);
1358 }
1359 }
1360
1361
1362
1335 if (chk_no_err_only(chk_syndrome_list, err_info) && 1363 if (chk_no_err_only(chk_syndrome_list, err_info) &&
1336 chk_1_err_only(chk_syndrome_list, err_info) && 1364 chk_1_err_only(chk_syndrome_list, err_info) &&
1337 chk_2_err_only(chk_syndrome_list, err_info) && 1365 chk_2_err_only(chk_syndrome_list, err_info) &&
@@ -1340,8 +1368,13 @@ int cafe_correct_ecc(unsigned char *buf,
1340 return -EIO; 1368 return -EIO;
1341 } 1369 }
1342 1370
1343 for (i=0; i < err_info[0]; i++) 1371 for (i=0; i < err_info[0]; i++) {
1372 if (debugecc)
1373 printk(KERN_WARNING "Correct symbol %d with 0x%03x\n",
1374 err_info[1+i], err_info[5+i]);
1375
1344 correct_12bit_symbol(buf, err_info[1+i], err_info[5+i]); 1376 correct_12bit_symbol(buf, err_info[1+i], err_info[5+i]);
1377 }
1345 1378
1346 return err_info[0]; 1379 return err_info[0];
1347} 1380}