diff options
author | John Crispin <john@phrozen.org> | 2016-06-20 17:32:09 -0400 |
---|---|---|
committer | Boris Brezillon <boris.brezillon@free-electrons.com> | 2016-07-11 02:40:15 -0400 |
commit | f45eb7b522359260606852d79a8899e5db37d8f3 (patch) | |
tree | 5e11a4959ee19d1c4f52c10a93f574b3867a2fd4 | |
parent | 024366750c2e04fdcda8bca685194ef0196b35fe (diff) |
mtd: nand: xway: Avoid messing up with IO_ADDR_W in ->cmd_ctrl()
The ->cmd_ctrl() function is adjusting the ->IO_ADDR_W value depending
on the command type each time NAND_CTRL_CHANGE is passed. This is not
only useless but can lead to an ->IO_ADDR_W corruption.
Get rid of this logic and rely on the NAND_CLE and NAND_ALE flags to
deduce the iomem address to write the cmd argument to.
Signed-off-by: John Crispin <john@phrozen.org>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
-rw-r--r-- | drivers/mtd/nand/xway_nand.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/drivers/mtd/nand/xway_nand.c b/drivers/mtd/nand/xway_nand.c index ec189e5b4459..6028edbad644 100644 --- a/drivers/mtd/nand/xway_nand.c +++ b/drivers/mtd/nand/xway_nand.c | |||
@@ -107,22 +107,18 @@ static void xway_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) | |||
107 | unsigned long nandaddr = (unsigned long) this->IO_ADDR_W; | 107 | unsigned long nandaddr = (unsigned long) this->IO_ADDR_W; |
108 | unsigned long flags; | 108 | unsigned long flags; |
109 | 109 | ||
110 | if (ctrl & NAND_CTRL_CHANGE) { | 110 | if (cmd == NAND_CMD_NONE) |
111 | nandaddr &= ~(NAND_WRITE_CMD | NAND_WRITE_ADDR); | 111 | return; |
112 | if (ctrl & NAND_CLE) | ||
113 | nandaddr |= NAND_WRITE_CMD; | ||
114 | else | ||
115 | nandaddr |= NAND_WRITE_ADDR; | ||
116 | this->IO_ADDR_W = (void __iomem *) nandaddr; | ||
117 | } | ||
118 | 112 | ||
119 | if (cmd != NAND_CMD_NONE) { | 113 | spin_lock_irqsave(&ebu_lock, flags); |
120 | spin_lock_irqsave(&ebu_lock, flags); | 114 | if (ctrl & NAND_CLE) |
121 | writeb(cmd, this->IO_ADDR_W); | 115 | writeb(cmd, (void __iomem *) (nandaddr | NAND_WRITE_CMD)); |
122 | while ((ltq_ebu_r32(EBU_NAND_WAIT) & NAND_WAIT_WR_C) == 0) | 116 | else if (ctrl & NAND_ALE) |
123 | ; | 117 | writeb(cmd, (void __iomem *) (nandaddr | NAND_WRITE_ADDR)); |
124 | spin_unlock_irqrestore(&ebu_lock, flags); | 118 | |
125 | } | 119 | while ((ltq_ebu_r32(EBU_NAND_WAIT) & NAND_WAIT_WR_C) == 0) |
120 | ; | ||
121 | spin_unlock_irqrestore(&ebu_lock, flags); | ||
126 | } | 122 | } |
127 | 123 | ||
128 | static int xway_dev_ready(struct mtd_info *mtd) | 124 | static int xway_dev_ready(struct mtd_info *mtd) |