OMAP2xxx clock: pre-initialize struct clks early
authorPaul Walmsley <paul@pwsan.com>
Thu, 23 Apr 2009 01:48:53 +0000 (19:48 -0600)
committerpaul <paul@twilight.(none)>
Thu, 23 Apr 2009 01:48:53 +0000 (19:48 -0600)
Commit 3f0a820c4c0b4670fb5f164baa5582e23c2ef118 breaks OMAP2xxx boot
during initial propagate_rate() on osc_ck and sys_ck.  Fix by
pre-initializing all struct clks before running any other clock init
code.  Incorporates review comments from Russell King
<rmk+kernel@arm.linux.org.uk>.

Resolves

<1>Unable to handle kernel NULL pointer dereference at virtual address 00000000
<1>pgd = c0004000
<1>[00000000] *pgd=00000000
Internal error: Oops: 5 [#1]
Modules linked in:
CPU: 0    Not tainted  (2.6.29-omap1 #37)
PC is at propagate_rate+0x10/0x60
LR is at omap2_clk_init+0x30/0x218
...

Signed-off-by: Paul Walmsley <paul@pwsan.com>
Tested-by: Jarkko Nikula <jarkko.nikula@nokia.com>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/mach-omap2/clock24xx.c
arch/arm/plat-omap/clock.c

index 1e839c5..984fb86 100644 (file)
@@ -720,14 +720,14 @@ int __init omap2_clk_init(void)
 
        clk_init(&omap2_clk_functions);
 
+       for (c = omap24xx_clks; c < omap24xx_clks + ARRAY_SIZE(omap24xx_clks); c++)
+               clk_init_one(c->lk.clk);
+
        osc_ck.rate = omap2_osc_clk_recalc(&osc_ck);
        propagate_rate(&osc_ck);
        sys_ck.rate = omap2_sys_clk_recalc(&sys_ck);
        propagate_rate(&sys_ck);
 
-       for (c = omap24xx_clks; c < omap24xx_clks + ARRAY_SIZE(omap24xx_clks); c++)
-               clk_init_one(c->lk.clk);
-
        cpu_mask = 0;
        if (cpu_is_omap2420())
                cpu_mask |= CK_242X;
index 2e06145..29efc27 100644 (file)
@@ -239,6 +239,13 @@ void recalculate_root_clocks(void)
        }
 }
 
+/**
+ * clk_init_one - initialize any fields in the struct clk before clk init
+ * @clk: struct clk * to initialize
+ *
+ * Initialize any struct clk fields needed before normal clk initialization
+ * can run.  No return value.
+ */
 void clk_init_one(struct clk *clk)
 {
        INIT_LIST_HEAD(&clk->children);