[PATCH] at91_nand: control NCE signal
Atsushi Nemoto
anemo at mba.ocn.ne.jp
Sat Apr 26 12:51:12 EDT 2008
On Fri, 25 Apr 2008 22:54:08 +0200, "Andrew Victor" <avictor.za at gmail.com> wrote:
> > This driver did not control NCE signal during normal operations (only
> > enable NCE on probing and disable NCE on removing). This patch make
> > NCE signal inactive on idle state.
>
> It might be better to call the existing at91_nand_enable() and
> at91_nand_disable() functions.
> ie,
> if (ctrl & NAND_CTRL_CHANGE) {
> if (ctrl & NAND_NCE)
> at91_nand_enable(host)
> else
> at91_nand_disable(host);
> }
Well, it might be. I did not use at91_nand_enable/at91_nand_disable
just because they had been defined after at91_nand_cmd_ctrl() and they
were both very simple.
My patch already have been mainlined, so here is a patch against
latest linux-2.6 tree.
------------------------------------------------------
Subject: at91_nand: refactoring enable_pin manipulations
Use at91_nand_enable(), at91_nand_disable() to manipulate enable_pin.
No functional changes.
Signed-off-by: Atsushi Nemoto <anemo at mba.ocn.ne.jp>
---
drivers/mtd/nand/at91_nand.c | 42 +++++++++++++++++++++---------------------
1 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/drivers/mtd/nand/at91_nand.c b/drivers/mtd/nand/at91_nand.c
index 414ceae..0adb287 100644
--- a/drivers/mtd/nand/at91_nand.c
+++ b/drivers/mtd/nand/at91_nand.c
@@ -94,6 +94,24 @@ struct at91_nand_host {
};
/*
+ * Enable NAND.
+ */
+static void at91_nand_enable(struct at91_nand_host *host)
+{
+ if (host->board->enable_pin)
+ at91_set_gpio_value(host->board->enable_pin, 0);
+}
+
+/*
+ * Disable NAND.
+ */
+static void at91_nand_disable(struct at91_nand_host *host)
+{
+ if (host->board->enable_pin)
+ at91_set_gpio_value(host->board->enable_pin, 1);
+}
+
+/*
* Hardware specific access to control-lines
*/
static void at91_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
@@ -101,11 +119,11 @@ static void at91_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
struct nand_chip *nand_chip = mtd->priv;
struct at91_nand_host *host = nand_chip->priv;
- if (host->board->enable_pin && (ctrl & NAND_CTRL_CHANGE)) {
+ if (ctrl & NAND_CTRL_CHANGE) {
if (ctrl & NAND_NCE)
- at91_set_gpio_value(host->board->enable_pin, 0);
+ at91_nand_enable(host);
else
- at91_set_gpio_value(host->board->enable_pin, 1);
+ at91_nand_disable(host);
}
if (cmd == NAND_CMD_NONE)
return;
@@ -128,24 +146,6 @@ static int at91_nand_device_ready(struct mtd_info *mtd)
}
/*
- * Enable NAND.
- */
-static void at91_nand_enable(struct at91_nand_host *host)
-{
- if (host->board->enable_pin)
- at91_set_gpio_value(host->board->enable_pin, 0);
-}
-
-/*
- * Disable NAND.
- */
-static void at91_nand_disable(struct at91_nand_host *host)
-{
- if (host->board->enable_pin)
- at91_set_gpio_value(host->board->enable_pin, 1);
-}
-
-/*
* write oob for small pages
*/
static int at91_nand_write_oob_512(struct mtd_info *mtd,
More information about the linux-mtd
mailing list