diff mbox

[RFC,1/2] mtd: nand: clean nand_write_subpage_hwecc to reduce local variables

Message ID 1404124441-26038-2-git-send-email-pekon@ti.com
State RFC
Headers show

Commit Message

pekon gupta June 30, 2014, 10:34 a.m. UTC
Use 'struct nand_ecc_ctrl *' instead of 'struct nand_chip *' for de-referenceing
ECC variables.

Signed-off-by: Pekon Gupta <pekon@ti.com>
---
 drivers/mtd/nand/nand_base.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
diff mbox

Patch

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 */