aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/chips/cfi_cmdset_0020.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2005-11-07 06:15:37 -0500
committerThomas Gleixner <tglx@mtd.linutronix.de>2005-11-07 08:45:15 -0500
commit1f948b43f7b5cf721cf0d03f507843efc1a9bfad (patch)
tree58f9f4b1baa374ee80f2641a44f87b361a628e6d /drivers/mtd/chips/cfi_cmdset_0020.c
parente4f0648fb400a05adb7c640ce8766a7011d472d3 (diff)
[MTD] chips: Clean up trailing white spaces
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/mtd/chips/cfi_cmdset_0020.c')
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0020.c172
1 files changed, 86 insertions, 86 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
index d22df2d96788..39e3c2d9441f 100644
--- a/drivers/mtd/chips/cfi_cmdset_0020.c
+++ b/drivers/mtd/chips/cfi_cmdset_0020.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * (C) 2000 Red Hat. GPL'd 5 * (C) 2000 Red Hat. GPL'd
6 * 6 *
7 * $Id: cfi_cmdset_0020.c,v 1.20 2005/07/20 21:01:14 tpoynor Exp $ 7 * $Id: cfi_cmdset_0020.c,v 1.22 2005/11/07 11:14:22 gleixner Exp $
8 * 8 *
9 * 10/10/2000 Nicolas Pitre <nico@cam.org> 9 * 10/10/2000 Nicolas Pitre <nico@cam.org>
10 * - completely revamped method functions so they are aware and 10 * - completely revamped method functions so they are aware and
@@ -81,17 +81,17 @@ static void cfi_tell_features(struct cfi_pri_intelext *extp)
81 printk(" - Page-mode read: %s\n", extp->FeatureSupport&128?"supported":"unsupported"); 81 printk(" - Page-mode read: %s\n", extp->FeatureSupport&128?"supported":"unsupported");
82 printk(" - Synchronous read: %s\n", extp->FeatureSupport&256?"supported":"unsupported"); 82 printk(" - Synchronous read: %s\n", extp->FeatureSupport&256?"supported":"unsupported");
83 for (i=9; i<32; i++) { 83 for (i=9; i<32; i++) {
84 if (extp->FeatureSupport & (1<<i)) 84 if (extp->FeatureSupport & (1<<i))
85 printk(" - Unknown Bit %X: supported\n", i); 85 printk(" - Unknown Bit %X: supported\n", i);
86 } 86 }
87 87
88 printk(" Supported functions after Suspend: %2.2X\n", extp->SuspendCmdSupport); 88 printk(" Supported functions after Suspend: %2.2X\n", extp->SuspendCmdSupport);
89 printk(" - Program after Erase Suspend: %s\n", extp->SuspendCmdSupport&1?"supported":"unsupported"); 89 printk(" - Program after Erase Suspend: %s\n", extp->SuspendCmdSupport&1?"supported":"unsupported");
90 for (i=1; i<8; i++) { 90 for (i=1; i<8; i++) {
91 if (extp->SuspendCmdSupport & (1<<i)) 91 if (extp->SuspendCmdSupport & (1<<i))
92 printk(" - Unknown Bit %X: supported\n", i); 92 printk(" - Unknown Bit %X: supported\n", i);
93 } 93 }
94 94
95 printk(" Block Status Register Mask: %4.4X\n", extp->BlkStatusRegMask); 95 printk(" Block Status Register Mask: %4.4X\n", extp->BlkStatusRegMask);
96 printk(" - Lock Bit Active: %s\n", extp->BlkStatusRegMask&1?"yes":"no"); 96 printk(" - Lock Bit Active: %s\n", extp->BlkStatusRegMask&1?"yes":"no");
97 printk(" - Valid Bit Active: %s\n", extp->BlkStatusRegMask&2?"yes":"no"); 97 printk(" - Valid Bit Active: %s\n", extp->BlkStatusRegMask&2?"yes":"no");
@@ -99,11 +99,11 @@ static void cfi_tell_features(struct cfi_pri_intelext *extp)
99 if (extp->BlkStatusRegMask & (1<<i)) 99 if (extp->BlkStatusRegMask & (1<<i))
100 printk(" - Unknown Bit %X Active: yes\n",i); 100 printk(" - Unknown Bit %X Active: yes\n",i);
101 } 101 }
102 102
103 printk(" Vcc Logic Supply Optimum Program/Erase Voltage: %d.%d V\n", 103 printk(" Vcc Logic Supply Optimum Program/Erase Voltage: %d.%d V\n",
104 extp->VccOptimal >> 8, extp->VccOptimal & 0xf); 104 extp->VccOptimal >> 8, extp->VccOptimal & 0xf);
105 if (extp->VppOptimal) 105 if (extp->VppOptimal)
106 printk(" Vpp Programming Supply Optimum Program/Erase Voltage: %d.%d V\n", 106 printk(" Vpp Programming Supply Optimum Program/Erase Voltage: %d.%d V\n",
107 extp->VppOptimal >> 8, extp->VppOptimal & 0xf); 107 extp->VppOptimal >> 8, extp->VppOptimal & 0xf);
108} 108}
109#endif 109#endif
@@ -121,7 +121,7 @@ struct mtd_info *cfi_cmdset_0020(struct map_info *map, int primary)
121 int i; 121 int i;
122 122
123 if (cfi->cfi_mode) { 123 if (cfi->cfi_mode) {
124 /* 124 /*
125 * It's a real CFI chip, not one for which the probe 125 * It's a real CFI chip, not one for which the probe
126 * routine faked a CFI structure. So we read the feature 126 * routine faked a CFI structure. So we read the feature
127 * table from it. 127 * table from it.
@@ -145,21 +145,21 @@ struct mtd_info *cfi_cmdset_0020(struct map_info *map, int primary)
145 /* Do some byteswapping if necessary */ 145 /* Do some byteswapping if necessary */
146 extp->FeatureSupport = cfi32_to_cpu(extp->FeatureSupport); 146 extp->FeatureSupport = cfi32_to_cpu(extp->FeatureSupport);
147 extp->BlkStatusRegMask = cfi32_to_cpu(extp->BlkStatusRegMask); 147 extp->BlkStatusRegMask = cfi32_to_cpu(extp->BlkStatusRegMask);
148 148
149#ifdef DEBUG_CFI_FEATURES 149#ifdef DEBUG_CFI_FEATURES
150 /* Tell the user about it in lots of lovely detail */ 150 /* Tell the user about it in lots of lovely detail */
151 cfi_tell_features(extp); 151 cfi_tell_features(extp);
152#endif 152#endif
153 153
154 /* Install our own private info structure */ 154 /* Install our own private info structure */
155 cfi->cmdset_priv = extp; 155 cfi->cmdset_priv = extp;
156 } 156 }
157 157
158 for (i=0; i< cfi->numchips; i++) { 158 for (i=0; i< cfi->numchips; i++) {
159 cfi->chips[i].word_write_time = 128; 159 cfi->chips[i].word_write_time = 128;
160 cfi->chips[i].buffer_write_time = 128; 160 cfi->chips[i].buffer_write_time = 128;
161 cfi->chips[i].erase_time = 1024; 161 cfi->chips[i].erase_time = 1024;
162 } 162 }
163 163
164 return cfi_staa_setup(map); 164 return cfi_staa_setup(map);
165} 165}
@@ -187,15 +187,15 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
187 mtd->size = devsize * cfi->numchips; 187 mtd->size = devsize * cfi->numchips;
188 188
189 mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips; 189 mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips;
190 mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) 190 mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info)
191 * mtd->numeraseregions, GFP_KERNEL); 191 * mtd->numeraseregions, GFP_KERNEL);
192 if (!mtd->eraseregions) { 192 if (!mtd->eraseregions) {
193 printk(KERN_ERR "Failed to allocate memory for MTD erase region info\n"); 193 printk(KERN_ERR "Failed to allocate memory for MTD erase region info\n");
194 kfree(cfi->cmdset_priv); 194 kfree(cfi->cmdset_priv);
195 kfree(mtd); 195 kfree(mtd);
196 return NULL; 196 return NULL;
197 } 197 }
198 198
199 for (i=0; i<cfi->cfiq->NumEraseRegions; i++) { 199 for (i=0; i<cfi->cfiq->NumEraseRegions; i++) {
200 unsigned long ernum, ersize; 200 unsigned long ernum, ersize;
201 ersize = ((cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff) * cfi->interleave; 201 ersize = ((cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff) * cfi->interleave;
@@ -228,7 +228,7 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
228 mtd->eraseregions[i].numblocks); 228 mtd->eraseregions[i].numblocks);
229 } 229 }
230 230
231 /* Also select the correct geometry setup too */ 231 /* Also select the correct geometry setup too */
232 mtd->erase = cfi_staa_erase_varsize; 232 mtd->erase = cfi_staa_erase_varsize;
233 mtd->read = cfi_staa_read; 233 mtd->read = cfi_staa_read;
234 mtd->write = cfi_staa_write_buffers; 234 mtd->write = cfi_staa_write_buffers;
@@ -259,8 +259,8 @@ static inline int do_read_onechip(struct map_info *map, struct flchip *chip, lof
259 259
260 adr += chip->start; 260 adr += chip->start;
261 261
262 /* Ensure cmd read/writes are aligned. */ 262 /* Ensure cmd read/writes are aligned. */
263 cmd_addr = adr & ~(map_bankwidth(map)-1); 263 cmd_addr = adr & ~(map_bankwidth(map)-1);
264 264
265 /* Let's determine this according to the interleave only once */ 265 /* Let's determine this according to the interleave only once */
266 status_OK = CMD(0x80); 266 status_OK = CMD(0x80);
@@ -276,7 +276,7 @@ static inline int do_read_onechip(struct map_info *map, struct flchip *chip, lof
276 case FL_ERASING: 276 case FL_ERASING:
277 if (!(((struct cfi_pri_intelext *)cfi->cmdset_priv)->FeatureSupport & 2)) 277 if (!(((struct cfi_pri_intelext *)cfi->cmdset_priv)->FeatureSupport & 2))
278 goto sleep; /* We don't support erase suspend */ 278 goto sleep; /* We don't support erase suspend */
279 279
280 map_write (map, CMD(0xb0), cmd_addr); 280 map_write (map, CMD(0xb0), cmd_addr);
281 /* If the flash has finished erasing, then 'erase suspend' 281 /* If the flash has finished erasing, then 'erase suspend'
282 * appears to make some (28F320) flash devices switch to 282 * appears to make some (28F320) flash devices switch to
@@ -291,7 +291,7 @@ static inline int do_read_onechip(struct map_info *map, struct flchip *chip, lof
291 status = map_read(map, cmd_addr); 291 status = map_read(map, cmd_addr);
292 if (map_word_andequal(map, status, status_OK, status_OK)) 292 if (map_word_andequal(map, status, status_OK, status_OK))
293 break; 293 break;
294 294
295 if (time_after(jiffies, timeo)) { 295 if (time_after(jiffies, timeo)) {
296 /* Urgh */ 296 /* Urgh */
297 map_write(map, CMD(0xd0), cmd_addr); 297 map_write(map, CMD(0xd0), cmd_addr);
@@ -303,17 +303,17 @@ static inline int do_read_onechip(struct map_info *map, struct flchip *chip, lof
303 "suspended: status = 0x%lx\n", status.x[0]); 303 "suspended: status = 0x%lx\n", status.x[0]);
304 return -EIO; 304 return -EIO;
305 } 305 }
306 306
307 spin_unlock_bh(chip->mutex); 307 spin_unlock_bh(chip->mutex);
308 cfi_udelay(1); 308 cfi_udelay(1);
309 spin_lock_bh(chip->mutex); 309 spin_lock_bh(chip->mutex);
310 } 310 }
311 311
312 suspended = 1; 312 suspended = 1;
313 map_write(map, CMD(0xff), cmd_addr); 313 map_write(map, CMD(0xff), cmd_addr);
314 chip->state = FL_READY; 314 chip->state = FL_READY;
315 break; 315 break;
316 316
317#if 0 317#if 0
318 case FL_WRITING: 318 case FL_WRITING:
319 /* Not quite yet */ 319 /* Not quite yet */
@@ -334,7 +334,7 @@ static inline int do_read_onechip(struct map_info *map, struct flchip *chip, lof
334 chip->state = FL_READY; 334 chip->state = FL_READY;
335 break; 335 break;
336 } 336 }
337 337
338 /* Urgh. Chip not yet ready to talk to us. */ 338 /* Urgh. Chip not yet ready to talk to us. */
339 if (time_after(jiffies, timeo)) { 339 if (time_after(jiffies, timeo)) {
340 spin_unlock_bh(chip->mutex); 340 spin_unlock_bh(chip->mutex);
@@ -364,17 +364,17 @@ static inline int do_read_onechip(struct map_info *map, struct flchip *chip, lof
364 364
365 if (suspended) { 365 if (suspended) {
366 chip->state = chip->oldstate; 366 chip->state = chip->oldstate;
367 /* What if one interleaved chip has finished and the 367 /* What if one interleaved chip has finished and the
368 other hasn't? The old code would leave the finished 368 other hasn't? The old code would leave the finished
369 one in READY mode. That's bad, and caused -EROFS 369 one in READY mode. That's bad, and caused -EROFS
370 errors to be returned from do_erase_oneblock because 370 errors to be returned from do_erase_oneblock because
371 that's the only bit it checked for at the time. 371 that's the only bit it checked for at the time.
372 As the state machine appears to explicitly allow 372 As the state machine appears to explicitly allow
373 sending the 0x70 (Read Status) command to an erasing 373 sending the 0x70 (Read Status) command to an erasing
374 chip and expecting it to be ignored, that's what we 374 chip and expecting it to be ignored, that's what we
375 do. */ 375 do. */
376 map_write(map, CMD(0xd0), cmd_addr); 376 map_write(map, CMD(0xd0), cmd_addr);
377 map_write(map, CMD(0x70), cmd_addr); 377 map_write(map, CMD(0x70), cmd_addr);
378 } 378 }
379 379
380 wake_up(&chip->wq); 380 wake_up(&chip->wq);
@@ -414,14 +414,14 @@ static int cfi_staa_read (struct mtd_info *mtd, loff_t from, size_t len, size_t
414 *retlen += thislen; 414 *retlen += thislen;
415 len -= thislen; 415 len -= thislen;
416 buf += thislen; 416 buf += thislen;
417 417
418 ofs = 0; 418 ofs = 0;
419 chipnum++; 419 chipnum++;
420 } 420 }
421 return ret; 421 return ret;
422} 422}
423 423
424static inline int do_write_buffer(struct map_info *map, struct flchip *chip, 424static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
425 unsigned long adr, const u_char *buf, int len) 425 unsigned long adr, const u_char *buf, int len)
426{ 426{
427 struct cfi_private *cfi = map->fldrv_priv; 427 struct cfi_private *cfi = map->fldrv_priv;
@@ -429,7 +429,7 @@ static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
429 unsigned long cmd_adr, timeo; 429 unsigned long cmd_adr, timeo;
430 DECLARE_WAITQUEUE(wait, current); 430 DECLARE_WAITQUEUE(wait, current);
431 int wbufsize, z; 431 int wbufsize, z;
432 432
433 /* M58LW064A requires bus alignment for buffer wriets -- saw */ 433 /* M58LW064A requires bus alignment for buffer wriets -- saw */
434 if (adr & (map_bankwidth(map)-1)) 434 if (adr & (map_bankwidth(map)-1))
435 return -EINVAL; 435 return -EINVAL;
@@ -437,10 +437,10 @@ static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
437 wbufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize; 437 wbufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize;
438 adr += chip->start; 438 adr += chip->start;
439 cmd_adr = adr & ~(wbufsize-1); 439 cmd_adr = adr & ~(wbufsize-1);
440 440
441 /* Let's determine this according to the interleave only once */ 441 /* Let's determine this according to the interleave only once */
442 status_OK = CMD(0x80); 442 status_OK = CMD(0x80);
443 443
444 timeo = jiffies + HZ; 444 timeo = jiffies + HZ;
445 retry: 445 retry:
446 446
@@ -448,7 +448,7 @@ static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
448 printk("%s: chip->state[%d]\n", __FUNCTION__, chip->state); 448 printk("%s: chip->state[%d]\n", __FUNCTION__, chip->state);
449#endif 449#endif
450 spin_lock_bh(chip->mutex); 450 spin_lock_bh(chip->mutex);
451 451
452 /* Check that the chip's ready to talk to us. 452 /* Check that the chip's ready to talk to us.
453 * Later, we can actually think about interrupting it 453 * Later, we can actually think about interrupting it
454 * if it's in FL_ERASING state. 454 * if it's in FL_ERASING state.
@@ -457,7 +457,7 @@ static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
457 switch (chip->state) { 457 switch (chip->state) {
458 case FL_READY: 458 case FL_READY:
459 break; 459 break;
460 460
461 case FL_CFI_QUERY: 461 case FL_CFI_QUERY:
462 case FL_JEDEC_QUERY: 462 case FL_JEDEC_QUERY:
463 map_write(map, CMD(0x70), cmd_adr); 463 map_write(map, CMD(0x70), cmd_adr);
@@ -522,7 +522,7 @@ static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
522 522
523 /* Write length of data to come */ 523 /* Write length of data to come */
524 map_write(map, CMD(len/map_bankwidth(map)-1), cmd_adr ); 524 map_write(map, CMD(len/map_bankwidth(map)-1), cmd_adr );
525 525
526 /* Write data */ 526 /* Write data */
527 for (z = 0; z < len; 527 for (z = 0; z < len;
528 z += map_bankwidth(map), buf += map_bankwidth(map)) { 528 z += map_bankwidth(map), buf += map_bankwidth(map)) {
@@ -569,7 +569,7 @@ static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
569 printk(KERN_ERR "waiting for chip to be ready timed out in bufwrite\n"); 569 printk(KERN_ERR "waiting for chip to be ready timed out in bufwrite\n");
570 return -EIO; 570 return -EIO;
571 } 571 }
572 572
573 /* Latency issues. Drop the lock, wait a while and retry */ 573 /* Latency issues. Drop the lock, wait a while and retry */
574 spin_unlock_bh(chip->mutex); 574 spin_unlock_bh(chip->mutex);
575 cfi_udelay(1); 575 cfi_udelay(1);
@@ -581,9 +581,9 @@ static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
581 if (!chip->buffer_write_time) 581 if (!chip->buffer_write_time)
582 chip->buffer_write_time++; 582 chip->buffer_write_time++;
583 } 583 }
584 if (z > 1) 584 if (z > 1)
585 chip->buffer_write_time++; 585 chip->buffer_write_time++;
586 586
587 /* Done and happy. */ 587 /* Done and happy. */
588 DISABLE_VPP(map); 588 DISABLE_VPP(map);
589 chip->state = FL_STATUS; 589 chip->state = FL_STATUS;
@@ -607,7 +607,7 @@ static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
607 return 0; 607 return 0;
608} 608}
609 609
610static int cfi_staa_write_buffers (struct mtd_info *mtd, loff_t to, 610static int cfi_staa_write_buffers (struct mtd_info *mtd, loff_t to,
611 size_t len, size_t *retlen, const u_char *buf) 611 size_t len, size_t *retlen, const u_char *buf)
612{ 612{
613 struct map_info *map = mtd->priv; 613 struct map_info *map = mtd->priv;
@@ -629,7 +629,7 @@ static int cfi_staa_write_buffers (struct mtd_info *mtd, loff_t to,
629 printk("%s: chipnum[%x] wbufsize[%x]\n", __FUNCTION__, chipnum, wbufsize); 629 printk("%s: chipnum[%x] wbufsize[%x]\n", __FUNCTION__, chipnum, wbufsize);
630 printk("%s: ofs[%x] len[%x]\n", __FUNCTION__, ofs, len); 630 printk("%s: ofs[%x] len[%x]\n", __FUNCTION__, ofs, len);
631#endif 631#endif
632 632
633 /* Write buffer is worth it only if more than one word to write... */ 633 /* Write buffer is worth it only if more than one word to write... */
634 while (len > 0) { 634 while (len > 0) {
635 /* We must not cross write block boundaries */ 635 /* We must not cross write block boundaries */
@@ -638,7 +638,7 @@ static int cfi_staa_write_buffers (struct mtd_info *mtd, loff_t to,
638 if (size > len) 638 if (size > len)
639 size = len; 639 size = len;
640 640
641 ret = do_write_buffer(map, &cfi->chips[chipnum], 641 ret = do_write_buffer(map, &cfi->chips[chipnum],
642 ofs, buf, size); 642 ofs, buf, size);
643 if (ret) 643 if (ret)
644 return ret; 644 return ret;
@@ -649,13 +649,13 @@ static int cfi_staa_write_buffers (struct mtd_info *mtd, loff_t to,
649 len -= size; 649 len -= size;
650 650
651 if (ofs >> cfi->chipshift) { 651 if (ofs >> cfi->chipshift) {
652 chipnum ++; 652 chipnum ++;
653 ofs = 0; 653 ofs = 0;
654 if (chipnum == cfi->numchips) 654 if (chipnum == cfi->numchips)
655 return 0; 655 return 0;
656 } 656 }
657 } 657 }
658 658
659 return 0; 659 return 0;
660} 660}
661 661
@@ -765,7 +765,7 @@ retry:
765 status = map_read(map, adr); 765 status = map_read(map, adr);
766 if (map_word_andequal(map, status, status_OK, status_OK)) 766 if (map_word_andequal(map, status, status_OK, status_OK))
767 break; 767 break;
768 768
769 /* Urgh. Chip not yet ready to talk to us. */ 769 /* Urgh. Chip not yet ready to talk to us. */
770 if (time_after(jiffies, timeo)) { 770 if (time_after(jiffies, timeo)) {
771 spin_unlock_bh(chip->mutex); 771 spin_unlock_bh(chip->mutex);
@@ -798,7 +798,7 @@ retry:
798 map_write(map, CMD(0x20), adr); 798 map_write(map, CMD(0x20), adr);
799 map_write(map, CMD(0xD0), adr); 799 map_write(map, CMD(0xD0), adr);
800 chip->state = FL_ERASING; 800 chip->state = FL_ERASING;
801 801
802 spin_unlock_bh(chip->mutex); 802 spin_unlock_bh(chip->mutex);
803 msleep(1000); 803 msleep(1000);
804 spin_lock_bh(chip->mutex); 804 spin_lock_bh(chip->mutex);
@@ -823,7 +823,7 @@ retry:
823 status = map_read(map, adr); 823 status = map_read(map, adr);
824 if (map_word_andequal(map, status, status_OK, status_OK)) 824 if (map_word_andequal(map, status, status_OK, status_OK))
825 break; 825 break;
826 826
827 /* OK Still waiting */ 827 /* OK Still waiting */
828 if (time_after(jiffies, timeo)) { 828 if (time_after(jiffies, timeo)) {
829 map_write(map, CMD(0x70), adr); 829 map_write(map, CMD(0x70), adr);
@@ -833,13 +833,13 @@ retry:
833 spin_unlock_bh(chip->mutex); 833 spin_unlock_bh(chip->mutex);
834 return -EIO; 834 return -EIO;
835 } 835 }
836 836
837 /* Latency issues. Drop the lock, wait a while and retry */ 837 /* Latency issues. Drop the lock, wait a while and retry */
838 spin_unlock_bh(chip->mutex); 838 spin_unlock_bh(chip->mutex);
839 cfi_udelay(1); 839 cfi_udelay(1);
840 spin_lock_bh(chip->mutex); 840 spin_lock_bh(chip->mutex);
841 } 841 }
842 842
843 DISABLE_VPP(map); 843 DISABLE_VPP(map);
844 ret = 0; 844 ret = 0;
845 845
@@ -864,7 +864,7 @@ retry:
864 /* Reset the error bits */ 864 /* Reset the error bits */
865 map_write(map, CMD(0x50), adr); 865 map_write(map, CMD(0x50), adr);
866 map_write(map, CMD(0x70), adr); 866 map_write(map, CMD(0x70), adr);
867 867
868 if ((chipstatus & 0x30) == 0x30) { 868 if ((chipstatus & 0x30) == 0x30) {
869 printk(KERN_NOTICE "Chip reports improper command sequence: status 0x%x\n", chipstatus); 869 printk(KERN_NOTICE "Chip reports improper command sequence: status 0x%x\n", chipstatus);
870 ret = -EIO; 870 ret = -EIO;
@@ -913,17 +913,17 @@ int cfi_staa_erase_varsize(struct mtd_info *mtd, struct erase_info *instr)
913 913
914 i = 0; 914 i = 0;
915 915
916 /* Skip all erase regions which are ended before the start of 916 /* Skip all erase regions which are ended before the start of
917 the requested erase. Actually, to save on the calculations, 917 the requested erase. Actually, to save on the calculations,
918 we skip to the first erase region which starts after the 918 we skip to the first erase region which starts after the
919 start of the requested erase, and then go back one. 919 start of the requested erase, and then go back one.
920 */ 920 */
921 921
922 while (i < mtd->numeraseregions && instr->addr >= regions[i].offset) 922 while (i < mtd->numeraseregions && instr->addr >= regions[i].offset)
923 i++; 923 i++;
924 i--; 924 i--;
925 925
926 /* OK, now i is pointing at the erase region in which this 926 /* OK, now i is pointing at the erase region in which this
927 erase request starts. Check the start of the requested 927 erase request starts. Check the start of the requested
928 erase range is aligned with the erase size which is in 928 erase range is aligned with the erase size which is in
929 effect here. 929 effect here.
@@ -946,7 +946,7 @@ int cfi_staa_erase_varsize(struct mtd_info *mtd, struct erase_info *instr)
946 the address actually falls 946 the address actually falls
947 */ 947 */
948 i--; 948 i--;
949 949
950 if ((instr->addr + instr->len) & (regions[i].erasesize-1)) 950 if ((instr->addr + instr->len) & (regions[i].erasesize-1))
951 return -EINVAL; 951 return -EINVAL;
952 952
@@ -958,7 +958,7 @@ int cfi_staa_erase_varsize(struct mtd_info *mtd, struct erase_info *instr)
958 958
959 while(len) { 959 while(len) {
960 ret = do_erase_oneblock(map, &cfi->chips[chipnum], adr); 960 ret = do_erase_oneblock(map, &cfi->chips[chipnum], adr);
961 961
962 if (ret) 962 if (ret)
963 return ret; 963 return ret;
964 964
@@ -971,15 +971,15 @@ int cfi_staa_erase_varsize(struct mtd_info *mtd, struct erase_info *instr)
971 if (adr >> cfi->chipshift) { 971 if (adr >> cfi->chipshift) {
972 adr = 0; 972 adr = 0;
973 chipnum++; 973 chipnum++;
974 974
975 if (chipnum >= cfi->numchips) 975 if (chipnum >= cfi->numchips)
976 break; 976 break;
977 } 977 }
978 } 978 }
979 979
980 instr->state = MTD_ERASE_DONE; 980 instr->state = MTD_ERASE_DONE;
981 mtd_erase_callback(instr); 981 mtd_erase_callback(instr);
982 982
983 return 0; 983 return 0;
984} 984}
985 985
@@ -1005,7 +1005,7 @@ static void cfi_staa_sync (struct mtd_info *mtd)
1005 case FL_JEDEC_QUERY: 1005 case FL_JEDEC_QUERY:
1006 chip->oldstate = chip->state; 1006 chip->oldstate = chip->state;
1007 chip->state = FL_SYNCING; 1007 chip->state = FL_SYNCING;
1008 /* No need to wake_up() on this state change - 1008 /* No need to wake_up() on this state change -
1009 * as the whole point is that nobody can do anything 1009 * as the whole point is that nobody can do anything
1010 * with the chip now anyway. 1010 * with the chip now anyway.
1011 */ 1011 */
@@ -1016,11 +1016,11 @@ static void cfi_staa_sync (struct mtd_info *mtd)
1016 default: 1016 default:
1017 /* Not an idle state */ 1017 /* Not an idle state */
1018 add_wait_queue(&chip->wq, &wait); 1018 add_wait_queue(&chip->wq, &wait);
1019 1019
1020 spin_unlock_bh(chip->mutex); 1020 spin_unlock_bh(chip->mutex);
1021 schedule(); 1021 schedule();
1022 remove_wait_queue(&chip->wq, &wait); 1022 remove_wait_queue(&chip->wq, &wait);
1023 1023
1024 goto retry; 1024 goto retry;
1025 } 1025 }
1026 } 1026 }
@@ -1031,7 +1031,7 @@ static void cfi_staa_sync (struct mtd_info *mtd)
1031 chip = &cfi->chips[i]; 1031 chip = &cfi->chips[i];
1032 1032
1033 spin_lock_bh(chip->mutex); 1033 spin_lock_bh(chip->mutex);
1034 1034
1035 if (chip->state == FL_SYNCING) { 1035 if (chip->state == FL_SYNCING) {
1036 chip->state = chip->oldstate; 1036 chip->state = chip->oldstate;
1037 wake_up(&chip->wq); 1037 wake_up(&chip->wq);
@@ -1066,9 +1066,9 @@ retry:
1066 1066
1067 case FL_STATUS: 1067 case FL_STATUS:
1068 status = map_read(map, adr); 1068 status = map_read(map, adr);
1069 if (map_word_andequal(map, status, status_OK, status_OK)) 1069 if (map_word_andequal(map, status, status_OK, status_OK))
1070 break; 1070 break;
1071 1071
1072 /* Urgh. Chip not yet ready to talk to us. */ 1072 /* Urgh. Chip not yet ready to talk to us. */
1073 if (time_after(jiffies, timeo)) { 1073 if (time_after(jiffies, timeo)) {
1074 spin_unlock_bh(chip->mutex); 1074 spin_unlock_bh(chip->mutex);
@@ -1097,7 +1097,7 @@ retry:
1097 map_write(map, CMD(0x60), adr); 1097 map_write(map, CMD(0x60), adr);
1098 map_write(map, CMD(0x01), adr); 1098 map_write(map, CMD(0x01), adr);
1099 chip->state = FL_LOCKING; 1099 chip->state = FL_LOCKING;
1100 1100
1101 spin_unlock_bh(chip->mutex); 1101 spin_unlock_bh(chip->mutex);
1102 msleep(1000); 1102 msleep(1000);
1103 spin_lock_bh(chip->mutex); 1103 spin_lock_bh(chip->mutex);
@@ -1111,7 +1111,7 @@ retry:
1111 status = map_read(map, adr); 1111 status = map_read(map, adr);
1112 if (map_word_andequal(map, status, status_OK, status_OK)) 1112 if (map_word_andequal(map, status, status_OK, status_OK))
1113 break; 1113 break;
1114 1114
1115 /* OK Still waiting */ 1115 /* OK Still waiting */
1116 if (time_after(jiffies, timeo)) { 1116 if (time_after(jiffies, timeo)) {
1117 map_write(map, CMD(0x70), adr); 1117 map_write(map, CMD(0x70), adr);
@@ -1121,13 +1121,13 @@ retry:
1121 spin_unlock_bh(chip->mutex); 1121 spin_unlock_bh(chip->mutex);
1122 return -EIO; 1122 return -EIO;
1123 } 1123 }
1124 1124
1125 /* Latency issues. Drop the lock, wait a while and retry */ 1125 /* Latency issues. Drop the lock, wait a while and retry */
1126 spin_unlock_bh(chip->mutex); 1126 spin_unlock_bh(chip->mutex);
1127 cfi_udelay(1); 1127 cfi_udelay(1);
1128 spin_lock_bh(chip->mutex); 1128 spin_lock_bh(chip->mutex);
1129 } 1129 }
1130 1130
1131 /* Done and happy. */ 1131 /* Done and happy. */
1132 chip->state = FL_STATUS; 1132 chip->state = FL_STATUS;
1133 DISABLE_VPP(map); 1133 DISABLE_VPP(map);
@@ -1171,8 +1171,8 @@ static int cfi_staa_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
1171 cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL); 1171 cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL);
1172 printk("after lock: block status register is %x\n",cfi_read_query(map, adr+(2*ofs_factor))); 1172 printk("after lock: block status register is %x\n",cfi_read_query(map, adr+(2*ofs_factor)));
1173 cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL); 1173 cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL);
1174#endif 1174#endif
1175 1175
1176 if (ret) 1176 if (ret)
1177 return ret; 1177 return ret;
1178 1178
@@ -1182,7 +1182,7 @@ static int cfi_staa_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
1182 if (adr >> cfi->chipshift) { 1182 if (adr >> cfi->chipshift) {
1183 adr = 0; 1183 adr = 0;
1184 chipnum++; 1184 chipnum++;
1185 1185
1186 if (chipnum >= cfi->numchips) 1186 if (chipnum >= cfi->numchips)
1187 break; 1187 break;
1188 } 1188 }
@@ -1217,7 +1217,7 @@ retry:
1217 status = map_read(map, adr); 1217 status = map_read(map, adr);
1218 if (map_word_andequal(map, status, status_OK, status_OK)) 1218 if (map_word_andequal(map, status, status_OK, status_OK))
1219 break; 1219 break;
1220 1220
1221 /* Urgh. Chip not yet ready to talk to us. */ 1221 /* Urgh. Chip not yet ready to talk to us. */
1222 if (time_after(jiffies, timeo)) { 1222 if (time_after(jiffies, timeo)) {
1223 spin_unlock_bh(chip->mutex); 1223 spin_unlock_bh(chip->mutex);
@@ -1246,7 +1246,7 @@ retry:
1246 map_write(map, CMD(0x60), adr); 1246 map_write(map, CMD(0x60), adr);
1247 map_write(map, CMD(0xD0), adr); 1247 map_write(map, CMD(0xD0), adr);
1248 chip->state = FL_UNLOCKING; 1248 chip->state = FL_UNLOCKING;
1249 1249
1250 spin_unlock_bh(chip->mutex); 1250 spin_unlock_bh(chip->mutex);
1251 msleep(1000); 1251 msleep(1000);
1252 spin_lock_bh(chip->mutex); 1252 spin_lock_bh(chip->mutex);
@@ -1260,7 +1260,7 @@ retry:
1260 status = map_read(map, adr); 1260 status = map_read(map, adr);
1261 if (map_word_andequal(map, status, status_OK, status_OK)) 1261 if (map_word_andequal(map, status, status_OK, status_OK))
1262 break; 1262 break;
1263 1263
1264 /* OK Still waiting */ 1264 /* OK Still waiting */
1265 if (time_after(jiffies, timeo)) { 1265 if (time_after(jiffies, timeo)) {
1266 map_write(map, CMD(0x70), adr); 1266 map_write(map, CMD(0x70), adr);
@@ -1270,13 +1270,13 @@ retry:
1270 spin_unlock_bh(chip->mutex); 1270 spin_unlock_bh(chip->mutex);
1271 return -EIO; 1271 return -EIO;
1272 } 1272 }
1273 1273
1274 /* Latency issues. Drop the unlock, wait a while and retry */ 1274 /* Latency issues. Drop the unlock, wait a while and retry */
1275 spin_unlock_bh(chip->mutex); 1275 spin_unlock_bh(chip->mutex);
1276 cfi_udelay(1); 1276 cfi_udelay(1);
1277 spin_lock_bh(chip->mutex); 1277 spin_lock_bh(chip->mutex);
1278 } 1278 }
1279 1279
1280 /* Done and happy. */ 1280 /* Done and happy. */
1281 chip->state = FL_STATUS; 1281 chip->state = FL_STATUS;
1282 DISABLE_VPP(map); 1282 DISABLE_VPP(map);
@@ -1301,7 +1301,7 @@ static int cfi_staa_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
1301 { 1301 {
1302 unsigned long temp_adr = adr; 1302 unsigned long temp_adr = adr;
1303 unsigned long temp_len = len; 1303 unsigned long temp_len = len;
1304 1304
1305 cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL); 1305 cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL);
1306 while (temp_len) { 1306 while (temp_len) {
1307 printk("before unlock %x: block status register is %x\n",temp_adr,cfi_read_query(map, temp_adr+(2*ofs_factor))); 1307 printk("before unlock %x: block status register is %x\n",temp_adr,cfi_read_query(map, temp_adr+(2*ofs_factor)));
@@ -1319,7 +1319,7 @@ static int cfi_staa_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
1319 printk("after unlock: block status register is %x\n",cfi_read_query(map, adr+(2*ofs_factor))); 1319 printk("after unlock: block status register is %x\n",cfi_read_query(map, adr+(2*ofs_factor)));
1320 cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL); 1320 cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL);
1321#endif 1321#endif
1322 1322
1323 return ret; 1323 return ret;
1324} 1324}
1325 1325
@@ -1343,7 +1343,7 @@ static int cfi_staa_suspend(struct mtd_info *mtd)
1343 case FL_JEDEC_QUERY: 1343 case FL_JEDEC_QUERY:
1344 chip->oldstate = chip->state; 1344 chip->oldstate = chip->state;
1345 chip->state = FL_PM_SUSPENDED; 1345 chip->state = FL_PM_SUSPENDED;
1346 /* No need to wake_up() on this state change - 1346 /* No need to wake_up() on this state change -
1347 * as the whole point is that nobody can do anything 1347 * as the whole point is that nobody can do anything
1348 * with the chip now anyway. 1348 * with the chip now anyway.
1349 */ 1349 */
@@ -1362,9 +1362,9 @@ static int cfi_staa_suspend(struct mtd_info *mtd)
1362 if (ret) { 1362 if (ret) {
1363 for (i--; i >=0; i--) { 1363 for (i--; i >=0; i--) {
1364 chip = &cfi->chips[i]; 1364 chip = &cfi->chips[i];
1365 1365
1366 spin_lock_bh(chip->mutex); 1366 spin_lock_bh(chip->mutex);
1367 1367
1368 if (chip->state == FL_PM_SUSPENDED) { 1368 if (chip->state == FL_PM_SUSPENDED) {
1369 /* No need to force it into a known state here, 1369 /* No need to force it into a known state here,
1370 because we're returning failure, and it didn't 1370 because we're returning failure, and it didn't
@@ -1374,8 +1374,8 @@ static int cfi_staa_suspend(struct mtd_info *mtd)
1374 } 1374 }
1375 spin_unlock_bh(chip->mutex); 1375 spin_unlock_bh(chip->mutex);
1376 } 1376 }
1377 } 1377 }
1378 1378
1379 return ret; 1379 return ret;
1380} 1380}
1381 1381
@@ -1387,11 +1387,11 @@ static void cfi_staa_resume(struct mtd_info *mtd)
1387 struct flchip *chip; 1387 struct flchip *chip;
1388 1388
1389 for (i=0; i<cfi->numchips; i++) { 1389 for (i=0; i<cfi->numchips; i++) {
1390 1390
1391 chip = &cfi->chips[i]; 1391 chip = &cfi->chips[i];
1392 1392
1393 spin_lock_bh(chip->mutex); 1393 spin_lock_bh(chip->mutex);
1394 1394
1395 /* Go to known state. Chip may have been power cycled */ 1395 /* Go to known state. Chip may have been power cycled */
1396 if (chip->state == FL_PM_SUSPENDED) { 1396 if (chip->state == FL_PM_SUSPENDED) {
1397 map_write(map, CMD(0xFF), 0); 1397 map_write(map, CMD(0xFF), 0);