From patchwork Tue Aug 25 18:27:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: fkan@amcc.com X-Patchwork-Id: 32080 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id B4A74B7B94 for ; Wed, 26 Aug 2009 04:30:47 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1Mg0kz-0001WR-On; Tue, 25 Aug 2009 18:28:33 +0000 Received: from sdcmail01.amcc.com ([198.137.200.72]) by bombadil.infradead.org with esmtps (Exim 4.69 #1 (Red Hat Linux)) id 1Mg0kn-0001Uo-UH for linux-mtd@lists.infradead.org; Tue, 25 Aug 2009 18:28:26 +0000 X-IronPort-AV: E=Sophos;i="4.44,273,1249282800"; d="scan'208";a="24046528" Received: from sdcexch01.amcc.com (HELO sdcexchange01.amcc.com) ([10.64.18.50]) by sdcmail01-int1.amcc.com with ESMTP; 25 Aug 2009 11:27:21 -0700 Received: from amcc.com ([10.66.12.74]) by sdcexchange01.amcc.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 25 Aug 2009 11:27:21 -0700 Received: (from fkan@localhost) by amcc.com (8.13.8/8.12.2/Submit) id n7PIRKEP017536; Tue, 25 Aug 2009 11:27:20 -0700 From: Feng Kan To: linux-mtd@lists.infradead.org Subject: [PATCH 1/1] Fix ECC Correction bug for SMC ordering for NDFC driver. Date: Tue, 25 Aug 2009 11:27:20 -0700 Message-Id: <1251224840-17514-1-git-send-email-fkan@amcc.com> X-Mailer: git-send-email 1.5.5 In-Reply-To: References: X-OriginalArrivalTime: 25 Aug 2009 18:27:21.0721 (UTC) FILETIME=[AF7E4E90:01CA25B1] X-Spam-Score: 0.0 (/) Cc: Feng Kan X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 --- drivers/mtd/nand/ndfc.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c index 5906c40..d9d3e6e 100644 --- a/drivers/mtd/nand/ndfc.c +++ b/drivers/mtd/nand/ndfc.c @@ -101,8 +101,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;