linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: atmel_nand: move the sanity check to the beginning of pmecc_enable()
@ 2013-08-07  9:58 Josh Wu
  2013-08-08  6:24 ` Brian Norris
  0 siblings, 1 reply; 2+ messages in thread
From: Josh Wu @ 2013-08-07  9:58 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Josh Wu <josh.wu@atmel.com>
---
 drivers/mtd/nand/atmel_nand.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 1ffa52f..0e365da 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -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);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-08-08  6:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-07  9:58 [PATCH] mtd: atmel_nand: move the sanity check to the beginning of pmecc_enable() Josh Wu
2013-08-08  6:24 ` Brian Norris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).