Skip to content

Commit

Permalink
mtd: fix timeout in M25P80 driver
Browse files Browse the repository at this point in the history
Extend erase timeout in M25P80 SPI Flash driver.

The M25P80 drivers fails erasing sectors on a M25P128 because the ready
wait timeout is too short. Change the timeout from a simple loop count to a
suitable number of seconds.

Signed-off-by: Peter Horton <zero@colonel-panic.org>
Tested-by: Martin Michlmayr <tbm@cyrius.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
Peter Horton authored and David Woodhouse committed May 8, 2009
1 parent 3f33b0a commit cd1a6de
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions drivers/mtd/devices/m25p80.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#define SR_SRWD 0x80 /* SR write protect */

/* Define max times to check status register before we give up. */
#define MAX_READY_WAIT_COUNT 1000000
#define MAX_READY_WAIT_JIFFIES (10 * HZ) /* eg. M25P128 specs 6s max sector erase */
#define CMD_SIZE 4

#ifdef CONFIG_M25PXX_USE_FAST_READ
Expand Down Expand Up @@ -139,20 +139,20 @@ static inline int write_enable(struct m25p *flash)
*/
static int wait_till_ready(struct m25p *flash)
{
int count;
unsigned long deadline;
int sr;

/* one chip guarantees max 5 msec wait here after page writes,
* but potentially three seconds (!) after page erase.
*/
for (count = 0; count < MAX_READY_WAIT_COUNT; count++) {
deadline = jiffies + MAX_READY_WAIT_JIFFIES;

do {
if ((sr = read_sr(flash)) < 0)
break;
else if (!(sr & SR_WIP))
return 0;

/* REVISIT sometimes sleeping would be best */
}
cond_resched();

} while (!time_after_eq(jiffies, deadline));

return 1;
}
Expand Down

0 comments on commit cd1a6de

Please sign in to comment.