[PATCH] Fix erase timeout in M25P80 driver

Mike Frysinger vapier.adi at gmail.com
Sat Apr 4 04:10:50 EDT 2009


On Sat, Apr 4, 2009 at 03:31, Peter Horton wrote:
>  static int wait_till_ready(struct m25p *flash)
>  {
> -       int count;
> +#      define DIV_U(n,d)               (((n)+(d)-1)/(d))
> +
> +       unsigned long deadline;
>        int sr;
>
> -       /* one chip guarantees max 5 msec wait here after page writes,
> -        * but potentially three seconds (!) after page erase.
> +       deadline = jiffies + DIV_U(MAX_READY_WAIT_TIMEOUT * HZ, 1000);

there's already a macro for working with jiffies and time.  dont start
writing yet another one with its own ugly magic.  just look in
linux/jiffies.h.

> +       /* this can take a long time for sector erase.
> +        * we should probably have a separate timeout
> +        * for program and erase and we should check
> +        * for signals ...

timeouts only occur when there's a problem.  a problematic system is
not normal, so having longer (and common) timeouts is fine because
they should never be reached.
-mike



More information about the linux-mtd mailing list