diff options
| author | Max Filippov <jcmvbkbc@gmail.com> | 2014-01-10 03:02:18 -0500 |
|---|---|---|
| committer | Max Filippov <jcmvbkbc@gmail.com> | 2014-01-14 15:28:10 -0500 |
| commit | 58f60c222e8d4503a4be654cbd6d4e190dc1a7d8 (patch) | |
| tree | cde29de11e157697767bff7e94de7ea4a712f408 | |
| parent | a6f3eefad8d1c9abd98fa03ba2b3abeb708e3b95 (diff) | |
xtensa: clean up udelay
Replace division with shift, use ccount_freq instead of loops_per_jiffy.
Introduce __MAX_UDELAY and (undefined) __bad_udelay, break build for too
big udelay constants.
Remove irrelevant comment, clean up code style.
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
| -rw-r--r-- | arch/xtensa/include/asm/delay.h | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/arch/xtensa/include/asm/delay.h b/arch/xtensa/include/asm/delay.h index 742b89f3ca2c..69ba4629bed0 100644 --- a/arch/xtensa/include/asm/delay.h +++ b/arch/xtensa/include/asm/delay.h | |||
| @@ -27,18 +27,27 @@ static inline void __delay(unsigned long loops) | |||
| 27 | : "+r" (loops)); | 27 | : "+r" (loops)); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | /* For SMP/NUMA systems, change boot_cpu_data to something like | 30 | /* Undefined function to get compile-time error */ |
| 31 | * local_cpu_data->... where local_cpu_data points to the current | 31 | void __bad_udelay(void); |
| 32 | * cpu. */ | ||
| 33 | 32 | ||
| 34 | static __inline__ void udelay (unsigned long usecs) | 33 | #define __MAX_UDELAY 30000 |
| 34 | |||
| 35 | static inline void __udelay(unsigned long usecs) | ||
| 35 | { | 36 | { |
| 36 | unsigned long start = get_ccount(); | 37 | unsigned long start = get_ccount(); |
| 37 | unsigned long cycles = usecs * (loops_per_jiffy / (1000000UL / HZ)); | 38 | unsigned long cycles = (usecs * (ccount_freq >> 15)) >> 5; |
| 38 | 39 | ||
| 39 | /* Note: all variables are unsigned (can wrap around)! */ | 40 | /* Note: all variables are unsigned (can wrap around)! */ |
| 40 | while (((unsigned long)get_ccount()) - start < cycles) | 41 | while (((unsigned long)get_ccount()) - start < cycles) |
| 41 | ; | 42 | cpu_relax(); |
| 43 | } | ||
| 44 | |||
| 45 | static inline void udelay(unsigned long usec) | ||
| 46 | { | ||
| 47 | if (__builtin_constant_p(usec) && usec >= __MAX_UDELAY) | ||
| 48 | __bad_udelay(); | ||
| 49 | else | ||
| 50 | __udelay(usec); | ||
| 42 | } | 51 | } |
| 43 | 52 | ||
| 44 | #endif | 53 | #endif |
