Commit 76c23c32 authored by Feng Kan's avatar Feng Kan Committed by David Woodhouse

mtd: nand: fix ECC Correction bug for SMC ordering for NDFC driver

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.

Cc: stable@kernel.org
Signed-off-by: default avatarFeng Kan <fkan@amcc.com>
Acked-by: default avatarVictor Gallardo <vgallardo@amcc.com>
Acked-by: default avatarProdyut Hazarika <phazarika@amcc.com>
Acked-by: default avatarStefan Roese <sr@denx.de>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent ebd5a74d
......@@ -102,8 +102,8 @@ static int ndfc_calculate_ecc(struct mtd_info *mtd,
wmb();
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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment