From patchwork Tue Sep 29 21:11:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 524028 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5FE14140180 for ; Wed, 30 Sep 2015 07:14:47 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=O2uaaa1x; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zh2DC-0002yI-Fi; Tue, 29 Sep 2015 21:13:22 +0000 Received: from mail-pa0-x22b.google.com ([2607:f8b0:400e:c03::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zh2CV-0002vy-PC for linux-mtd@lists.infradead.org; Tue, 29 Sep 2015 21:12:40 +0000 Received: by pacfv12 with SMTP id fv12so16980057pac.2 for ; Tue, 29 Sep 2015 14:12:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=A58fo7uGUHdYBJQgQFeji3S+JtMrG7d4CJnbFKoBtxk=; b=O2uaaa1xkhBU76CKAgEXcFVnDd5zgYJ41QZ5LNsNwZ6yr3TGXwN14lpg2MrGY5rLKe cXb5/Ax5VeNQsyKRYIyxB20zdXQMrgLcC+ZdHx+Dy4xYr5R3c1GwdCIK/s8hIzPBYLkB QgOS7IBqDR4LoWc4GWPDfdqV3bh6jlxZUq/qdAwCSWdiF/CQvHM19WBWUd4JWp5AyaN5 2o2efDunTyzjfBbfRUZor2+sT7oWvulSTZjO7BhyIzTs97z359hh9wXGWi5+u+O/XnBq x7XTlUHT7verV6x6BsPrPyWdUVtRJDMoWJ2NBBNRNKooRjAeNSdVqSPreFcma5vpUgrA /qAw== X-Received: by 10.68.237.161 with SMTP id vd1mr145895pbc.168.1443561138925; Tue, 29 Sep 2015 14:12:18 -0700 (PDT) Received: from ban.mtv.corp.google.com ([172.22.64.120]) by smtp.gmail.com with ESMTPSA id rw8sm27448999pac.11.2015.09.29.14.12.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Sep 2015 14:12:18 -0700 (PDT) From: Brian Norris To: Subject: [RFC PATCH] mtd: nand: vf610_nfc: use nand_check_erased_ecc_chunk() helper Date: Tue, 29 Sep 2015 14:11:56 -0700 Message-Id: <1443561116-139851-1-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150929_141239_849402_7D2A9DAB X-CRM114-Status: GOOD ( 11.85 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c03:0:0:0:22b listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (computersforpeace[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Boris Brezillon , Brian Norris , Bill Pringlemeir , Stefan Agner MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Signed-off-by: Brian Norris Reviewed-by: Boris Brezillon --- I forgot about this feedback. How does this patch look? Just compile tested. drivers/mtd/nand/vf610_nfc.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c index 42dad8e4b26f..598faf655f5b 100644 --- a/drivers/mtd/nand/vf610_nfc.c +++ b/drivers/mtd/nand/vf610_nfc.c @@ -560,7 +560,6 @@ static inline int vf610_nfc_correct_data(struct mtd_info *mtd, uint8_t *dat, u32 ecc_status_off = NFC_MAIN_AREA(0) + ECC_SRAM_ADDR + ECC_STATUS; u8 ecc_status; u8 ecc_count; - int flips; int flips_threshold = nfc->chip.ecc.strength / 2; ecc_status = vf610_nfc_read(nfc, ecc_status_off) & 0xff; @@ -577,16 +576,9 @@ static inline int vf610_nfc_correct_data(struct mtd_info *mtd, uint8_t *dat, * On an erased page, bit count (including OOB) should be zero or * at least less then half of the ECC strength. */ - flips = count_written_bits(dat, nfc->chip.ecc.size, flips_threshold); - flips += count_written_bits(oob, mtd->oobsize, flips_threshold); - - if (unlikely(flips > flips_threshold)) - return -EINVAL; - - /* Erased page. */ - memset(dat, 0xff, nfc->chip.ecc.size); - memset(oob, 0xff, mtd->oobsize); - return flips; + return nand_check_erased_ecc_chunk(dat, nfc->chip.ecc.size, oob, + mtd->oobsize, NULL, 0, + flips_threshold); } static int vf610_nfc_read_page(struct mtd_info *mtd, struct nand_chip *chip,