mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Krzysztof Halasa <khc@pm.waw.pl>
To: Joe Perches <joe@perches.com>
Cc: Roel Kluin <12o3l@tiscali.nl>, lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drivers/net/wan/wanxl.c: time_before(timeout, jiffies) -> jiffies, timeout
Date: Mon, 24 Mar 2008 16:01:32 +0100	[thread overview]
Message-ID: <m3fxug2mk3.fsf@maximus.localdomain> (raw)
In-Reply-To: <1206031566.26345.63.camel@localhost> (Joe Perches's message of "Thu\, 20 Mar 2008 09\:46\:06 -0700")

Joe Perches <joe@perches.com> writes:

>>  	while ((stat = readl(card->plx + PLX_MAILBOX_0)) != 0) {
>> -		if (time_before(timeout, jiffies)) {
>> +		if (time_before(jiffies, timeout)) {
>>  			printk(KERN_WARNING "wanXL %s: timeout waiting for"
>>  			       " PUTS to complete\n", pci_name(pdev));
>>  			wanxl_pci_remove_one(pdev);
>
> Wouldn't it be better to have a schedule() in those
> while loops too?

There is a schedule() here:

        timeout = jiffies + 20 * HZ;
        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"
                               " failed\n", pci_name(pdev), stat & 0x30);
                        wanxl_pci_remove_one(pdev);
                        return -ENODEV;
                }

                schedule();
        }

The timeout is 20 seconds, busy loop wouldn't make any sense.

> Maybe a more generic macro / statement expression
> would be more readable?

I don't think so. BTW the only "long" loop is the POTS one (after hw
reset or rmmod + insmod), IIRC it takes about 1 second for every MB of
installed DRAM. Officially you can have 1 or 4 MB, and 16 MB module
works (IIRC, on my card) as well - thus 20 * HZ timeout.

A couple of reversed time_{after,before}, yes (with reversed
arguments, i.e., functionally equivalent but probably harder to
parse). Will look at them.
-- 
Krzysztof Halasa

  parent reply	other threads:[~2008-03-24 15:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-20 15:43 Roel Kluin
2008-03-20 16:46 ` Joe Perches
2008-03-20 20:23   ` Roel Kluin
2008-03-20 21:06     ` Joe Perches
2008-03-24 15:01   ` Krzysztof Halasa [this message]
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=m3fxug2mk3.fsf@maximus.localdomain \
    --to=khc@pm.waw.pl \
    --cc=12o3l@tiscali.nl \
    --cc=joe@perches.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®