diff options
author | Paul Walmsley <paul@pwsan.com> | 2009-12-08 18:33:16 -0500 |
---|---|---|
committer | paul <paul@twilight.(none)> | 2009-12-11 19:00:43 -0500 |
commit | 6f8b7ff5b01e16a65c3b17865ce047faeca40907 (patch) | |
tree | ae5ecb4b377588b157c23176cf95a5c9631206ba /arch/arm/mach-omap2/omap_hwmod.c | |
parent | 3863c74b512c1afd3ce6b2f81d8dea9f1d860968 (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/mach-omap2/omap_hwmod.c')
-rw-r--r-- | arch/arm/mach-omap2/omap_hwmod.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index 633b216a8b2..7aaf5f1eea7 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <linux/mutex.h> | 45 | #include <linux/mutex.h> |
46 | #include <linux/bootmem.h> | 46 | #include <linux/bootmem.h> |
47 | 47 | ||
48 | #include <plat/common.h> | ||
48 | #include <plat/cpu.h> | 49 | #include <plat/cpu.h> |
49 | #include <plat/clockdomain.h> | 50 | #include <plat/clockdomain.h> |
50 | #include <plat/powerdomain.h> | 51 | #include <plat/powerdomain.h> |
@@ -736,7 +737,7 @@ static int _wait_target_ready(struct omap_hwmod *oh) | |||
736 | static int _reset(struct omap_hwmod *oh) | 737 | static int _reset(struct omap_hwmod *oh) |
737 | { | 738 | { |
738 | u32 r, v; | 739 | u32 r, v; |
739 | int c; | 740 | int c = 0; |
740 | 741 | ||
741 | if (!oh->sysconfig || | 742 | if (!oh->sysconfig || |
742 | !(oh->sysconfig->sysc_flags & SYSC_HAS_SOFTRESET) || | 743 | !(oh->sysconfig->sysc_flags & SYSC_HAS_SOFTRESET) || |
@@ -758,13 +759,9 @@ static int _reset(struct omap_hwmod *oh) | |||
758 | return r; | 759 | return r; |
759 | _write_sysconfig(v, oh); | 760 | _write_sysconfig(v, oh); |
760 | 761 | ||
761 | c = 0; | 762 | omap_test_timeout((omap_hwmod_readl(oh, oh->sysconfig->syss_offs) & |
762 | while (c < MAX_MODULE_RESET_WAIT && | 763 | SYSS_RESETDONE_MASK), |
763 | !(omap_hwmod_readl(oh, oh->sysconfig->syss_offs) & | 764 | MAX_MODULE_RESET_WAIT, c); |
764 | SYSS_RESETDONE_MASK)) { | ||
765 | udelay(1); | ||
766 | c++; | ||
767 | } | ||
768 | 765 | ||
769 | if (c == MAX_MODULE_RESET_WAIT) | 766 | if (c == MAX_MODULE_RESET_WAIT) |
770 | WARN(1, "omap_hwmod: %s: failed to reset in %d usec\n", | 767 | WARN(1, "omap_hwmod: %s: failed to reset in %d usec\n", |