From: Roland Stigge <stigge@antcom.de>
To: w.sang@pengutronix.de, bangaragiri.g@nxp.com,
srinivas.bakki@nxp.com, sundarapandian.andithevar@nxp.com,
linus.walleij@linaro.org, linux-kernel@vger.kernel.org,
kevin.wells@nxp.com, grant.likely@secretlab.ca,
linux-arm-kernel@lists.infradead.org
Cc: Roland Stigge <stigge@antcom.de>
Subject: [PATCH v2 2/7] LPC32xx: clock.c: jiffies wrapping
Date: Mon, 30 Jan 2012 17:02:01 +0100 [thread overview]
Message-ID: <1327939327-7799-2-git-send-email-stigge@antcom.de> (raw)
In-Reply-To: <1327939327-7799-1-git-send-email-stigge@antcom.de>
This patch fixes the jiffies wrapping bug in clock.c.
It corrects the timeout computation based on jiffies, uses time_before() for
correct wrapping handling and replaces a binary "&" which should really be a
logical "&&" in a truth expression.
Signed-off-by: Roland Stigge <stigge@antcom.de>
diff --git a/arch/arm/mach-lpc32xx/clock.c b/arch/arm/mach-lpc32xx/clock.c
index 8e79313..f64c9a1 100644
--- a/arch/arm/mach-lpc32xx/clock.c
+++ b/arch/arm/mach-lpc32xx/clock.c
@@ -128,7 +128,7 @@ static struct clk osc_32KHz = {
static int local_pll397_enable(struct clk *clk, int enable)
{
u32 reg;
- unsigned long timeout = 1 + msecs_to_jiffies(10);
+ unsigned long timeout = jiffies + msecs_to_jiffies(10);
reg = __raw_readl(LPC32XX_CLKPWR_PLL397_CTRL);
@@ -143,7 +143,7 @@ static int local_pll397_enable(struct clk *clk, int enable)
/* Wait for PLL397 lock */
while (((__raw_readl(LPC32XX_CLKPWR_PLL397_CTRL) &
LPC32XX_CLKPWR_SYSCTRL_PLL397_STS) == 0) &&
- (timeout > jiffies))
+ time_before(jiffies, timeout))
cpu_relax();
if ((__raw_readl(LPC32XX_CLKPWR_PLL397_CTRL) &
@@ -157,7 +157,7 @@ static int local_pll397_enable(struct clk *clk, int enable)
static int local_oscmain_enable(struct clk *clk, int enable)
{
u32 reg;
- unsigned long timeout = 1 + msecs_to_jiffies(10);
+ unsigned long timeout = jiffies + msecs_to_jiffies(10);
reg = __raw_readl(LPC32XX_CLKPWR_MAIN_OSC_CTRL);
@@ -172,7 +172,7 @@ static int local_oscmain_enable(struct clk *clk, int enable)
/* Wait for main oscillator to start */
while (((__raw_readl(LPC32XX_CLKPWR_MAIN_OSC_CTRL) &
LPC32XX_CLKPWR_MOSC_DISABLE) != 0) &&
- (timeout > jiffies))
+ time_before(jiffies, timeout))
cpu_relax();
if ((__raw_readl(LPC32XX_CLKPWR_MAIN_OSC_CTRL) &
@@ -384,7 +384,7 @@ static int local_usbpll_enable(struct clk *clk, int enable)
{
u32 reg;
int ret = -ENODEV;
- unsigned long timeout = 1 + msecs_to_jiffies(10);
+ unsigned long timeout = jiffies + msecs_to_jiffies(10);
reg = __raw_readl(LPC32XX_CLKPWR_USB_CTRL);
@@ -397,7 +397,7 @@ static int local_usbpll_enable(struct clk *clk, int enable)
__raw_writel(reg, LPC32XX_CLKPWR_USB_CTRL);
/* Wait for PLL lock */
- while ((timeout > jiffies) & (ret == -ENODEV)) {
+ while (time_before(jiffies, timeout) && (ret == -ENODEV)) {
reg = __raw_readl(LPC32XX_CLKPWR_USB_CTRL);
if (reg & LPC32XX_CLKPWR_USBCTRL_PLL_STS)
ret = 0;
next prev parent reply other threads:[~2012-01-30 16:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-30 16:02 [PATCH v2 1/7] LPC32xx: clock.c: Missing header file Roland Stigge
2012-01-30 16:02 ` Roland Stigge [this message]
2012-01-31 10:24 ` [PATCH v2 2/7] LPC32xx: clock.c: jiffies wrapping Wolfram Sang
2012-01-30 16:02 ` [PATCH v2 3/7] LPC32xx: clock.c: Clock registration fixes Roland Stigge
2012-01-30 16:02 ` [PATCH v2 4/7] LPC32xx: clock.c: MMC update Roland Stigge
2012-01-30 16:02 ` [PATCH v2 5/7] LPC32xx: clock.c: warning fix Roland Stigge
2012-01-31 10:26 ` Wolfram Sang
2012-01-30 16:02 ` [PATCH v2 6/7] LPC32xx: clock.c: USB PLL fix Roland Stigge
2012-01-31 10:34 ` Wolfram Sang
2012-02-01 13:27 ` Roland Stigge
2012-02-02 16:49 ` Wolfram Sang
2012-02-02 19:20 ` Roland Stigge
2012-02-02 23:01 ` Wolfram Sang
2012-01-30 16:02 ` [PATCH v2 7/7] LPC32xx: clock.c: Fix mutex lock issues Roland Stigge
2012-01-31 10:27 ` Wolfram Sang
2012-01-30 17:56 ` [PATCH v2 1/7] LPC32xx: clock.c: Missing header file Sergei Shtylyov
2012-01-31 10:22 ` Wolfram Sang
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=1327939327-7799-2-git-send-email-stigge@antcom.de \
--to=stigge@antcom.de \
--cc=bangaragiri.g@nxp.com \
--cc=grant.likely@secretlab.ca \
--cc=kevin.wells@nxp.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=srinivas.bakki@nxp.com \
--cc=sundarapandian.andithevar@nxp.com \
--cc=w.sang@pengutronix.de \
/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).