提交 cd1a6de7 编写于 作者: P Peter Horton 提交者: David Woodhouse

mtd: fix timeout in M25P80 driver

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: NPeter Horton <zero@colonel-panic.org>
Tested-by: NMartin Michlmayr <tbm@cyrius.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
上级 3f33b0aa
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
#define SR_SRWD 0x80 /* SR write protect */ #define SR_SRWD 0x80 /* SR write protect */
/* Define max times to check status register before we give up. */ /* 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 #define CMD_SIZE 4
#ifdef CONFIG_M25PXX_USE_FAST_READ #ifdef CONFIG_M25PXX_USE_FAST_READ
...@@ -139,20 +139,20 @@ static inline int write_enable(struct m25p *flash) ...@@ -139,20 +139,20 @@ static inline int write_enable(struct m25p *flash)
*/ */
static int wait_till_ready(struct m25p *flash) static int wait_till_ready(struct m25p *flash)
{ {
int count; unsigned long deadline;
int sr; int sr;
/* one chip guarantees max 5 msec wait here after page writes, deadline = jiffies + MAX_READY_WAIT_JIFFIES;
* but potentially three seconds (!) after page erase.
*/ do {
for (count = 0; count < MAX_READY_WAIT_COUNT; count++) {
if ((sr = read_sr(flash)) < 0) if ((sr = read_sr(flash)) < 0)
break; break;
else if (!(sr & SR_WIP)) else if (!(sr & SR_WIP))
return 0; return 0;
/* REVISIT sometimes sleeping would be best */ cond_resched();
}
} while (!time_after_eq(jiffies, deadline));
return 1; return 1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册