ar71xx: clarify the nand subtarget a bit
[openwrt/svn-archive/archive.git] / target / linux / adm5120 / patches-2.6.33 / 400-revert-mips-machine-update.patch
1 --- a/arch/mips/include/asm/mips_machine.h
2 +++ b/arch/mips/include/asm/mips_machine.h
3 @@ -1,5 +1,5 @@
4 /*
5 - * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
6 + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
7 *
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
10 @@ -13,42 +13,35 @@
11 #include <linux/init.h>
12 #include <linux/list.h>
13
14 -#include <asm/bootinfo.h>
15 -
16 struct mips_machine {
17 unsigned long mach_type;
18 - const char *mach_id;
19 - const char *mach_name;
20 void (*mach_setup)(void);
21 + char *mach_name;
22 + struct list_head list;
23 };
24
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;
35 +
36 +extern char *mips_machine_name;
37 +
38 +#define MIPS_MACHINE(_type, _name, _setup) \
39 +static char machine_name_##_type[] __initdata = _name; \
40 +static struct mips_machine machine_##_type __initdata = \
41 { \
42 .mach_type = _type, \
43 - .mach_id = machine_id_##_type, \
44 .mach_name = machine_name_##_type, \
45 .mach_setup = _setup, \
46 -};
47 -
48 -extern long __mips_machines_start;
49 -extern long __mips_machines_end;
50 -
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);
56 -#else
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 */
62 +}; \
63 + \
64 +static int __init register_machine_##_type(void) \
65 +{ \
66 + mips_machine_register(&machine_##_type); \
67 + return 0; \
68 +} \
69 + \
70 +pure_initcall(register_machine_##_type)
71
72 #endif /* __ASM_MIPS_MACHINE_H */
73 +
74 --- a/arch/mips/kernel/mips_machine.c
75 +++ b/arch/mips/kernel/mips_machine.c
76 @@ -1,5 +1,5 @@
77 /*
78 - * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
79 + * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
80 *
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
83 @@ -7,77 +7,68 @@
84 *
85 */
86 #include <linux/mm.h>
87 -#include <linux/string.h>
88 -#include <linux/slab.h>
89
90 #include <asm/mips_machine.h>
91 +#include <asm/bootinfo.h>
92
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);
97
98 -#define for_each_machine(mach) \
99 - for ((mach) = (struct mips_machine *)&__mips_machines_start; \
100 - (mach) && \
101 - (unsigned long)(mach) < (unsigned long)&__mips_machines_end; \
102 - (mach)++)
103 +char *mips_machine_name = "Unknown";
104
105 -__init void mips_set_machine_name(const char *name)
106 +static struct mips_machine * __init mips_machine_find(unsigned long machtype)
107 {
108 - char *p;
109 + struct list_head *this;
110
111 - if (name == NULL)
112 - return;
113 + list_for_each(this, &mips_machines) {
114 + struct mips_machine *mach;
115
116 - p = kstrdup(name, GFP_KERNEL);
117 - if (!p)
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)
121 + return mach;
122 + }
123
124 - mips_machine_name = p;
125 + return NULL;
126 }
127
128 -char *mips_get_machine_name(void)
129 +void __init mips_machine_register(struct mips_machine *mach)
130 {
131 - return mips_machine_name;
132 + list_add_tail(&mach->list, &mips_machines);
133 }
134
135 -__init int mips_machtype_setup(char *id)
136 +void __init mips_machine_set_name(char *name)
137 {
138 - struct mips_machine *mach;
139 + unsigned int len;
140 + char *p;
141
142 - for_each_machine(mach) {
143 - if (mach->mach_id == NULL)
144 - continue;
145 -
146 - if (strcmp(mach->mach_id, id) == 0) {
147 - mips_machine = mach;
148 - break;
149 - }
150 - }
151 + if (name == NULL)
152 + return;
153
154 - if (!mips_machine) {
155 - pr_err("MIPS: no machine found for id '%s', supported machines:\n",
156 - id);
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);
160 - return 1;
161 + len = strlen(name);
162 + p = kmalloc(len + 1, GFP_KERNEL);
163 + if (p) {
164 + strncpy(p, name, len);
165 + p[len] = '\0';
166 + mips_machine_name = p;
167 + } else {
168 + printk(KERN_WARNING "MIPS: no memory for machine_name\n");
169 }
170 -
171 - mips_machtype = mips_machine->mach_type;
172 -
173 - return 0;
174 }
175
176 -__setup("machtype=", mips_machtype_setup);
177 -
178 -__init void mips_machine_setup(void)
179 +void __init mips_machine_setup(unsigned long machtype)
180 {
181 - if (!mips_machine)
182 + struct mips_machine *mach;
183 +
184 + mach = mips_machine_find(machtype);
185 + if (!mach) {
186 + printk(KERN_ALERT "MIPS: no machine registered for "
187 + "machtype %lu\n", machtype);
188 return;
189 + }
190
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);
195
196 - if (mips_machine->mach_setup)
197 - mips_machine->mach_setup();
198 + if (mach->mach_setup)
199 + mach->mach_setup();
200 }
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
204 */
205 if (n == 0) {
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);
212 +#endif
213 }
214
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)
221
222 - . = ALIGN(4);
223 - .mips.machines.init : AT(ADDR(.mips.machines.init) - LOAD_OFFSET) {
224 - __mips_machines_start = .;
225 - *(.mips.machines.init)
226 - __mips_machines_end = .;
227 - }
228 -
229 /* .exit.text is discarded at runtime, not link time, to deal with
230 * references from .rodata
231 */