1 --- a/arch/mips/include/asm/mips_machine.h
2 +++ b/arch/mips/include/asm/mips_machine.h
5 - * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
6 + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
11 #include <linux/init.h>
12 #include <linux/list.h>
14 -#include <asm/bootinfo.h>
17 unsigned long mach_type;
18 - const char *mach_id;
19 - const char *mach_name;
20 void (*mach_setup)(void);
22 + struct list_head list;
25 -#define MIPS_MACHINE(_type, _id, _name, _setup) \
26 -static const char machine_name_##_type[] __initconst \
27 - __aligned(1) = _name; \
28 -static const char machine_id_##_type[] __initconst \
29 - __aligned(1) = _id; \
30 -static struct mips_machine machine_##_type \
31 - __used __section(.mips.machines.init) = \
32 +void mips_machine_register(struct mips_machine *) __init;
33 +void mips_machine_setup(unsigned long machtype) __init;
34 +void mips_machine_set_name(char *name) __init;
36 +extern char *mips_machine_name;
38 +#define MIPS_MACHINE(_type, _name, _setup) \
39 +static char machine_name_##_type[] __initdata = _name; \
40 +static struct mips_machine machine_##_type __initdata = \
43 - .mach_id = machine_id_##_type, \
44 .mach_name = machine_name_##_type, \
45 .mach_setup = _setup, \
48 -extern long __mips_machines_start;
49 -extern long __mips_machines_end;
51 -#ifdef CONFIG_MIPS_MACHINE
52 -int mips_machtype_setup(char *id) __init;
53 -void mips_machine_setup(void) __init;
54 -void mips_set_machine_name(const char *name) __init;
55 -char *mips_get_machine_name(void);
57 -static inline int mips_machtype_setup(char *id) { return 1; }
58 -static inline void mips_machine_setup(void) { }
59 -static inline void mips_set_machine_name(const char *name) { }
60 -static inline char *mips_get_machine_name(void) { return NULL; }
61 -#endif /* CONFIG_MIPS_MACHINE */
64 +static int __init register_machine_##_type(void) \
66 + mips_machine_register(&machine_##_type); \
70 +pure_initcall(register_machine_##_type)
72 #endif /* __ASM_MIPS_MACHINE_H */
74 --- a/arch/mips/kernel/mips_machine.c
75 +++ b/arch/mips/kernel/mips_machine.c
78 - * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
79 + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
81 * This program is free software; you can redistribute it and/or modify it
82 * under the terms of the GNU General Public License version 2 as published
87 -#include <linux/string.h>
88 -#include <linux/slab.h>
90 #include <asm/mips_machine.h>
91 +#include <asm/bootinfo.h>
93 -static struct mips_machine *mips_machine __initdata;
94 -static char *mips_machine_name = "Unknown";
95 +static struct list_head mips_machines __initdata =
96 + LIST_HEAD_INIT(mips_machines);
98 -#define for_each_machine(mach) \
99 - for ((mach) = (struct mips_machine *)&__mips_machines_start; \
101 - (unsigned long)(mach) < (unsigned long)&__mips_machines_end; \
103 +char *mips_machine_name = "Unknown";
105 -__init void mips_set_machine_name(const char *name)
106 +static struct mips_machine * __init mips_machine_find(unsigned long machtype)
109 + struct list_head *this;
113 + list_for_each(this, &mips_machines) {
114 + struct mips_machine *mach;
116 - p = kstrdup(name, GFP_KERNEL);
118 - pr_err("MIPS: no memory for machine_name\n");
119 + mach = list_entry(this, struct mips_machine, list);
120 + if (mach->mach_type == machtype)
124 - mips_machine_name = p;
128 -char *mips_get_machine_name(void)
129 +void __init mips_machine_register(struct mips_machine *mach)
131 - return mips_machine_name;
132 + list_add_tail(&mach->list, &mips_machines);
135 -__init int mips_machtype_setup(char *id)
136 +void __init mips_machine_set_name(char *name)
138 - struct mips_machine *mach;
142 - for_each_machine(mach) {
143 - if (mach->mach_id == NULL)
146 - if (strcmp(mach->mach_id, id) == 0) {
147 - mips_machine = mach;
154 - if (!mips_machine) {
155 - pr_err("MIPS: no machine found for id '%s', supported machines:\n",
157 - pr_err("%32s %s\n", "id", "name");
158 - for_each_machine(mach)
159 - pr_err("%32s %s\n", mach->mach_id, mach->mach_name);
161 + len = strlen(name);
162 + p = kmalloc(len + 1, GFP_KERNEL);
164 + strncpy(p, name, len);
166 + mips_machine_name = p;
168 + printk(KERN_WARNING "MIPS: no memory for machine_name\n");
171 - mips_machtype = mips_machine->mach_type;
176 -__setup("machtype=", mips_machtype_setup);
178 -__init void mips_machine_setup(void)
179 +void __init mips_machine_setup(unsigned long machtype)
182 + struct mips_machine *mach;
184 + mach = mips_machine_find(machtype);
186 + printk(KERN_ALERT "MIPS: no machine registered for "
187 + "machtype %lu\n", machtype);
191 - mips_set_machine_name(mips_machine->mach_name);
192 - pr_info("MIPS: machine is %s\n", mips_machine_name);
193 + mips_machine_set_name(mach->mach_name);
194 + printk(KERN_INFO "MIPS: machine is %s\n", mips_machine_name);
196 - if (mips_machine->mach_setup)
197 - mips_machine->mach_setup();
198 + if (mach->mach_setup)
199 + mach->mach_setup();
201 --- a/arch/mips/kernel/proc.c
202 +++ b/arch/mips/kernel/proc.c
203 @@ -34,9 +34,9 @@ static int show_cpuinfo(struct seq_file
206 seq_printf(m, "system type\t\t: %s\n", get_system_type());
207 - if (mips_get_machine_name())
208 - seq_printf(m, "machine\t\t\t: %s\n",
209 - mips_get_machine_name());
210 +#ifdef CONFIG_MIPS_MACHINE
211 + seq_printf(m, "machine\t\t\t: %s\n", mips_machine_name);
215 seq_printf(m, "processor\t\t: %ld\n", n);
216 --- a/arch/mips/kernel/vmlinux.lds.S
217 +++ b/arch/mips/kernel/vmlinux.lds.S
218 @@ -98,13 +98,6 @@ SECTIONS
219 INIT_TEXT_SECTION(PAGE_SIZE)
220 INIT_DATA_SECTION(16)
223 - .mips.machines.init : AT(ADDR(.mips.machines.init) - LOAD_OFFSET) {
224 - __mips_machines_start = .;
225 - *(.mips.machines.init)
226 - __mips_machines_end = .;
229 /* .exit.text is discarded at runtime, not link time, to deal with
230 * references from .rodata