--- cfi_cmdset_0002.c.orig Wed Jan 15 11:13:11 2003 +++ cfi_cmdset_0002.c Wed Jan 15 11:25:29 2003 @@ -520,7 +520,7 @@ status = cfi_read(map, adr); while( (status & dq6) != (oldstatus & dq6) && - (status & dq5) != dq5 && + (oldstatus & dq5) == 0 && !time_after(jiffies, timeo) ) { if (need_resched()) { @@ -536,20 +536,17 @@ if( (status & dq6) != (oldstatus & dq6) ) { /* The erasing didn't stop?? */ - if( (status & dq5) == dq5 ) { - /* When DQ5 raises, we must check once again - if DQ6 is toggling. If not, the erase has been - completed OK. If not, reset chip. */ - oldstatus = cfi_read(map, adr); - status = cfi_read(map, adr); - - if ( (oldstatus & 0x00FF) == (status & 0x00FF) ) { - printk(KERN_WARNING "Warning: DQ5 raised while program operation was in progress, however operation completed OK\n" ); - } else { - /* DQ5 is active so we can do a reset and stop the erase */ - cfi_write(map, CMD(0xF0), chip->start); - printk(KERN_WARNING "Internal flash device timeout occurred or write operation was performed while flash was programming.\n" ); - } + if( (status & dq5) != 0 ) { + + /* one or more bit5's set. */ + + /* no need to re-check if bit 6 is toggling, as */ + /* we've already seen bit 6 toggle after bit 5 */ + /* was set. */ + + /* DQ5 is active so we can do a reset and stop the erase */ + cfi_write(map, CMD(0xF0), chip->start); + printk(KERN_WARNING "Internal flash device timeout occurred or write operation was performed while flash was programming.\n" ); } else { printk(KERN_WARNING "Waiting for write to complete timed out in do_write_oneword."); @@ -773,7 +770,7 @@ oldstatus = cfi_read(map, adr); status = cfi_read(map, adr); while( ((status & dq6) != (oldstatus & dq6)) && - ((status & dq5) != dq5) && + ((oldstatus & dq5) == 0) && !time_after(jiffies, timeo)) { int wait_reps; @@ -805,7 +802,7 @@ for(wait_reps = 0; (wait_reps < 100) && ((status & dq6) != (oldstatus & dq6)) && - ((status & dq5) != dq5); + ((oldstatus & dq5) == 0); wait_reps++) { /* Latency issues. Drop the lock, wait a while and retry */ @@ -822,7 +819,7 @@ } if ((status & dq6) != (oldstatus & dq6)) { /* The erasing didn't stop?? */ - if ((status & dq5) == dq5) { + if ((oldstatus & dq5) != 0) { /* dq5 is active so we can do a reset and stop the erase */ cfi_write(map, CMD(0xF0), chip->start); } @@ -897,7 +894,7 @@ oldstatus = cfi_read(map, adr); status = cfi_read(map, adr); while( ((status & dq6) != (oldstatus & dq6)) && - ((status & dq5) != dq5) && + ((oldstatus & dq5) == 0) && !time_after(jiffies, timeo)) { int wait_reps; @@ -929,7 +926,7 @@ for(wait_reps = 0; (wait_reps < 100) && ((status & dq6) != (oldstatus & dq6)) && - ((status & dq5) != dq5); + ((oldstatus & dq5) == 0); wait_reps++) { /* Latency issues. Drop the lock, wait a while and retry */ @@ -947,34 +944,28 @@ if( (status & dq6) != (oldstatus & dq6) ) { /* The erasing didn't stop?? */ - if( ( status & dq5 ) == dq5 ) + if( ( oldstatus & dq5 ) != 0 ) { - /* When DQ5 raises, we must check once again if DQ6 is toggling. - If not, the erase has been completed OK. If not, reset chip. */ - oldstatus = cfi_read( map, adr ); - status = cfi_read( map, adr ); - - if( ( oldstatus & 0x00FF ) == ( status & 0x00FF ) ) - { - printk( "Warning: DQ5 raised while erase operation was in progress, but erase completed OK\n" ); - } - else - { - /* DQ5 is active so we can do a reset and stop the erase */ - cfi_write(map, CMD(0xF0), chip->start); - printk( KERN_WARNING "Internal flash device timeout occured or write operation was performed while flash was erasing\n" ); - } + /* one or more bit5's set. */ + + /* no need to re-check if bit 6 is toggling, as */ + /* we've already seen bit 6 toggle after bit 5 */ + /* was set. */ + + /* DQ5 is active so we can do a reset and stop the erase */ + cfi_write(map, CMD(0xF0), chip->start); + printk( KERN_WARNING "Internal flash device timeout occured or write operation was performed while flash was erasing\n" ); } - else - { - printk( "Waiting for erase to complete timed out in do_erase_oneblock."); + else + { + printk( "Waiting for erase to complete timed out in do_erase_oneblock."); - chip->state = FL_READY; - wake_up(&chip->wq); - cfi_spin_unlock(chip->mutex); - DISABLE_VPP(map); - return -EIO; - } + chip->state = FL_READY; + wake_up(&chip->wq); + cfi_spin_unlock(chip->mutex); + DISABLE_VPP(map); + return -EIO; + } } DISABLE_VPP(map);