[lkml]   [2009]   [Oct]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[037/136] mtd: nand: fix ECC Correction bug for SMC ordering for NDFC driver
2.6.31-stable review patch.  If anyone has any objections, please let us know.

From: Feng Kan <>

commit 76c23c32e3b3ad48e07e07897075ab19ae1ef117 upstream.

Fix ECC Correction bug where the byte offset location were double
fliped causing correction routine to toggle the wrong byte location
in the ECC segment. The ndfc_calculate_ecc routine change the order
of getting the ECC code.
/* The NDFC uses Smart Media (SMC) bytes order */
ecc_code[0] = p[2];
ecc_code[1] = p[1];
ecc_code[2] = p[3];
But in the Correction algorithm when calculating the byte offset
location, the b1 is used as the upper part of the address. Which
again reverse the order making the final byte offset address
location incorrect.
byte_addr = (addressbits[b1] << 4) + addressbits[b0];
The order is change to read it in straight and let the correction
function to revert it to SMC order.

Signed-off-by: Feng Kan <>
Acked-by: Victor Gallardo <>
Acked-by: Prodyut Hazarika <>
Acked-by: Stefan Roese <>
Signed-off-by: David Woodhouse <>
Signed-off-by: Greg Kroah-Hartman <>

drivers/mtd/nand/ndfc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/mtd/nand/ndfc.c
+++ b/drivers/mtd/nand/ndfc.c
@@ -102,8 +102,8 @@ static int ndfc_calculate_ecc(struct mtd
ecc = in_be32(ndfc->ndfcbase + NDFC_ECC);
/* The NDFC uses Smart Media (SMC) bytes order */
- ecc_code[0] = p[2];
- ecc_code[1] = p[1];
+ ecc_code[0] = p[1];
+ ecc_code[1] = p[2];
ecc_code[2] = p[3];

return 0;

 \ /
  Last update: 2009-10-02 04:01    [W:0.272 / U:29.428 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site