aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap/include
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2009-12-08 18:33:16 -0500
committerpaul <paul@twilight.(none)>2009-12-11 19:00:43 -0500
commit6f8b7ff5b01e16a65c3b17865ce047faeca40907 (patch)
treeae5ecb4b377588b157c23176cf95a5c9631206ba /arch/arm/plat-omap/include
parent3863c74b512c1afd3ce6b2f81d8dea9f1d860968 (diff)
OMAP clock/hwmod: fix off-by-one errors
Fix loop bailout off-by-one bugs reported by Juha Leppänen <juha_motorsportcom@luukku.com>. This second version incorporates comments from Russell King <linux@arm.linux.org.uk>. A new macro, 'omap_test_timeout', has been created, with cleaner code, and existing code has been converted to use it. Signed-off-by: Paul Walmsley <paul@pwsan.com> Cc: Juha Leppänen <juha_motorsportcom@luukku.com> Cc: Russell King <linux@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/plat-omap/include')
-rw-r--r--arch/arm/plat-omap/include/plat/common.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/arch/arm/plat-omap/include/plat/common.h b/arch/arm/plat-omap/include/plat/common.h
index 064f1730f43b..e9779676448b 100644
--- a/arch/arm/plat-omap/include/plat/common.h
+++ b/arch/arm/plat-omap/include/plat/common.h
@@ -71,4 +71,24 @@ void omap2_set_globals_sdrc(struct omap_globals *);
71void omap2_set_globals_control(struct omap_globals *); 71void omap2_set_globals_control(struct omap_globals *);
72void omap2_set_globals_prcm(struct omap_globals *); 72void omap2_set_globals_prcm(struct omap_globals *);
73 73
74/**
75 * omap_test_timeout - busy-loop, testing a condition
76 * @cond: condition to test until it evaluates to true
77 * @timeout: maximum number of microseconds in the timeout
78 * @index: loop index (integer)
79 *
80 * Loop waiting for @cond to become true or until at least @timeout
81 * microseconds have passed. To use, define some integer @index in the
82 * calling code. After running, if @index == @timeout, then the loop has
83 * timed out.
84 */
85#define omap_test_timeout(cond, timeout, index) \
86({ \
87 for (index = 0; index < timeout; index++) { \
88 if (cond) \
89 break; \
90 udelay(1); \
91 } \
92})
93
74#endif /* __ARCH_ARM_MACH_OMAP_COMMON_H */ 94#endif /* __ARCH_ARM_MACH_OMAP_COMMON_H */