public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: Ryan Mallon <ryan@bluewatersys.com>
Cc: linus.walleij@stericsson.com, andre@bluewatersys.com,
	linux-mtd@lists.infradead.org, akpm@linux-foundation.org,
	avorontsov@ru.mvista.com, hartleys@visionengravers.com
Subject: Re: [patch 02/13] mtd: SST25L (non JEDEC) SPI Flash driver
Date: Sun, 20 Sep 2009 23:14:16 -0700	[thread overview]
Message-ID: <1253513656.6317.235.camel@macbook.infradead.org> (raw)
In-Reply-To: <4AB70570.5050703@bluewatersys.com>

On Mon, 2009-09-21 at 16:47 +1200, Ryan Mallon wrote:
> >  while (busy) {
> >     if (timed_out) return -ETIMEDOUT;
> >     cond_resched();
> >  }
> > 
> 
> Just thinking about this a bit more. We don't want to call cond_resched
> if the device is ready immediately, and we want to do the check _after_
> cond_resched each time through the loop.

Right, absolutely.

And that's exactly what the loop above was doing, isn't it? If you
unroll the loop, it goes...

 if (busy) {
  if (timed_out) return -ETIMEDOUT;
  cond_resched();
  if (busy) {
    if (timed_out) return -ETIMEDOUT;
    cond_resched();
    if (busy) {
      if (timed_out) return -ETIMEDOUT;
      cond_resched();
      if (busy) {
        ...

It _isn't_ calling cond_resched() if the device is ready immediately,
and it _is_ doing the check _after_ cond_resched() each time. Yes?
  
> There are probably enough places that this sort of thing gets used
> that it may be worth having a generic function like this (untested):
> 
> int cond_resched_wait_timeout(unsigned long timeout_jiffies,
>                               int (*cond_check)(void *cookie),
>                               void *data)

Yes, it's probably a good idea. Maybe better off as a macro, rather than
having a function call to evaluate the condition. Much like wait_event?

-- 
dwmw2

      reply	other threads:[~2009-09-21  6:14 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
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 [this message]

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=1253513656.6317.235.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