diff options
| -rw-r--r-- | drivers/mtd/devices/m25p80.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index dfadef84c052..cc6369ea67dd 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c | |||
| @@ -54,7 +54,7 @@ | |||
| 54 | #define SR_SRWD 0x80 /* SR write protect */ | 54 | #define SR_SRWD 0x80 /* SR write protect */ |
| 55 | 55 | ||
| 56 | /* Define max times to check status register before we give up. */ | 56 | /* Define max times to check status register before we give up. */ |
| 57 | #define MAX_READY_WAIT_COUNT 1000000 | 57 | #define MAX_READY_WAIT_JIFFIES (10 * HZ) /* eg. M25P128 specs 6s max sector erase */ |
| 58 | #define CMD_SIZE 4 | 58 | #define CMD_SIZE 4 |
| 59 | 59 | ||
| 60 | #ifdef CONFIG_M25PXX_USE_FAST_READ | 60 | #ifdef CONFIG_M25PXX_USE_FAST_READ |
| @@ -139,20 +139,20 @@ static inline int write_enable(struct m25p *flash) | |||
| 139 | */ | 139 | */ |
| 140 | static int wait_till_ready(struct m25p *flash) | 140 | static int wait_till_ready(struct m25p *flash) |
| 141 | { | 141 | { |
| 142 | int count; | 142 | unsigned long deadline; |
| 143 | int sr; | 143 | int sr; |
| 144 | 144 | ||
| 145 | /* one chip guarantees max 5 msec wait here after page writes, | 145 | deadline = jiffies + MAX_READY_WAIT_JIFFIES; |
| 146 | * but potentially three seconds (!) after page erase. | 146 | |
| 147 | */ | 147 | do { |
| 148 | for (count = 0; count < MAX_READY_WAIT_COUNT; count++) { | ||
| 149 | if ((sr = read_sr(flash)) < 0) | 148 | if ((sr = read_sr(flash)) < 0) |
| 150 | break; | 149 | break; |
| 151 | else if (!(sr & SR_WIP)) | 150 | else if (!(sr & SR_WIP)) |
| 152 | return 0; | 151 | return 0; |
| 153 | 152 | ||
| 154 | /* REVISIT sometimes sleeping would be best */ | 153 | cond_resched(); |
| 155 | } | 154 | |
| 155 | } while (!time_after_eq(jiffies, deadline)); | ||
| 156 | 156 | ||
| 157 | return 1; | 157 | return 1; |
| 158 | } | 158 | } |
