From: Josh Wu Date: Wed, 7 Aug 2013 09:58:11 +0000 (+0800) Subject: mtd: atmel_nand: move the sanity check to the beginning of pmecc_enable() X-Git-Tag: next-20130822~69^2~55 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=e5829d0f5cdf6409fa5537462aba5f629238941d;p=karo-tx-linux.git 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. Signed-off-by: Josh Wu Signed-off-by: Brian Norris --- diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c index 1ffa52f7ab4a..0e365daad9cc 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);