linux-dm8000: add nand flash driver fix (this fixes mtd/jffs2 ecc error messages...
[vuplus_openembedded] / recipes / linux / linux-dm8000-2.6.18 / linux-2.6.18-dm8000-nand-smp-fix.patch
1 --- linux-2.6.18-org/drivers/mtd/nand/dm8000_nand.c     2010-10-18 22:40:58.000000000 +0200
2 +++ linux-2.6.18/drivers/mtd/nand/dm8000_nand.c 2011-02-09 19:23:15.808489533 +0100
3 @@ -16,6 +16,7 @@
4   *
5   */
6  
7 +#include <linux/delay.h>
8  #include <linux/jiffies.h>
9  #include <linux/slab.h>
10  #include <linux/module.h>
11 @@ -61,16 +62,24 @@
12  };
13  #define NUM_PARTITIONS 7
14  
15 +static int dm8000_nand_dev_ready(struct mtd_info *mtd);
16 +
17  static void dm8000_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
18  {
19 -       if (ctrl & NAND_CTRL_CHANGE) {
20 -               if (!(ctrl & NAND_NCE))
21 -                       writeb(0, (void __iomem *)0xBF030003);
22 -               //else
23 -               //      readb((void __iomem *)0xBF030002);
24 -       }
25 -       if (cmd == NAND_CMD_NONE)
26 +       if (ctrl & NAND_CTRL_CHANGE && !(ctrl & NAND_NCE))
27 +               writeb(0, (void __iomem *)0xBF030003);
28 +
29 +       if (cmd == NAND_CMD_NONE) {
30 +#ifdef CONFIG_SMP
31 +               struct nand_chip *this = (struct nand_chip *)(dm8000_mtd+1);
32 +               int cnt=0;
33 +               while (cnt < this->chip_delay && !dm8000_nand_dev_ready(mtd)) {
34 +                       ++cnt;
35 +                       udelay(1);
36 +               }
37 +#endif
38                 return;
39 +       }
40  
41         if (ctrl & NAND_CLE)
42                 writeb(cmd, (void __iomem *)0xBF030000);