All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
To: Jon Smirl <jonsmirl@gmail.com>
Cc: linuxppc-dev@ozlabs.org, alsa-devel@alsa-project.org,
	broonie@sirena.org.uk, timur@freescale.com
Subject: Re: [PATCH V4 1/5] The macro spin_event_timeout() takes a condition and timeout value
Date: Tue, 26 May 2009 09:29:31 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LRH.2.00.0905260928320.31893@vixen.sonytel.be> (raw)
In-Reply-To: <20090525221507.21370.68301.stgit@terra>

On Mon, 25 May 2009, Jon Smirl wrote:
> (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(-)
> 
> diff --git a/arch/powerpc/include/asm/delay.h b/arch/powerpc/include/asm/delay.h
> index f9200a6..fedf037 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)                   \

static inline function, returning rc, instead of a macro?

> +{                                                                           \
> +	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 */

With kind regards,

Geert Uytterhoeven
Software Architect
Techsoft Centre

Technology and Software Centre Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium

Phone:    +32 (0)2 700 8453
Fax:      +32 (0)2 700 8622
E-mail:   Geert.Uytterhoeven@sonycom.com
Internet: http://www.sony-europe.com/

A division of Sony Europe (Belgium) N.V.
VAT BE 0413.825.160 · RPR Brussels
Fortis · BIC GEBABEBB · IBAN BE41293037680010

  reply	other threads:[~2009-05-26  7:29 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-25 22:15 [PATCH V4 0/5] AC97 driver for mpc5200 Jon Smirl
2009-05-25 22:15 ` [PATCH V4 1/5] The macro spin_event_timeout() takes a condition and timeout value Jon Smirl
2009-05-25 22:15   ` Jon Smirl
2009-05-26  7:29   ` Geert Uytterhoeven [this message]
2009-05-26 11:32     ` Timur Tabi
2009-05-26 11:32       ` Timur Tabi
2009-05-26 11:51       ` Geert Uytterhoeven
2009-05-26 12:49         ` Arnd Bergmann
2009-05-26 14:20           ` Timur Tabi
2009-05-26 14:20             ` Timur Tabi
2009-05-25 22:15 ` [PATCH V4 2/5] Main rewite of the mpc5200 audio DMA code Jon Smirl
2009-05-26 11:01   ` [alsa-devel] " Mark Brown
2009-05-26 16:51     ` Grant Likely
2009-05-26 16:53       ` Jon Smirl
2009-05-26 16:53         ` [alsa-devel] " Jon Smirl
2009-05-26 16:56         ` Grant Likely
2009-05-26 16:56           ` [alsa-devel] " Grant Likely
2009-05-26 17:08         ` Timur Tabi
2009-05-26 17:08           ` [alsa-devel] " Timur Tabi
2009-05-26 20:21           ` Mark Brown
2009-05-25 22:15 ` [PATCH V4 3/5] AC97 driver for mpc5200 Jon Smirl
2009-05-26  3:41   ` Timur Tabi
2009-05-26  3:41     ` [alsa-devel] " Timur Tabi
2009-05-26  3:47     ` Grant Likely
2009-05-26  3:47       ` [alsa-devel] " Grant Likely
2009-05-25 22:15 ` [PATCH V4 4/5] Support for AC97 on Phytec pmc030 base board Jon Smirl
2009-05-25 22:15 ` [PATCH V4 5/5] Fabric bindings for STAC9766 on the Efika Jon Smirl
2009-05-26  3:44 ` [alsa-devel] [PATCH V4 0/5] AC97 driver for mpc5200 Timur Tabi
2009-05-26  3:44   ` Timur Tabi
2009-05-26  9:21   ` Mark Brown
2009-05-26  9:21     ` [alsa-devel] " Mark Brown
2009-05-26 11:08   ` Jon Smirl
2009-05-26 11:08     ` Jon Smirl
2009-05-26 11:39     ` Timur Tabi
2009-05-26 11:39       ` [alsa-devel] " Timur Tabi
2009-05-26 11:43     ` Mark Brown
2009-05-26 11:43       ` [alsa-devel] " Mark Brown
2009-05-26 11:04 ` Mark Brown
2009-05-26 11:04   ` [alsa-devel] " Mark Brown

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=alpine.LRH.2.00.0905260928320.31893@vixen.sonytel.be \
    --to=geert.uytterhoeven@sonycom.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@sirena.org.uk \
    --cc=jonsmirl@gmail.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=timur@freescale.com \
    /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.