sh: Support early clkdev allocations.
authorPaul Mundt <lethal@linux-sh.org>
Mon, 8 Mar 2010 12:46:37 +0000 (21:46 +0900)
committerPaul Mundt <lethal@linux-sh.org>
Tue, 9 Mar 2010 02:57:18 +0000 (11:57 +0900)
early platform devices and the like may need to set up clock aliases,
which require an allocation at a time well before the slab allocators
are available. The clock framework comes up after bootmem, so using
bootmem as a fallback should be sufficient.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
arch/sh/kernel/clkdev.c

index 29cd802ac3882082b757a9df15ac49f7cf88e123..defdd6e309084e406ad70d655004d6742b7e9b1b 100644 (file)
@@ -20,6 +20,9 @@
 #include <linux/string.h>
 #include <linux/mutex.h>
 #include <linux/clk.h>
+#include <linux/slab.h>
+#include <linux/bootmem.h>
+#include <linux/mm.h>
 #include <asm/clock.h>
 #include <asm/clkdev.h>
 
@@ -103,12 +106,16 @@ struct clk_lookup_alloc {
        char    con_id[MAX_CON_ID];
 };
 
-struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
-       const char *dev_fmt, ...)
+struct clk_lookup * __init_refok
+clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
 {
        struct clk_lookup_alloc *cla;
 
-       cla = kzalloc(sizeof(*cla), GFP_KERNEL);
+       if (!slab_is_available())
+               cla = alloc_bootmem_low_pages(sizeof(*cla));
+       else
+               cla = kzalloc(sizeof(*cla), GFP_KERNEL);
+
        if (!cla)
                return NULL;