ar71xx: update mips multi-machine stuff
[openwrt.git] / target / linux / ar71xx / patches-2.6.31 / 400-mips-multi-machine-update.patch
1 --- a/arch/mips/kernel/mips_machine.c
2 +++ b/arch/mips/kernel/mips_machine.c
3 @@ -7,12 +7,13 @@
4 *
5 */
6 #include <linux/mm.h>
7 +#include <linux/string.h>
8
9 #include <asm/mips_machine.h>
10 -#include <asm/bootinfo.h>
11
12 static struct list_head mips_machines __initdata =
13 LIST_HEAD_INIT(mips_machines);
14 +static char *mips_machid __initdata;
15
16 char *mips_machine_name = "Unknown";
17
18 @@ -55,20 +56,64 @@ void __init mips_machine_set_name(char *
19 }
20 }
21
22 -void __init mips_machine_setup(unsigned long machtype)
23 +void __init mips_machine_setup(void)
24 {
25 struct mips_machine *mach;
26
27 - mach = mips_machine_find(machtype);
28 + mach = mips_machine_find(mips_machtype);
29 if (!mach) {
30 - printk(KERN_ALERT "MIPS: no machine registered for "
31 - "machtype %lu\n", machtype);
32 + printk(KERN_WARNING "MIPS: no machine registered for "
33 + "machtype %lu\n", mips_machtype);
34 return;
35 }
36
37 mips_machine_set_name(mach->mach_name);
38 - printk(KERN_INFO "MIPS: machine is %s\n", mips_machine_name);
39 + printk(KERN_NOTICE "MIPS: machine is %s\n", mips_machine_name);
40
41 if (mach->mach_setup)
42 mach->mach_setup();
43 }
44 +
45 +int __init mips_machtype_setup(char *id)
46 +{
47 + if (mips_machid == NULL)
48 + mips_machid = id;
49 +
50 + return 1;
51 +}
52 +
53 +__setup("machtype=", mips_machtype_setup);
54 +
55 +static int __init mips_machtype_init(void)
56 +{
57 + struct list_head *this;
58 + struct mips_machine *mach;
59 +
60 + if (mips_machid == NULL)
61 + return 0;
62 +
63 + list_for_each(this, &mips_machines) {
64 + mach = list_entry(this, struct mips_machine, list);
65 + if (strncmp(mach->mach_id, mips_machid,
66 + strlen(mips_machid)) == 0
67 + ) {
68 + mips_machtype = mach->mach_type;
69 + return 0;
70 + }
71 + }
72 +
73 + printk(KERN_WARNING
74 + "MIPS: no machine found for id: '%s', registered machines:\n",
75 + mips_machid);
76 + printk(KERN_WARNING "%32s %s\n", "id", "name");
77 +
78 + list_for_each(this, &mips_machines) {
79 + mach = list_entry(this, struct mips_machine, list);
80 + printk(KERN_WARNING "%32s %s\n",
81 + mach->mach_id, mach->mach_name);
82 + }
83 +
84 + return 0;
85 +}
86 +
87 +core_initcall(mips_machtype_init);
88 --- a/include/asm-mips/mips_machine.h
89 +++ b/include/asm-mips/mips_machine.h
90 @@ -13,24 +13,32 @@
91 #include <linux/init.h>
92 #include <linux/list.h>
93
94 +#include <asm/bootinfo.h>
95 +
96 struct mips_machine {
97 unsigned long mach_type;
98 - void (*mach_setup)(void);
99 + char *mach_id;
100 char *mach_name;
101 + void (*mach_setup)(void);
102 struct list_head list;
103 };
104
105 void mips_machine_register(struct mips_machine *) __init;
106 -void mips_machine_setup(unsigned long machtype) __init;
107 +void mips_machine_setup(void) __init;
108 +int mips_machtype_setup(char *id) __init;
109 void mips_machine_set_name(char *name) __init;
110
111 extern char *mips_machine_name;
112
113 -#define MIPS_MACHINE(_type, _name, _setup) \
114 -static char machine_name_##_type[] __initdata = _name; \
115 -static struct mips_machine machine_##_type __initdata = \
116 +#define MIPS_MACHINE(_type, _id, _name, _setup) \
117 +static char machine_name_##_type[] __initconst \
118 + __aligned(1) = _name; \
119 +static char machine_id_##_type[] __initconst \
120 + __aligned(1) = _id; \
121 +static struct mips_machine machine_##_type __initconst = \
122 { \
123 .mach_type = _type, \
124 + .mach_id = machine_id_##_type, \
125 .mach_name = machine_name_##_type, \
126 .mach_setup = _setup, \
127 }; \
This page took 0.044935 seconds and 5 git commands to generate.