[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <44C9CFF8.2080503@garzik.org>
Date: Fri, 28 Jul 2006 04:51:04 -0400
From: Jeff Garzik <jeff@...zik.org>
To: Zed 0xff <zed.0xff@...il.com>
CC: kernel-janitors@...l.org, linux-kernel@...r.kernel.org
Subject: Re: [patch] fix common mistake in polling loops
Zed 0xff wrote:
> b/drivers/block/sx8.c
> --- a/drivers/block/sx8.c 2006-07-27 21:56:05.000000000 +0600
> +++ b/drivers/block/sx8.c 2006-07-28 00:52:33.000000000 +0600
> @@ -550,21 +550,23 @@ static struct carm_request *carm_get_spe
> unsigned long flags;
> struct carm_request *crq = NULL;
> struct request *rq;
> - int tries = 5000;
> + unsigned long timeout= jiffies + msecs_to_jiffies(50000);
>
> - while (tries-- > 0) {
> + for(;;) {
> spin_lock_irqsave(&host->lock, flags);
> crq = carm_get_request(host);
> spin_unlock_irqrestore(&host->lock, flags);
>
> if (crq)
> break;
> +
> + if (time_after(timeout, jiffies)) {
> + return NULL;
> + }
> +
> msleep(10);
> }
>
> - if (!crq)
> - return NULL;
> -
NAK:
* [minor] broken whitespace
* [minor] adding braces to singleton C statements
* [major] makes a simple loop much more annoying to read
There is no critical hard deadline for this loop, as with most error
handling loops.
Since error handling code is exercised much less frequently than regular
code, I would rather KISS.
Jeff
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists