package: fix insmod on install
[openwrt/openwrt.git] / target / linux / ramips / patches-3.8 / 0100-MIPS-move-mips_-set-get-_machine_name-to-a-more-gene.patch
1 From dd4bb7e821d112bff981016fd4e7c014ca9425f9 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Thu, 11 Apr 2013 05:34:59 +0000
4 Subject: [PATCH 100/137] MIPS: move mips_{set,get}_machine_name() to a more
5 generic place
6
7 Previously this functionality was only available to users of the mips_machine
8 api. Moving the code to prom.c allows us to also add a OF wrapper.
9
10 Signed-off-by: John Crispin <blogic@openwrt.org>
11 Patchwork: http://patchwork.linux-mips.org/patch/5164/
12 ---
13 arch/mips/include/asm/mips_machine.h | 4 ----
14 arch/mips/include/asm/prom.h | 3 +++
15 arch/mips/kernel/mips_machine.c | 21 ---------------------
16 arch/mips/kernel/proc.c | 2 +-
17 arch/mips/kernel/prom.c | 31 +++++++++++++++++++++++++++++++
18 5 files changed, 35 insertions(+), 26 deletions(-)
19
20 --- a/arch/mips/include/asm/mips_machine.h
21 +++ b/arch/mips/include/asm/mips_machine.h
22 @@ -42,13 +42,9 @@ extern long __mips_machines_end;
23 #ifdef CONFIG_MIPS_MACHINE
24 int mips_machtype_setup(char *id) __init;
25 void mips_machine_setup(void) __init;
26 -void mips_set_machine_name(const char *name) __init;
27 -char *mips_get_machine_name(void);
28 #else
29 static inline int mips_machtype_setup(char *id) { return 1; }
30 static inline void mips_machine_setup(void) { }
31 -static inline void mips_set_machine_name(const char *name) { }
32 -static inline char *mips_get_machine_name(void) { return NULL; }
33 #endif /* CONFIG_MIPS_MACHINE */
34
35 #endif /* __ASM_MIPS_MACHINE_H */
36 --- a/arch/mips/include/asm/prom.h
37 +++ b/arch/mips/include/asm/prom.h
38 @@ -48,4 +48,7 @@ extern void __dt_setup_arch(struct boot_
39 static inline void device_tree_init(void) { }
40 #endif /* CONFIG_OF */
41
42 +extern char *mips_get_machine_name(void);
43 +extern void mips_set_machine_name(const char *name);
44 +
45 #endif /* __ASM_PROM_H */
46 --- a/arch/mips/kernel/mips_machine.c
47 +++ b/arch/mips/kernel/mips_machine.c
48 @@ -13,7 +13,6 @@
49 #include <asm/mips_machine.h>
50
51 static struct mips_machine *mips_machine __initdata;
52 -static char *mips_machine_name = "Unknown";
53
54 #define for_each_machine(mach) \
55 for ((mach) = (struct mips_machine *)&__mips_machines_start; \
56 @@ -21,25 +20,6 @@ static char *mips_machine_name = "Unknow
57 (unsigned long)(mach) < (unsigned long)&__mips_machines_end; \
58 (mach)++)
59
60 -__init void mips_set_machine_name(const char *name)
61 -{
62 - char *p;
63 -
64 - if (name == NULL)
65 - return;
66 -
67 - p = kstrdup(name, GFP_KERNEL);
68 - if (!p)
69 - pr_err("MIPS: no memory for machine_name\n");
70 -
71 - mips_machine_name = p;
72 -}
73 -
74 -char *mips_get_machine_name(void)
75 -{
76 - return mips_machine_name;
77 -}
78 -
79 __init int mips_machtype_setup(char *id)
80 {
81 struct mips_machine *mach;
82 @@ -79,7 +59,6 @@ __init void mips_machine_setup(void)
83 return;
84
85 mips_set_machine_name(mips_machine->mach_name);
86 - pr_info("MIPS: machine is %s\n", mips_machine_name);
87
88 if (mips_machine->mach_setup)
89 mips_machine->mach_setup();
90 --- a/arch/mips/kernel/proc.c
91 +++ b/arch/mips/kernel/proc.c
92 @@ -12,7 +12,7 @@
93 #include <asm/cpu-features.h>
94 #include <asm/mipsregs.h>
95 #include <asm/processor.h>
96 -#include <asm/mips_machine.h>
97 +#include <asm/prom.h>
98
99 unsigned int vced_count, vcei_count;
100
101 --- a/arch/mips/kernel/prom.c
102 +++ b/arch/mips/kernel/prom.c
103 @@ -23,6 +23,22 @@
104 #include <asm/page.h>
105 #include <asm/prom.h>
106
107 +static char mips_machine_name[64] = "Unknown";
108 +
109 +__init void mips_set_machine_name(const char *name)
110 +{
111 + if (name == NULL)
112 + return;
113 +
114 + strncpy(mips_machine_name, name, sizeof(mips_machine_name));
115 + pr_info("MIPS: machine is %s\n", mips_get_machine_name());
116 +}
117 +
118 +char *mips_get_machine_name(void)
119 +{
120 + return mips_machine_name;
121 +}
122 +
123 int __init early_init_dt_scan_memory_arch(unsigned long node,
124 const char *uname, int depth,
125 void *data)
126 @@ -50,6 +66,18 @@ void __init early_init_dt_setup_initrd_a
127 }
128 #endif
129
130 +int __init early_init_dt_scan_model(unsigned long node, const char *uname,
131 + int depth, void *data)
132 +{
133 + if (!depth) {
134 + char *model = of_get_flat_dt_prop(node, "model", NULL);
135 +
136 + if (model)
137 + mips_set_machine_name(model);
138 + }
139 + return 0;
140 +}
141 +
142 void __init early_init_devtree(void *params)
143 {
144 /* Setup flat device-tree pointer */
145 @@ -65,6 +93,9 @@ void __init early_init_devtree(void *par
146 /* Scan memory nodes */
147 of_scan_flat_dt(early_init_dt_scan_root, NULL);
148 of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL);
149 +
150 + /* try to load the mips machine name */
151 + of_scan_flat_dt(early_init_dt_scan_model, NULL);
152 }
153
154 void __init __dt_setup_arch(struct boot_param_header *bph)