From patchwork Wed May 2 09:41:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastian Hecht X-Patchwork-Id: 156403 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D998DB6FB7 for ; Wed, 2 May 2012 19:44:23 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SPW5R-0008CR-E2; Wed, 02 May 2012 09:43:05 +0000 Received: from mail-bk0-f49.google.com ([209.85.214.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SPW50-000846-38 for linux-mtd@lists.infradead.org; Wed, 02 May 2012 09:42:38 +0000 Received: by mail-bk0-f49.google.com with SMTP id j4so343202bkw.36 for ; Wed, 02 May 2012 02:42:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=/REt0tIe1Q7Mui373t9kL4WYamSMBSxEvJ73Vx2+xqQ=; b=VFR6S1dk3fjWqtZ1Hv/blHoOWjwUS8hhjAvrwBJ8rrWaINA86WV6//U/5NPMz5QaB/ PGrPw7l+1hYFNDFEdaVy0IWNUytofIMVWwP5alAgXMTCSIsj9o6xZ8uwpceExzWndE6h QXWH7zh/9SNIXEC3q8/0dxPvQeF+Nc7cqTmHTejx+tPzXTVBE3tzK7f0G7aGmD7N2Qwn STWG+NiBj/gVlLoOnV0UgL52UDV2YXG1W3atO09dNGsjXKJyCEHhNRCRAn7dKTVFuYwa HA1p++e/cZGQsU+2wlvieCEh1dozmWMETnmj65WLRv1dl9dEMVHnkVBUF0ULZ9atHArn gIEw== Received: by 10.204.141.18 with SMTP id k18mr6524132bku.27.1335951757681; Wed, 02 May 2012 02:42:37 -0700 (PDT) Received: from localhost.localdomain ([176.74.57.22]) by mx.google.com with ESMTPS id e20sm2362194bkv.10.2012.05.02.02.42.36 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 02 May 2012 02:42:37 -0700 (PDT) From: Bastian Hecht To: linux-mtd@lists.infradead.org, linux-sh@vger.kernel.org Subject: [PATCH v3 06/10] mtd: sh_flctl: Simplify the hardware ecc page read/write Date: Wed, 2 May 2012 11:41:46 +0200 Message-Id: <1335951710-9390-7-git-send-email-hechtb@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1335951710-9390-1-git-send-email-hechtb@gmail.com> References: <1335951710-9390-1-git-send-email-hechtb@gmail.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.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 [209.85.214.49 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (hechtb[at]googlemail.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 Cc: Brian Norris , Magnus Damm , Laurent Pichart , Artem Bityutskiy X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 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 As the equation mtd->writesize == eccsteps * eccsize holds, we can simplify the code. The second loop of the 1st hunk is never entered, so we delete it. Signed-off-by: Bastian Hecht --- drivers/mtd/nand/sh_flctl.c | 25 ++----------------------- 1 files changed, 2 insertions(+), 23 deletions(-) diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c index 4ea3e20..b0389c5 100644 --- a/drivers/mtd/nand/sh_flctl.c +++ b/drivers/mtd/nand/sh_flctl.c @@ -346,35 +346,14 @@ static void set_cmd_regs(struct mtd_info *mtd, uint32_t cmd, uint32_t flcmcdr_va static int flctl_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, uint8_t *buf, int page) { - int i, eccsize = chip->ecc.size; - int eccbytes = chip->ecc.bytes; - int eccsteps = chip->ecc.steps; - uint8_t *p = buf; - struct sh_flctl *flctl = mtd_to_flctl(mtd); - - for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) - chip->read_buf(mtd, p, eccsize); - - for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) { - if (flctl->hwecc_cant_correct[i]) - mtd->ecc_stats.failed++; - else - mtd->ecc_stats.corrected += 0; /* FIXME */ - } - + chip->read_buf(mtd, buf, mtd->writesize); return 0; } static void flctl_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, const uint8_t *buf) { - int i, eccsize = chip->ecc.size; - int eccbytes = chip->ecc.bytes; - int eccsteps = chip->ecc.steps; - const uint8_t *p = buf; - - for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) - chip->write_buf(mtd, p, eccsize); + chip->write_buf(mtd, buf, mtd->writesize); } static void execmd_read_page_sector(struct mtd_info *mtd, int page_addr)