From patchwork Mon Jun 30 10:34:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pekon gupta X-Patchwork-Id: 365537 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-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BA8CD14007B for ; Mon, 30 Jun 2014 20:36:09 +1000 (EST) 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 1X1Yv9-0007bO-Ds; Mon, 30 Jun 2014 10:34:47 +0000 Received: from comal.ext.ti.com ([198.47.26.152]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X1Yv2-0007TX-PK for linux-mtd@lists.infradead.org; Mon, 30 Jun 2014 10:34:42 +0000 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s5UAYGjx005542; Mon, 30 Jun 2014 05:34:16 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5UAYG2k015449; Mon, 30 Jun 2014 05:34:16 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Mon, 30 Jun 2014 05:34:16 -0500 Received: from psplinux063.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5UAYBBG014059; Mon, 30 Jun 2014 05:34:14 -0500 From: Pekon Gupta To: Brian Norris Subject: [RFC PATCH 1/2] mtd: nand: clean nand_write_subpage_hwecc to reduce local variables Date: Mon, 30 Jun 2014 16:04:00 +0530 Message-ID: <1404124441-26038-2-git-send-email-pekon@ti.com> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 In-Reply-To: <1404124441-26038-1-git-send-email-pekon@ti.com> References: <1404124441-26038-1-git-send-email-pekon@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140630_033440_905367_0573099D X-CRM114-Status: UNSURE ( 9.31 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [198.47.26.152 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [198.47.26.152 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: linux-mtd , Pekon Gupta , Ezequiel Garcia , Artem Bityutskiy X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Use 'struct nand_ecc_ctrl *' instead of 'struct nand_chip *' for de-referenceing ECC variables. Signed-off-by: Pekon Gupta --- drivers/mtd/nand/nand_base.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index c5c1b1f..fdbd8c6 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -2106,25 +2106,23 @@ static int nand_write_subpage_hwecc(struct mtd_info *mtd, { uint8_t *oob_buf = chip->oob_poi; uint8_t *ecc_calc = chip->buffers->ecccalc; - int ecc_size = chip->ecc.size; - int ecc_bytes = chip->ecc.bytes; - int ecc_steps = chip->ecc.steps; + struct nand_ecc_ctrl *ecc = &chip->ecc; uint32_t *eccpos = chip->ecc.layout->eccpos; - uint32_t start_step = offset / ecc_size; - uint32_t end_step = (offset + data_len - 1) / ecc_size; - int oob_bytes = mtd->oobsize / ecc_steps; + uint32_t start_step = offset / ecc->size; + uint32_t end_step = (offset + data_len - 1) / ecc->size; + int oob_bytes = mtd->oobsize / ecc->steps; int step, i; - for (step = 0; step < ecc_steps; step++) { + for (step = 0; step < ecc->steps; step++) { /* configure controller for WRITE access */ chip->ecc.hwctl(mtd, NAND_ECC_WRITE); /* write data (untouched subpages already masked by 0xFF) */ - chip->write_buf(mtd, buf, ecc_size); + chip->write_buf(mtd, buf, ecc->size); /* mask ECC of un-touched subpages by padding 0xFF */ if ((step < start_step) || (step > end_step)) - memset(ecc_calc, 0xff, ecc_bytes); + memset(ecc_calc, 0xff, ecc->bytes); else chip->ecc.calculate(mtd, buf, ecc_calc); @@ -2133,9 +2131,9 @@ static int nand_write_subpage_hwecc(struct mtd_info *mtd, if (!oob_required || (step < start_step) || (step > end_step)) memset(oob_buf, 0xff, oob_bytes); - buf += ecc_size; - ecc_calc += ecc_bytes; - oob_buf += oob_bytes; + buf += ecc->size; + ecc_calc += ecc->bytes; + oob_buf += oob_bytes; } /* copy calculated ECC for whole page to chip->buffer->oob */