From: Joe Perches <joe@perches.com>
To: Roel Kluin <12o3l@tiscali.nl>
Cc: khc@pm.waw.pl, lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drivers/net/wan/wanxl.c: time_before(timeout, jiffies) -> jiffies, timeout
Date: Thu, 20 Mar 2008 14:06:18 -0700 [thread overview]
Message-ID: <1206047178.26345.80.camel@localhost> (raw)
In-Reply-To: <47E2C7D2.5080601@tiscali.nl>
On Thu, 2008-03-20 at 21:23 +0100, Roel Kluin wrote:
> > - while ((stat = readl(card->plx + PLX_MAILBOX_0)) != 0) {
> > - if (time_before(timeout, jiffies)) {
> > - printk(KERN_WARNING "wanXL %s: timeout waiting for"
> > - " PUTS to complete\n", pci_name(pdev));
> > - wanxl_pci_remove_one(pdev);
> > - return -ENODEV;
> > - }
> > -
> > - switch(stat & 0xC0) {
> > - case 0x00: /* hmm - PUTS completed with non-zero code? */
> > - case 0x80: /* PUTS still testing the hardware */
> > - break;
> > -
> > - default:
> > - printk(KERN_WARNING "wanXL %s: PUTS test 0x%X"
> > + if (TEST_UNTIL_TIMEOUT(((stat = readl(card->plx + PLX_MAILBOX_0)) != 0),
> > + 20 * HZ)) {
> > + printk(KERN_WARNING "wanXL %s: PUTS test 0x%X"
> > " failed\n", pci_name(pdev), stat & 0x30);
> > wanxl_pci_remove_one(pdev);
> > return -ENODEV;
>
> Doesn't this change behavior for (stat & 0xC0) != 0x00 or 0x80?
Probably, I didn't look at it too much. Feel free to fix it.
The patch was just to demonstrate the statement expression macro
and show the lack of schedules() in some of the loops.
Maybe the statement expression macro should optionally schedule too:
#define TEST_UNTIL_TIMEOUT(test, hz, schedule) \
({ \
typeof(test) t; \
unsigned long timeout = jiffies + (hz); \
do { \
t = (test); \
if (t) \
break; \
if ((schedule)) \
schedule(); \
} while (time_before(jiffies, timeout)); \
t; \
})
cheers, Joe
next prev parent reply other threads:[~2008-03-20 21:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-20 15:43 [PATCH] drivers/net/wan/wanxl.c: time_before(timeout, jiffies) -> jiffies, timeout Roel Kluin
2008-03-20 16:46 ` Joe Perches
2008-03-20 20:23 ` Roel Kluin
2008-03-20 21:06 ` Joe Perches [this message]
2008-03-24 15:01 ` Krzysztof Halasa
2008-03-24 15:52 ` Joe Perches
2008-03-24 20:22 ` Krzysztof Halasa
2008-03-24 14:42 ` Krzysztof Halasa
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=1206047178.26345.80.camel@localhost \
--to=joe@perches.com \
--cc=12o3l@tiscali.nl \
--cc=khc@pm.waw.pl \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.