d3e8b7956821f7e6964b5926a5746e32cf484565
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / patches-2.6.30 / 108-mtd_fix_cfi_cmdset_0002_status_check.patch
1 --- a/drivers/mtd/chips/cfi_cmdset_0002.c
2 +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
3 @@ -39,7 +39,7 @@
4 #include <linux/mtd/xip.h>
5
6 #define AMD_BOOTLOC_BUG
7 -#define FORCE_WORD_WRITE 0
8 +#define FORCE_WORD_WRITE 1
9
10 #define MAX_WORD_RETRIES 3
11
12 @@ -190,6 +190,7 @@ static void fixup_amd_bootblock(struct m
13 }
14 #endif
15
16 +#if !FORCE_WORD_WRITE
17 static void fixup_use_write_buffers(struct mtd_info *mtd, void *param)
18 {
19 struct map_info *map = mtd->priv;
20 @@ -199,6 +200,7 @@ static void fixup_use_write_buffers(stru
21 mtd->write = cfi_amdstd_write_buffers;
22 }
23 }
24 +#endif
25
26 /* Atmel chips don't use the same PRI format as AMD chips */
27 static void fixup_convert_atmel_pri(struct mtd_info *mtd, void *param)
28 @@ -1152,8 +1154,8 @@ static int __xipram do_write_oneword(str
29 break;
30 }
31
32 - if (chip_ready(map, adr))
33 - break;
34 + if (chip_good(map, adr, datum))
35 + goto enable_xip;
36
37 /* Latency issues. Drop the lock, wait a while and retry */
38 UDELAY(map, chip, adr, 1);
39 @@ -1169,6 +1171,8 @@ static int __xipram do_write_oneword(str
40
41 ret = -EIO;
42 }
43 +
44 + enable_xip:
45 xip_enable(map, chip, adr);
46 op_done:
47 chip->state = FL_READY;
48 @@ -1436,6 +1440,7 @@ static int __xipram do_write_buffer(stru
49 }
50
51
52 +#if !FORCE_WORD_WRITE
53 static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len,
54 size_t *retlen, const u_char *buf)
55 {
56 @@ -1514,7 +1519,7 @@ static int cfi_amdstd_write_buffers(stru
57
58 return 0;
59 }
60 -
61 +#endif
62
63 /*
64 * Handle devices with one erase region, that only implement
65 @@ -1579,8 +1584,8 @@ static int __xipram do_erase_chip(struct
66 chip->erase_suspended = 0;
67 }
68
69 - if (chip_ready(map, adr))
70 - break;
71 + if (chip_good(map, adr, map_word_ff(map)))
72 + goto op_done;
73
74 if (time_after(jiffies, timeo)) {
75 printk(KERN_WARNING "MTD %s(): software timeout\n",
76 @@ -1600,6 +1605,7 @@ static int __xipram do_erase_chip(struct
77 ret = -EIO;
78 }
79
80 + op_done:
81 chip->state = FL_READY;
82 xip_enable(map, chip, adr);
83 put_chip(map, chip, adr);
84 @@ -1667,9 +1673,9 @@ static int __xipram do_erase_oneblock(st
85 chip->erase_suspended = 0;
86 }
87
88 - if (chip_ready(map, adr)) {
89 + if (chip_good(map, adr, map_word_ff(map))) {
90 xip_enable(map, chip, adr);
91 - break;
92 + goto op_done;
93 }
94
95 if (time_after(jiffies, timeo)) {
96 @@ -1691,6 +1697,7 @@ static int __xipram do_erase_oneblock(st
97 ret = -EIO;
98 }
99
100 + op_done:
101 chip->state = FL_READY;
102 put_chip(map, chip, adr);
103 spin_unlock(chip->mutex);