Re: [PATCH] add function spin_event_timeout()

From: Jeremy Fitzhardinge
Date: Mon Mar 09 2009 - 16:48:10 EST


Timur Tabi wrote:
On Fri, Mar 6, 2009 at 7:11 PM, Roland Dreier <rdreier@xxxxxxxxx> wrote:
> The function spin_event_timeout() takes a condition and timeout value
> (in jiffies) as parameters. It spins until either the condition is true
> or the timeout expires. It returns non-zero if the condition is true,
> zero otherwise.

What's the motivation for this? Where do you plan to use it?

I expect it would be useful for drivers that need to wait until a
specific register has changed its value, but don't want to risk an
infinite loop if the hardware is not functioning. For example, to
replace the while loop and subsequent check in this code:

A jiffy is a really long time to be spinning, let alone liffies plural. In this use case are you expecting that the loop will iterate a very small number of times before returning, and the timeout case is a very unlikely error condition?

J
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/