Message ID | 20090526123406.17472.79948.stgit@terra (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
On Tue, May 26, 2009 at 08:34:06AM -0400, Jon Smirl wrote: > The macro spin_event_timeout() takes a condition and timeout value > (in microseconds) as parameters. It spins until either the condition is true > or the timeout expires. It returns the result of the condition when the loop > was terminated. As previously mentioned you need to submit any changes you want to make here as incremental patches against the PowerPC tree rather than as an entire new patch. If you are forwarding on copies of the patch you really ought to preserve Timur's authorship too with a From line in the mail.
On Tue, May 26, 2009 at 9:03 AM, Mark Brown <broonie@opensource.wolfsonmicro.com> wrote: > On Tue, May 26, 2009 at 08:34:06AM -0400, Jon Smirl wrote: >> The macro spin_event_timeout() takes a condition and timeout value >> (in microseconds) as parameters. It spins until either the condition is true >> or the timeout expires. It returns the result of the condition when the loop >> was terminated. > > As previously mentioned you need to submit any changes you want to make > here as incremental patches against the PowerPC tree rather than as an > entire new patch. If you are forwarding on copies of the patch you > really ought to preserve Timur's authorship too with a From line in the > mail. I have reverted back to TImur's original patch so you can just drop this patch if that is easier for you. You'll just need to coordinate the landing so that things land in the right order.
On Tue, May 26, 2009 at 09:12:10AM -0400, Jon Smirl wrote: > On Tue, May 26, 2009 at 9:03 AM, Mark Brown > > As previously mentioned you need to submit any changes you want to make > > here as incremental patches against the PowerPC tree rather than as an > > entire new patch. ?If you are forwarding on copies of the patch you > > really ought to preserve Timur's authorship too with a From line in the > > mail. > I have reverted back to TImur's original patch so you can just drop > this patch if that is easier for you. > You'll just need to coordinate the landing so that things land in the > right order. Like I say, since it's a new driver I'm just going to ignore the ordering since it'll sort itself out in the merge window and we're rather close to that. Worst case something that doesn't build isn't that much different from something that isn't there in terms of usability.
diff --git a/arch/powerpc/include/asm/delay.h b/arch/powerpc/include/asm/delay.h index f9200a6..af4a270 100644 --- a/arch/powerpc/include/asm/delay.h +++ b/arch/powerpc/include/asm/delay.h @@ -2,8 +2,11 @@ #define _ASM_POWERPC_DELAY_H #ifdef __KERNEL__ +#include <asm/time.h> + /* * Copyright 1996, Paul Mackerras. + * Copyright (C) 2009 Freescale Semiconductor, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -30,5 +33,35 @@ extern void udelay(unsigned long usecs); #define mdelay(n) udelay((n) * 1000) #endif +/** + * spin_event_timeout - spin until a condition gets true or a timeout elapses + * @condition: a C expression to evalate + * @timeout: timeout, in microseconds + * @delay: the number of microseconds to delay between eache evaluation of + * @condition + * @rc: the last value of the condition + * + * The process spins until the condition evaluates to true (non-zero) or the + * timeout elapses. Upon exit, @rc contains the value of the condition. This + * allows you to test the condition without incurring any side effects. + * + * This primary purpose of this macro is to poll on a hardware register + * until a status bit changes. The timeout ensures that the loop still + * terminates even if the bit never changes. The delay is for devices that + * need a delay in between successive reads. + * + * gcc will optimize out the if-statement if @delay is a constant. + */ +#define spin_event_timeout(condition, timeout, delay, rc) \ +{ \ + unsigned long __loops = tb_ticks_per_usec * timeout; \ + unsigned long __start = get_tbl(); \ + while (!(rc = (condition)) && (tb_ticks_since(__start) <= __loops)) \ + if (delay) \ + udelay(delay); \ + else \ + cpu_relax(); \ +} + #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_DELAY_H */
The macro spin_event_timeout() takes a condition and timeout value (in microseconds) as parameters. It spins until either the condition is true or the timeout expires. It returns the result of the condition when the loop was terminated. This primary purpose of this macro is to poll on a hardware register until a status bit changes. The timeout ensures that the loop still terminates if the bit doesn't change as expected. This macro makes it easier for driver developers to perform this kind of operation properly. Signed-off-by: Timur Tabi <timur@freescale.com> --- arch/powerpc/include/asm/delay.h | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-)