From: paul@pwsan.com (Paul Walmsley)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] OMAP clock/hwmod: fix off-by-one errors
Date: Mon, 16 Nov 2009 06:36:55 -0700 [thread overview]
Message-ID: <20091116133654.14128.175.stgit@localhost.localdomain> (raw)
In-Reply-To: <20091116133237.14128.39687.stgit@localhost.localdomain>
Fix loop bailout off-by-one bugs reported by Juha Lepp?nen
<juha_motorsportcom@luukku.com>.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Cc: Juha Lepp?nen <juha_motorsportcom@luukku.com>
---
arch/arm/mach-omap2/cm.c | 2 +-
arch/arm/mach-omap2/omap_hwmod.c | 12 +++++-------
arch/arm/mach-omap2/prcm.c | 4 ++--
3 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/arch/arm/mach-omap2/cm.c b/arch/arm/mach-omap2/cm.c
index 8eb2dab..0766e52 100644
--- a/arch/arm/mach-omap2/cm.c
+++ b/arch/arm/mach-omap2/cm.c
@@ -65,6 +65,6 @@ int omap2_cm_wait_module_ready(s16 prcm_mod, u8 idlest_id, u8 idlest_shift)
(i++ < MAX_MODULE_READY_TIME))
udelay(1);
- return (i < MAX_MODULE_READY_TIME) ? 0 : -EBUSY;
+ return (i <= MAX_MODULE_READY_TIME) ? 0 : -EBUSY;
}
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 633b216..a4a9518 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -759,14 +759,12 @@ static int _reset(struct omap_hwmod *oh)
_write_sysconfig(v, oh);
c = 0;
- while (c < MAX_MODULE_RESET_WAIT &&
- !(omap_hwmod_readl(oh, oh->sysconfig->syss_offs) &
- SYSS_RESETDONE_MASK)) {
+ while (!(omap_hwmod_readl(oh, oh->sysconfig->syss_offs) &
+ SYSS_RESETDONE_MASK) &&
+ (c++ < MAX_MODULE_RESET_WAIT))
udelay(1);
- c++;
- }
- if (c == MAX_MODULE_RESET_WAIT)
+ if (c > MAX_MODULE_RESET_WAIT)
WARN(1, "omap_hwmod: %s: failed to reset in %d usec\n",
oh->name, MAX_MODULE_RESET_WAIT);
else
@@ -777,7 +775,7 @@ static int _reset(struct omap_hwmod *oh)
* _wait_target_ready() or _reset()
*/
- return (c == MAX_MODULE_RESET_WAIT) ? -ETIMEDOUT : 0;
+ return (c > MAX_MODULE_RESET_WAIT) ? -ETIMEDOUT : 0;
}
/**
diff --git a/arch/arm/mach-omap2/prcm.c b/arch/arm/mach-omap2/prcm.c
index 029d376..d486709 100644
--- a/arch/arm/mach-omap2/prcm.c
+++ b/arch/arm/mach-omap2/prcm.c
@@ -251,14 +251,14 @@ int omap2_cm_wait_idlest(void __iomem *reg, u32 mask, const char *name)
(i++ < MAX_MODULE_ENABLE_WAIT))
udelay(1);
- if (i < MAX_MODULE_ENABLE_WAIT)
+ if (i <= MAX_MODULE_ENABLE_WAIT)
pr_debug("cm: Module associated with clock %s ready after %d "
"loops\n", name, i);
else
pr_err("cm: Module associated with clock %s didn't enable in "
"%d tries\n", name, MAX_MODULE_ENABLE_WAIT);
- return (i < MAX_MODULE_ENABLE_WAIT) ? 1 : 0;
+ return (i <= MAX_MODULE_ENABLE_WAIT) ? 1 : 0;
};
void __init omap2_set_globals_prcm(struct omap_globals *omap2_globals)
next prev parent reply other threads:[~2009-11-16 13:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-16 13:36 [PATCH 0/3] OMAP clock and PM architecture fixes for 2.6.32-rc6 Paul Walmsley
2009-11-16 13:36 ` [PATCH 1/3] OMAP3 clock: Fix the DPLL freqsel computations Paul Walmsley
2009-11-16 13:36 ` [PATCH 2/3] OMAP3: Clock: Fixed dpll3_m2x2 rate calculation Paul Walmsley
2009-11-16 13:36 ` Paul Walmsley [this message]
2009-11-16 14:08 ` [PATCH 3/3] OMAP clock/hwmod: fix off-by-one errors Russell King - ARM Linux
2009-11-17 17:39 ` Paul Walmsley
2009-11-17 17:50 ` Pandita, Vikram
2009-11-17 22:24 ` Tony Lindgren
2009-11-18 18:47 ` Tony Lindgren
2009-11-18 19:11 ` Paul Walmsley
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=20091116133654.14128.175.stgit@localhost.localdomain \
--to=paul@pwsan.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).