ARM: simplify early machine init hooks
authorRussell King <rmk+kernel@arm.linux.org.uk>
Mon, 20 Dec 2010 10:18:36 +0000 (10:18 +0000)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Fri, 24 Dec 2010 09:49:51 +0000 (09:49 +0000)
Rather than storing each machine init hook separately, store a
pointer to the machine description record and dereference this
instead.  This pointer is only available while the init sections
are present, which is not a problem as we only use it from init
code.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/include/asm/mach/arch.h
arch/arm/include/asm/mach/irq.h
arch/arm/include/asm/mach/time.h
arch/arm/kernel/irq.c
arch/arm/kernel/setup.c
arch/arm/kernel/time.c

index 7d55356..69908dd 100644 (file)
@@ -45,6 +45,11 @@ struct machine_desc {
 #endif
 };
 
+/*
+ * Current machine - only accessible during boot.
+ */
+extern struct machine_desc *machine_desc;
+
 /*
  * Set of macros to define architecture features.  This is built into
  * a table by the linker.
index 6ecdad9..831e814 100644 (file)
@@ -17,8 +17,6 @@ struct seq_file;
 /*
  * This is internal.  Do not use it.
  */
-extern unsigned int arch_nr_irqs;
-extern void (*init_arch_irq)(void);
 extern void init_FIQ(void);
 extern int show_fiq_list(struct seq_file *, void *);
 
index 35d408f..883f6be 100644 (file)
@@ -43,7 +43,6 @@ struct sys_timer {
 #endif
 };
 
-extern struct sys_timer *system_timer;
 extern void timer_tick(void);
 
 #endif
index 36ad3be..a591971 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/proc_fs.h>
 
 #include <asm/system.h>
+#include <asm/mach/arch.h>
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
 
@@ -47,8 +48,6 @@
 #define irq_finish(irq) do { } while (0)
 #endif
 
-unsigned int arch_nr_irqs;
-void (*init_arch_irq)(void) __initdata = NULL;
 unsigned long irq_err_count;
 
 int show_interrupts(struct seq_file *p, void *v)
@@ -154,13 +153,13 @@ void set_irq_flags(unsigned int irq, unsigned int iflags)
 
 void __init init_IRQ(void)
 {
-       init_arch_irq();
+       machine_desc->init_irq();
 }
 
 #ifdef CONFIG_SPARSE_IRQ
 int __init arch_probe_nr_irqs(void)
 {
-       nr_irqs = arch_nr_irqs ? arch_nr_irqs : NR_IRQS;
+       nr_irqs = machine_desc->nr_irqs ? machine_desc->nr_irqs : NR_IRQS;
        return nr_irqs;
 }
 #endif
index 0826f36..e53132e 100644 (file)
@@ -126,6 +126,7 @@ EXPORT_SYMBOL(elf_platform);
 static const char *cpu_name;
 static const char *machine_name;
 static char __initdata cmd_line[COMMAND_LINE_SIZE];
+struct machine_desc *machine_desc __initdata;
 
 static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
 static union { char c[4]; unsigned long l; } endian_test __initdata = { { 'l', '?', '?', 'b' } };
@@ -708,13 +709,11 @@ static struct init_tags {
        { 0, ATAG_NONE }
 };
 
-static void (*init_machine)(void) __initdata;
-
 static int __init customize_machine(void)
 {
        /* customizes platform devices, or adds new ones */
-       if (init_machine)
-               init_machine();
+       if (machine_desc->init_machine)
+               machine_desc->init_machine();
        return 0;
 }
 arch_initcall(customize_machine);
@@ -809,6 +808,7 @@ void __init setup_arch(char **cmdline_p)
 
        setup_processor();
        mdesc = setup_machine(machine_arch_type);
+       machine_desc = mdesc;
        machine_name = mdesc->name;
 
        if (mdesc->soft_reboot)
@@ -868,13 +868,6 @@ void __init setup_arch(char **cmdline_p)
        cpu_init();
        tcm_init();
 
-       /*
-        * Set up various architecture-specific pointers
-        */
-       arch_nr_irqs = mdesc->nr_irqs;
-       init_arch_irq = mdesc->init_irq;
-       system_timer = mdesc->timer;
-       init_machine = mdesc->init_machine;
 #ifdef CONFIG_MULTI_IRQ_HANDLER
        handle_arch_irq = mdesc->handle_irq;
 #endif
index 38c261f..f1e2eb1 100644 (file)
 #include <asm/leds.h>
 #include <asm/thread_info.h>
 #include <asm/stacktrace.h>
+#include <asm/mach/arch.h>
 #include <asm/mach/time.h>
 
 /*
  * Our system timer.
  */
-struct sys_timer *system_timer;
+static struct sys_timer *system_timer;
 
 #if defined(CONFIG_RTC_DRV_CMOS) || defined(CONFIG_RTC_DRV_CMOS_MODULE)
 /* this needs a better home */
@@ -160,6 +161,7 @@ device_initcall(timer_init_sysfs);
 
 void __init time_init(void)
 {
+       system_timer = machine_desc->timer;
        system_timer->init();
 }