[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20120128160011.GA15455@n2100.arm.linux.org.uk>
Date: Sat, 28 Jan 2012 16:00:11 +0000
From: Russell King - ARM Linux <linux@....linux.org.uk>
To: Roland Stigge <stigge@...com.de>
Cc: w.sang@...gutronix.de, grant.likely@...retlab.ca,
linus.walleij@...aro.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Fix LPC32XX's clock.c
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists