From: David Woodhouse <dwmw2@infradead.org>
To: akpm@linux-foundation.org
Cc: linus.walleij@stericsson.com, ryan@bluewatersys.com,
andre@bluewatersys.com, linux-mtd@lists.infradead.org,
hartleys@visionengravers.com, avorontsov@ru.mvista.com
Subject: Re: [patch 02/13] mtd: SST25L (non JEDEC) SPI Flash driver
Date: Sat, 19 Sep 2009 10:22:52 -0700 [thread overview]
Message-ID: <1253380972.6317.22.camel@macbook.infradead.org> (raw)
In-Reply-To: <200909181951.n8IJpeq1023467@imap1.linux-foundation.org>
On Fri, 2009-09-18 at 12:51 -0700, akpm@linux-foundation.org wrote:
>
> +static int sst25l_wait_till_ready(struct sst25l_flash *flash)
> +{
> + unsigned long deadline;
> + int status, err;
> +
> + deadline = jiffies + MAX_READY_WAIT_JIFFIES;
> + do {
> + err = sst25l_status(flash, &status);
> + if (err)
> + return err;
> + if (!(status & SST25L_STATUS_BUSY))
> + return 0;
> +
> + cond_resched();
> + } while (!time_after_eq(jiffies, deadline));
> +
> + return -ETIMEDOUT;
> +}
If your system is busy and you end up relinquishing the CPU for a long
period of time during that cond_resched(), you could hit the timeout
condition even though the hardware _is_ actually reporting 'ready'
status by the time you get back on the CPU.
It's unlikely, admittedly, but it's good practice to make sure it can't
happen like that. Something like
while (busy) {
if (timed_out) return -ETIMEDOUT;
cond_resched();
}
--
David Woodhouse Open Source Technology Centre
David.Woodhouse@intel.com Intel Corporation
next prev parent reply other threads:[~2009-09-19 17:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-18 19:51 [patch 02/13] mtd: SST25L (non JEDEC) SPI Flash driver akpm
2009-09-19 17:22 ` David Woodhouse [this message]
2009-09-21 3:24 ` Ryan Mallon
2009-09-21 6:08 ` David Woodhouse
2009-09-21 4:47 ` Ryan Mallon
2009-09-21 6:14 ` David Woodhouse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1253380972.6317.22.camel@macbook.infradead.org \
--to=dwmw2@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=andre@bluewatersys.com \
--cc=avorontsov@ru.mvista.com \
--cc=hartleys@visionengravers.com \
--cc=linus.walleij@stericsson.com \
--cc=linux-mtd@lists.infradead.org \
--cc=ryan@bluewatersys.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox