Skip to contentSkip to conversation

mtd: atmel_nand: move the sanity check to the beginning of pmecc_enable()

PATCH New Josh Wu 2 participants 2 messages Aug 7, 2013 – Aug 8, 2013

Subsystems (3)
lore
Share & tools
lore

Josh Wu

author
#0 lore raw

PATCH 1/1 mtd: atmel_nand: move the sanity check to the beginning of pmecc_enable()

It is better to do the sanity check for the parameter before any hardware operation.

---
 drivers/mtd/nand/atmel_nand.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mtd/nand/atmel_nand.c +4 -4
index 1ffa52f..0e365da 100644
@@ -905,15 +905,15 @@ static void pmecc_enable(struct atmel_nand_host *host, int ecc_op)
 {
 	u32 val;
 
-	pmecc_writel(host->ecc, CTRL, PMECC_CTRL_RST);
-	pmecc_writel(host->ecc, CTRL, PMECC_CTRL_DISABLE);
-	val = pmecc_readl_relaxed(host->ecc, CFG);
-
 	if (ecc_op != NAND_ECC_READ && ecc_op != NAND_ECC_WRITE) {
 		dev_err(host->dev, "atmel_nand: wrong pmecc operation type!");
 		return;
 	}
 
+	pmecc_writel(host->ecc, CTRL, PMECC_CTRL_RST);
+	pmecc_writel(host->ecc, CTRL, PMECC_CTRL_DISABLE);
+	val = pmecc_readl_relaxed(host->ecc, CFG);
+
 	if (ecc_op == NAND_ECC_READ)
 		pmecc_writel(host->ecc, CFG, (val & ~PMECC_CFG_WRITE_OP)
 			| PMECC_CFG_AUTO_ENABLE);
Signature · 1 line
1.7.9.5
Applied
#1 lore raw

PATCH 1/1 mtd: atmel_nand: move the sanity check to the beginning of pmecc_enable()

Quoted 4 lines · Josh Wu

It is better to do the sanity check for the parameter before any hardware operation.

Pushed to l2-mtd.git. I would squash it into the original patch, but David has already taken it into his tree. I'll leave it up to him, then.

Thanks,
Brian