Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
delay.h
Go to the documentation of this file.
1 #ifndef _ASM_POWERPC_DELAY_H
2 #define _ASM_POWERPC_DELAY_H
3 #ifdef __KERNEL__
4 
5 #include <asm/time.h>
6 
7 /*
8  * Copyright 1996, Paul Mackerras.
9  * Copyright (C) 2009 Freescale Semiconductor, Inc. All rights reserved.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version
14  * 2 of the License, or (at your option) any later version.
15  *
16  * PPC64 Support added by Dave Engebretsen, Todd Inglett, Mike Corrigan,
17  * Anton Blanchard.
18  */
19 
20 extern void __delay(unsigned long loops);
21 extern void udelay(unsigned long usecs);
22 
23 /*
24  * On shared processor machines the generic implementation of mdelay can
25  * result in large errors. While each iteration of the loop inside mdelay
26  * is supposed to take 1ms, the hypervisor could sleep our partition for
27  * longer (eg 10ms). With the right timing these errors can add up.
28  *
29  * Since there is no 32bit overflow issue on 64bit kernels, just call
30  * udelay directly.
31  */
32 #ifdef CONFIG_PPC64
33 #define mdelay(n) udelay((n) * 1000)
34 #endif
35 
56 #define spin_event_timeout(condition, timeout, delay) \
57 ({ \
58  typeof(condition) __ret; \
59  unsigned long __loops = tb_ticks_per_usec * timeout; \
60  unsigned long __start = get_tbl(); \
61  while (!(__ret = (condition)) && (tb_ticks_since(__start) <= __loops)) \
62  if (delay) \
63  udelay(delay); \
64  else \
65  cpu_relax(); \
66  if (!__ret) \
67  __ret = (condition); \
68  __ret; \
69 })
70 
71 #endif /* __KERNEL__ */
72 #endif /* _ASM_POWERPC_DELAY_H */