ralink: update patches
[openwrt.git] / target / linux / ramips / patches-3.9 / 0100-MIPS-move-mips_-set-get-_machine_name-to-a-more-gene.patch
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
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 diff --git a/arch/mips/include/asm/mips_machine.h b/arch/mips/include/asm/mips_machine.h
21 index 363bb35..9d00aeb 100644
22 --- a/arch/mips/include/asm/mips_machine.h
23 +++ b/arch/mips/include/asm/mips_machine.h
24 @@ -42,13 +42,9 @@ extern long __mips_machines_end;
25  #ifdef CONFIG_MIPS_MACHINE
26  int  mips_machtype_setup(char *id) __init;
27  void mips_machine_setup(void) __init;
28 -void mips_set_machine_name(const char *name) __init;
29 -char *mips_get_machine_name(void);
30  #else
31  static inline int mips_machtype_setup(char *id) { return 1; }
32  static inline void mips_machine_setup(void) { }
33 -static inline void mips_set_machine_name(const char *name) { }
34 -static inline char *mips_get_machine_name(void) { return NULL; }
35  #endif /* CONFIG_MIPS_MACHINE */
36  
37  #endif /* __ASM_MIPS_MACHINE_H */
38 diff --git a/arch/mips/include/asm/prom.h b/arch/mips/include/asm/prom.h
39 index 8808bf5..1e7e096 100644
40 --- a/arch/mips/include/asm/prom.h
41 +++ b/arch/mips/include/asm/prom.h
42 @@ -48,4 +48,7 @@ extern void __dt_setup_arch(struct boot_param_header *bph);
43  static inline void device_tree_init(void) { }
44  #endif /* CONFIG_OF */
45  
46 +extern char *mips_get_machine_name(void);
47 +extern void mips_set_machine_name(const char *name);
48 +
49  #endif /* __ASM_PROM_H */
50 diff --git a/arch/mips/kernel/mips_machine.c b/arch/mips/kernel/mips_machine.c
51 index 411a058..6dc5866 100644
52 --- a/arch/mips/kernel/mips_machine.c
53 +++ b/arch/mips/kernel/mips_machine.c
54 @@ -13,7 +13,6 @@
55  #include <asm/mips_machine.h>
56  
57  static struct mips_machine *mips_machine __initdata;
58 -static char *mips_machine_name = "Unknown";
59  
60  #define for_each_machine(mach) \
61         for ((mach) = (struct mips_machine *)&__mips_machines_start; \
62 @@ -21,25 +20,6 @@ static char *mips_machine_name = "Unknown";
63              (unsigned long)(mach) < (unsigned long)&__mips_machines_end; \
64              (mach)++)
65  
66 -__init void mips_set_machine_name(const char *name)
67 -{
68 -       char *p;
69 -
70 -       if (name == NULL)
71 -               return;
72 -
73 -       p = kstrdup(name, GFP_KERNEL);
74 -       if (!p)
75 -               pr_err("MIPS: no memory for machine_name\n");
76 -
77 -       mips_machine_name = p;
78 -}
79 -
80 -char *mips_get_machine_name(void)
81 -{
82 -       return mips_machine_name;
83 -}
84 -
85  __init int mips_machtype_setup(char *id)
86  {
87         struct mips_machine *mach;
88 @@ -79,7 +59,6 @@ __init void mips_machine_setup(void)
89                 return;
90  
91         mips_set_machine_name(mips_machine->mach_name);
92 -       pr_info("MIPS: machine is %s\n", mips_machine_name);
93  
94         if (mips_machine->mach_setup)
95                 mips_machine->mach_setup();
96 diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c
97 index 7a54f74..1dd137b 100644
98 --- a/arch/mips/kernel/proc.c
99 +++ b/arch/mips/kernel/proc.c
100 @@ -12,7 +12,7 @@
101  #include <asm/cpu-features.h>
102  #include <asm/mipsregs.h>
103  #include <asm/processor.h>
104 -#include <asm/mips_machine.h>
105 +#include <asm/prom.h>
106  
107  unsigned int vced_count, vcei_count;
108  
109 diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c
110 index 028f6f8..b68e53b 100644
111 --- a/arch/mips/kernel/prom.c
112 +++ b/arch/mips/kernel/prom.c
113 @@ -23,6 +23,22 @@
114  #include <asm/page.h>
115  #include <asm/prom.h>
116  
117 +static char mips_machine_name[64] = "Unknown";
118 +
119 +__init void mips_set_machine_name(const char *name)
120 +{
121 +       if (name == NULL)
122 +               return;
123 +
124 +       strncpy(mips_machine_name, name, sizeof(mips_machine_name));
125 +       pr_info("MIPS: machine is %s\n", mips_get_machine_name());
126 +}
127 +
128 +char *mips_get_machine_name(void)
129 +{
130 +       return mips_machine_name;
131 +}
132 +
133  int __init early_init_dt_scan_memory_arch(unsigned long node,
134                                           const char *uname, int depth,
135                                           void *data)
136 @@ -50,6 +66,18 @@ void __init early_init_dt_setup_initrd_arch(unsigned long start,
137  }
138  #endif
139  
140 +int __init early_init_dt_scan_model(unsigned long node,        const char *uname,
141 +                                   int depth, void *data)
142 +{
143 +       if (!depth) {
144 +               char *model = of_get_flat_dt_prop(node, "model", NULL);
145 +
146 +               if (model)
147 +                       mips_set_machine_name(model);
148 +       }
149 +       return 0;
150 +}
151 +
152  void __init early_init_devtree(void *params)
153  {
154         /* Setup flat device-tree pointer */
155 @@ -65,6 +93,9 @@ void __init early_init_devtree(void *params)
156         /* Scan memory nodes */
157         of_scan_flat_dt(early_init_dt_scan_root, NULL);
158         of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL);
159 +
160 +       /* try to load the mips machine name */
161 +       of_scan_flat_dt(early_init_dt_scan_model, NULL);
162  }
163  
164  void __init __dt_setup_arch(struct boot_param_header *bph)
165 -- 
166 1.7.10.4
167