1 From 67d6534cdc4f90e6998a79ac57d5318412f18486 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/164] MIPS: move mips_{set,get}_machine_name() to a more
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.
10 Signed-off-by: John Crispin <blogic@openwrt.org>
11 Patchwork: http://patchwork.linux-mips.org/patch/5164/
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(-)
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);
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 */
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 */
42 +extern char *mips_get_machine_name(void);
43 +extern void mips_set_machine_name(const char *name);
45 #endif /* __ASM_PROM_H */
46 --- a/arch/mips/kernel/mips_machine.c
47 +++ b/arch/mips/kernel/mips_machine.c
49 #include <asm/mips_machine.h>
51 static struct mips_machine *mips_machine __initdata;
52 -static char *mips_machine_name = "Unknown";
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; \
60 -__init void mips_set_machine_name(const char *name)
67 - p = kstrdup(name, GFP_KERNEL);
69 - pr_err("MIPS: no memory for machine_name\n");
71 - mips_machine_name = p;
74 -char *mips_get_machine_name(void)
76 - return mips_machine_name;
79 __init int mips_machtype_setup(char *id)
81 struct mips_machine *mach;
82 @@ -79,7 +59,6 @@ __init void mips_machine_setup(void)
85 mips_set_machine_name(mips_machine->mach_name);
86 - pr_info("MIPS: machine is %s\n", mips_machine_name);
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
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>
99 unsigned int vced_count, vcei_count;
101 --- a/arch/mips/kernel/prom.c
102 +++ b/arch/mips/kernel/prom.c
104 #include <asm/page.h>
105 #include <asm/prom.h>
107 +static char mips_machine_name[64] = "Unknown";
109 +__init void mips_set_machine_name(const char *name)
114 + strncpy(mips_machine_name, name, sizeof(mips_machine_name));
115 + pr_info("MIPS: machine is %s\n", mips_get_machine_name());
118 +char *mips_get_machine_name(void)
120 + return mips_machine_name;
123 int __init early_init_dt_scan_memory_arch(unsigned long node,
124 const char *uname, int depth,
126 @@ -50,6 +66,18 @@ void __init early_init_dt_setup_initrd_a
130 +int __init early_init_dt_scan_model(unsigned long node, const char *uname,
131 + int depth, void *data)
134 + char *model = of_get_flat_dt_prop(node, "model", NULL);
137 + mips_set_machine_name(model);
142 void __init early_init_devtree(void *params)
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);
150 + /* try to load the mips machine name */
151 + of_scan_flat_dt(early_init_dt_scan_model, NULL);
154 void __init __dt_setup_arch(struct boot_param_header *bph)