From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] Fix LPC32XX's clock.c
Date: Sat, 28 Jan 2012 16:00:11 +0000 [thread overview]
Message-ID: <20120128160011.GA15455@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1327673868-19741-1-git-send-email-stigge@antcom.de>
On Fri, Jan 27, 2012 at 03:17:48PM +0100, Roland Stigge wrote:
> @@ -382,30 +388,62 @@ static u32 local_clk_usbpll_setup(struct clk_pll_setup *pHCLKPllSetup)
> static int local_usbpll_enable(struct clk *clk, int enable)
> {
> u32 reg;
> - int ret = -ENODEV;
> - unsigned long timeout = 1 + msecs_to_jiffies(10);
> + int ret = 0;
> + unsigned long timeout = jiffies + msecs_to_jiffies(20);
...
> - /* Wait for PLL lock */
> - while ((timeout > jiffies) & (ret == -ENODEV)) {
> + /*
> + * Enable PLL
> + */
> + reg |= LPC32XX_CLKPWR_USBCTRL_PLL_PWRUP;
> + __raw_writel(reg, LPC32XX_CLKPWR_USB_CTRL);
> +
> + /*
> + * Wait for PLL to lock
> + */
> + while ((timeout > jiffies) && (ret == -ENODEV)) {
This is buggy - it's waiting to go wrong when jiffies wraps. You really
want to use time_before() or time_after() to make these comparisons, which
are safe against wrap-around.
prev parent reply other threads:[~2012-01-28 16:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-27 14:17 [PATCH] Fix LPC32XX's clock.c Roland Stigge
2012-01-27 22:32 ` Wolfram Sang
2012-01-28 10:41 ` Roland Stigge
2012-01-28 16:00 ` Russell King - ARM Linux [this message]
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=20120128160011.GA15455@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--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).