kernel: fix bluetooth and zsmalloc for 3.14
[openwrt/svn-archive/archive.git] / target / linux / brcm63xx / patches-3.13 / 317-MIPS-BCM63XX-remove-RUNTIME_DETECT-code-for-bcmcpu_g.patch
1 From 78c3d2e796a28ad55f6c2310a11ab22e91bb52fc Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jogo@openwrt.org>
3 Date: Mon, 2 Dec 2013 12:30:44 +0100
4 Subject: [PATCH 8/8] MIPS: BCM63XX: remove !RUNTIME_DETECT code for
5 bcmcpu_get_id
6
7 Use the same pattern as with get_*_cpu_type() to allow the compiler
8 to remove code for non enabled devices.
9
10 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
11 ---
12 arch/mips/bcm63xx/cpu.c | 11 +--
13 arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h | 120 +++++++----------------
14 2 files changed, 38 insertions(+), 93 deletions(-)
15
16 --- a/arch/mips/bcm63xx/cpu.c
17 +++ b/arch/mips/bcm63xx/cpu.c
18 @@ -24,7 +24,9 @@ EXPORT_SYMBOL(bcm63xx_regs_base);
19 const int *bcm63xx_irqs;
20 EXPORT_SYMBOL(bcm63xx_irqs);
21
22 -static u16 bcm63xx_cpu_id;
23 +u16 bcm63xx_cpu_id __read_mostly;
24 +EXPORT_SYMBOL(bcm63xx_cpu_id);
25 +
26 static u8 bcm63xx_cpu_rev;
27 static unsigned int bcm63xx_cpu_freq;
28 static unsigned int bcm63xx_memory_size;
29 @@ -97,13 +99,6 @@ static const int bcm6368_irqs[] = {
30
31 };
32
33 -u16 __bcm63xx_get_cpu_id(void)
34 -{
35 - return bcm63xx_cpu_id;
36 -}
37 -
38 -EXPORT_SYMBOL(__bcm63xx_get_cpu_id);
39 -
40 u8 bcm63xx_get_cpu_rev(void)
41 {
42 return bcm63xx_cpu_rev;
43 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h
44 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h
45 @@ -19,118 +19,68 @@
46 #define BCM6368_CPU_ID 0x6368
47
48 void __init bcm63xx_cpu_init(void);
49 -u16 __bcm63xx_get_cpu_id(void);
50 u8 bcm63xx_get_cpu_rev(void);
51 unsigned int bcm63xx_get_cpu_freq(void);
52
53 +static inline u16 __pure __bcm63xx_get_cpu_id(const u16 cpu_id)
54 +{
55 + switch (cpu_id) {
56 #ifdef CONFIG_BCM63XX_CPU_3368
57 -# ifdef bcm63xx_get_cpu_id
58 -# undef bcm63xx_get_cpu_id
59 -# define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
60 -# define BCMCPU_RUNTIME_DETECT
61 -# else
62 -# define bcm63xx_get_cpu_id() BCM3368_CPU_ID
63 -# endif
64 -# define BCMCPU_IS_3368() (bcm63xx_get_cpu_id() == BCM3368_CPU_ID)
65 -#else
66 -# define BCMCPU_IS_3368() (0)
67 + case BCM3368_CPU_ID:
68 #endif
69
70 #ifdef CONFIG_BCM63XX_CPU_6328
71 -# ifdef bcm63xx_get_cpu_id
72 -# undef bcm63xx_get_cpu_id
73 -# define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
74 -# define BCMCPU_RUNTIME_DETECT
75 -# else
76 -# define bcm63xx_get_cpu_id() BCM6328_CPU_ID
77 -# endif
78 -# define BCMCPU_IS_6328() (bcm63xx_get_cpu_id() == BCM6328_CPU_ID)
79 -#else
80 -# define BCMCPU_IS_6328() (0)
81 + case BCM6328_CPU_ID:
82 #endif
83
84 #ifdef CONFIG_BCM63XX_CPU_6338
85 -# ifdef bcm63xx_get_cpu_id
86 -# undef bcm63xx_get_cpu_id
87 -# define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
88 -# define BCMCPU_RUNTIME_DETECT
89 -# else
90 -# define bcm63xx_get_cpu_id() BCM6338_CPU_ID
91 -# endif
92 -# define BCMCPU_IS_6338() (bcm63xx_get_cpu_id() == BCM6338_CPU_ID)
93 -#else
94 -# define BCMCPU_IS_6338() (0)
95 + case BCM6338_CPU_ID:
96 #endif
97
98 #ifdef CONFIG_BCM63XX_CPU_6345
99 -# ifdef bcm63xx_get_cpu_id
100 -# undef bcm63xx_get_cpu_id
101 -# define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
102 -# define BCMCPU_RUNTIME_DETECT
103 -# else
104 -# define bcm63xx_get_cpu_id() BCM6345_CPU_ID
105 -# endif
106 -# define BCMCPU_IS_6345() (bcm63xx_get_cpu_id() == BCM6345_CPU_ID)
107 -#else
108 -# define BCMCPU_IS_6345() (0)
109 + case BCM6345_CPU_ID:
110 #endif
111
112 #ifdef CONFIG_BCM63XX_CPU_6348
113 -# ifdef bcm63xx_get_cpu_id
114 -# undef bcm63xx_get_cpu_id
115 -# define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
116 -# define BCMCPU_RUNTIME_DETECT
117 -# else
118 -# define bcm63xx_get_cpu_id() BCM6348_CPU_ID
119 -# endif
120 -# define BCMCPU_IS_6348() (bcm63xx_get_cpu_id() == BCM6348_CPU_ID)
121 -#else
122 -# define BCMCPU_IS_6348() (0)
123 + case BCM6348_CPU_ID:
124 #endif
125
126 #ifdef CONFIG_BCM63XX_CPU_6358
127 -# ifdef bcm63xx_get_cpu_id
128 -# undef bcm63xx_get_cpu_id
129 -# define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
130 -# define BCMCPU_RUNTIME_DETECT
131 -# else
132 -# define bcm63xx_get_cpu_id() BCM6358_CPU_ID
133 -# endif
134 -# define BCMCPU_IS_6358() (bcm63xx_get_cpu_id() == BCM6358_CPU_ID)
135 -#else
136 -# define BCMCPU_IS_6358() (0)
137 + case BCM6358_CPU_ID:
138 #endif
139
140 #ifdef CONFIG_BCM63XX_CPU_6362
141 -# ifdef bcm63xx_get_cpu_id
142 -# undef bcm63xx_get_cpu_id
143 -# define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
144 -# define BCMCPU_RUNTIME_DETECT
145 -# else
146 -# define bcm63xx_get_cpu_id() BCM6362_CPU_ID
147 -# endif
148 -# define BCMCPU_IS_6362() (bcm63xx_get_cpu_id() == BCM6362_CPU_ID)
149 -#else
150 -# define BCMCPU_IS_6362() (0)
151 + case BCM6362_CPU_ID:
152 #endif
153
154 -
155 #ifdef CONFIG_BCM63XX_CPU_6368
156 -# ifdef bcm63xx_get_cpu_id
157 -# undef bcm63xx_get_cpu_id
158 -# define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
159 -# define BCMCPU_RUNTIME_DETECT
160 -# else
161 -# define bcm63xx_get_cpu_id() BCM6368_CPU_ID
162 -# endif
163 -# define BCMCPU_IS_6368() (bcm63xx_get_cpu_id() == BCM6368_CPU_ID)
164 -#else
165 -# define BCMCPU_IS_6368() (0)
166 -#endif
167 -
168 -#ifndef bcm63xx_get_cpu_id
169 -#error "No CPU support configured"
170 + case BCM6368_CPU_ID:
171 #endif
172 + break;
173 + default:
174 + unreachable();
175 + }
176 +
177 + return cpu_id;
178 +}
179 +
180 +extern u16 bcm63xx_cpu_id;
181 +
182 +static inline u16 __pure bcm63xx_get_cpu_id(void)
183 +{
184 + const u16 cpu_id = bcm63xx_cpu_id;
185 +
186 + return __bcm63xx_get_cpu_id(cpu_id);
187 +}
188 +
189 +#define BCMCPU_IS_3368() (bcm63xx_get_cpu_id() == BCM3368_CPU_ID)
190 +#define BCMCPU_IS_6328() (bcm63xx_get_cpu_id() == BCM6328_CPU_ID)
191 +#define BCMCPU_IS_6338() (bcm63xx_get_cpu_id() == BCM6338_CPU_ID)
192 +#define BCMCPU_IS_6345() (bcm63xx_get_cpu_id() == BCM6345_CPU_ID)
193 +#define BCMCPU_IS_6348() (bcm63xx_get_cpu_id() == BCM6348_CPU_ID)
194 +#define BCMCPU_IS_6358() (bcm63xx_get_cpu_id() == BCM6358_CPU_ID)
195 +#define BCMCPU_IS_6362() (bcm63xx_get_cpu_id() == BCM6362_CPU_ID)
196 +#define BCMCPU_IS_6368() (bcm63xx_get_cpu_id() == BCM6368_CPU_ID)
197
198 /*
199 * While registers sets are (mostly) the same across 63xx CPU, base