| 1 | --- a/drivers/mtd/chips/cfi_cmdset_0002.c |
| 2 | +++ b/drivers/mtd/chips/cfi_cmdset_0002.c |
| 3 | @@ -1221,8 +1221,8 @@ static int __xipram do_write_oneword(str |
| 4 | break; |
| 5 | } |
| 6 | |
| 7 | - if (chip_ready(map, adr)) |
| 8 | - break; |
| 9 | + if (chip_good(map, adr, datum)) |
| 10 | + goto enable_xip; |
| 11 | |
| 12 | /* Latency issues. Drop the lock, wait a while and retry */ |
| 13 | UDELAY(map, chip, adr, 1); |
| 14 | @@ -1238,6 +1238,8 @@ static int __xipram do_write_oneword(str |
| 15 | |
| 16 | ret = -EIO; |
| 17 | } |
| 18 | + |
| 19 | + enable_xip: |
| 20 | xip_enable(map, chip, adr); |
| 21 | op_done: |
| 22 | chip->state = FL_READY; |
| 23 | @@ -1796,7 +1798,6 @@ static int cfi_amdstd_panic_write(struct |
| 24 | return 0; |
| 25 | } |
| 26 | |
| 27 | - |
| 28 | /* |
| 29 | * Handle devices with one erase region, that only implement |
| 30 | * the chip erase command. |
| 31 | @@ -1860,8 +1861,8 @@ static int __xipram do_erase_chip(struct |
| 32 | chip->erase_suspended = 0; |
| 33 | } |
| 34 | |
| 35 | - if (chip_ready(map, adr)) |
| 36 | - break; |
| 37 | + if (chip_good(map, adr, map_word_ff(map))) |
| 38 | + goto op_done; |
| 39 | |
| 40 | if (time_after(jiffies, timeo)) { |
| 41 | printk(KERN_WARNING "MTD %s(): software timeout\n", |
| 42 | @@ -1881,6 +1882,7 @@ static int __xipram do_erase_chip(struct |
| 43 | ret = -EIO; |
| 44 | } |
| 45 | |
| 46 | + op_done: |
| 47 | chip->state = FL_READY; |
| 48 | xip_enable(map, chip, adr); |
| 49 | DISABLE_VPP(map); |
| 50 | @@ -1949,9 +1951,9 @@ static int __xipram do_erase_oneblock(st |
| 51 | chip->erase_suspended = 0; |
| 52 | } |
| 53 | |
| 54 | - if (chip_ready(map, adr)) { |
| 55 | + if (chip_good(map, adr, map_word_ff(map))) { |
| 56 | xip_enable(map, chip, adr); |
| 57 | - break; |
| 58 | + goto op_done; |
| 59 | } |
| 60 | |
| 61 | if (time_after(jiffies, timeo)) { |
| 62 | @@ -1973,6 +1975,7 @@ static int __xipram do_erase_oneblock(st |
| 63 | ret = -EIO; |
| 64 | } |
| 65 | |
| 66 | + op_done: |
| 67 | chip->state = FL_READY; |
| 68 | DISABLE_VPP(map); |
| 69 | put_chip(map, chip, adr); |
| 70 | |