brcm47xx: backport MIPS BCM47XX patches queued for 4.1
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-3.18 / 031-06-MIPS-BCM47XX-Fix-coding-style-to-match-kernel-standa.patch
1 From d548ca6b0784a99f0fcae397f115823ccd0361a5 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Wed, 10 Dec 2014 17:38:26 +0100
4 Subject: [PATCH] MIPS: BCM47XX: Fix coding style to match kernel standards
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 [ralf@linux-mips.org: Fixed conflicts.]
10
11 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
12 Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
13 Cc: linux-mips@linux-mips.org
14 Cc: Paul Walmsley <paul@pwsan.com>
15 Patchwork: https://patchwork.linux-mips.org/patch/8665/
16 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
17 ---
18 arch/mips/bcm47xx/bcm47xx_private.h | 4 ++++
19 arch/mips/bcm47xx/board.c | 3 +--
20 arch/mips/bcm47xx/nvram.c | 25 ++++++++++++++-----------
21 arch/mips/bcm47xx/prom.c | 3 +--
22 arch/mips/bcm47xx/serial.c | 8 ++++----
23 arch/mips/bcm47xx/setup.c | 12 ++++++------
24 arch/mips/bcm47xx/sprom.c | 8 ++++----
25 arch/mips/bcm47xx/time.c | 1 -
26 8 files changed, 34 insertions(+), 30 deletions(-)
27
28 diff --git a/arch/mips/bcm47xx/bcm47xx_private.h b/arch/mips/bcm47xx/bcm47xx_private.h
29 index ea909a5..41796be 100644
30 --- a/arch/mips/bcm47xx/bcm47xx_private.h
31 +++ b/arch/mips/bcm47xx/bcm47xx_private.h
32 @@ -1,6 +1,10 @@
33 #ifndef LINUX_BCM47XX_PRIVATE_H_
34 #define LINUX_BCM47XX_PRIVATE_H_
35
36 +#ifndef pr_fmt
37 +#define pr_fmt(fmt) "bcm47xx: " fmt
38 +#endif
39 +
40 #include <linux/kernel.h>
41
42 /* prom.c */
43 diff --git a/arch/mips/bcm47xx/board.c b/arch/mips/bcm47xx/board.c
44 index 6e85130..d4a5a51 100644
45 --- a/arch/mips/bcm47xx/board.c
46 +++ b/arch/mips/bcm47xx/board.c
47 @@ -330,9 +330,8 @@ void __init bcm47xx_board_detect(void)
48 err = bcm47xx_nvram_getenv("boardtype", buf, sizeof(buf));
49
50 /* init of nvram failed, probably too early now */
51 - if (err == -ENXIO) {
52 + if (err == -ENXIO)
53 return;
54 - }
55
56 board_detected = bcm47xx_board_get_nvram();
57 bcm47xx_board.board = board_detected->board;
58 diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c
59 index 7c77a88..6a97732 100644
60 --- a/arch/mips/bcm47xx/nvram.c
61 +++ b/arch/mips/bcm47xx/nvram.c
62 @@ -18,8 +18,10 @@
63 #include <linux/mtd/mtd.h>
64 #include <linux/bcm47xx_nvram.h>
65
66 -#define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */
67 -#define NVRAM_SPACE 0x8000
68 +#define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */
69 +#define NVRAM_SPACE 0x8000
70 +#define NVRAM_MAX_GPIO_ENTRIES 32
71 +#define NVRAM_MAX_GPIO_VALUE_LEN 30
72
73 #define FLASH_MIN 0x00020000 /* Minimum flash size */
74
75 @@ -97,8 +99,8 @@ found:
76 pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
77 header->len, NVRAM_SPACE);
78
79 - src = (u32 *) header;
80 - dst = (u32 *) nvram_buf;
81 + src = (u32 *)header;
82 + dst = (u32 *)nvram_buf;
83 for (i = 0; i < sizeof(struct nvram_header); i += 4)
84 *dst++ = __raw_readl(src++);
85 for (; i < header->len && i < NVRAM_SPACE && i < size; i += 4)
86 @@ -189,7 +191,8 @@ int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len)
87 /* Look for name=value and return value */
88 var = &nvram_buf[sizeof(struct nvram_header)];
89 end = nvram_buf + sizeof(nvram_buf) - 2;
90 - end[0] = end[1] = '\0';
91 + end[0] = '\0';
92 + end[1] = '\0';
93 for (; *var; var = value + strlen(value) + 1) {
94 data_left = end - var;
95
96 @@ -197,11 +200,10 @@ int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len)
97 if (!eq)
98 break;
99 value = eq + 1;
100 - if ((eq - var) == strlen(name) &&
101 - strncmp(var, name, (eq - var)) == 0) {
102 + if (eq - var == strlen(name) &&
103 + strncmp(var, name, eq - var) == 0)
104 return snprintf(val, val_len, "%s", value);
105 }
106 - }
107 return -ENOENT;
108 }
109 EXPORT_SYMBOL(bcm47xx_nvram_getenv);
110 @@ -209,10 +211,11 @@ EXPORT_SYMBOL(bcm47xx_nvram_getenv);
111 int bcm47xx_nvram_gpio_pin(const char *name)
112 {
113 int i, err;
114 - char nvram_var[10];
115 - char buf[30];
116 + char nvram_var[] = "gpioXX";
117 + char buf[NVRAM_MAX_GPIO_VALUE_LEN];
118
119 - for (i = 0; i < 32; i++) {
120 + /* TODO: Optimize it to don't call getenv so many times */
121 + for (i = 0; i < NVRAM_MAX_GPIO_ENTRIES; i++) {
122 err = snprintf(nvram_var, sizeof(nvram_var), "gpio%i", i);
123 if (err <= 0)
124 continue;
125 diff --git a/arch/mips/bcm47xx/prom.c b/arch/mips/bcm47xx/prom.c
126 index 1b170bf..ab698ba 100644
127 --- a/arch/mips/bcm47xx/prom.c
128 +++ b/arch/mips/bcm47xx/prom.c
129 @@ -35,7 +35,6 @@
130 #include <bcm47xx.h>
131 #include <bcm47xx_board.h>
132
133 -
134 static char bcm47xx_system_type[20] = "Broadcom BCM47XX";
135
136 const char *get_system_type(void)
137 @@ -83,7 +82,7 @@ static __init void prom_init_mem(void)
138 /* Loop condition may be not enough, off may be over 1 MiB */
139 if (off + mem >= max) {
140 mem = max;
141 - printk(KERN_DEBUG "assume 128MB RAM\n");
142 + pr_debug("Assume 128MB RAM\n");
143 break;
144 }
145 if (!memcmp(prom_init, prom_init + mem, 32))
146 diff --git a/arch/mips/bcm47xx/serial.c b/arch/mips/bcm47xx/serial.c
147 index 2f5bbd6..df761d3 100644
148 --- a/arch/mips/bcm47xx/serial.c
149 +++ b/arch/mips/bcm47xx/serial.c
150 @@ -36,8 +36,8 @@ static int __init uart8250_init_ssb(void)
151 struct plat_serial8250_port *p = &(uart8250_data[i]);
152 struct ssb_serial_port *ssb_port = &(mcore->serial_ports[i]);
153
154 - p->mapbase = (unsigned int) ssb_port->regs;
155 - p->membase = (void *) ssb_port->regs;
156 + p->mapbase = (unsigned int)ssb_port->regs;
157 + p->membase = (void *)ssb_port->regs;
158 p->irq = ssb_port->irq + 2;
159 p->uartclk = ssb_port->baud_base;
160 p->regshift = ssb_port->reg_shift;
161 @@ -62,8 +62,8 @@ static int __init uart8250_init_bcma(void)
162 struct bcma_serial_port *bcma_port;
163 bcma_port = &(cc->serial_ports[i]);
164
165 - p->mapbase = (unsigned int) bcma_port->regs;
166 - p->membase = (void *) bcma_port->regs;
167 + p->mapbase = (unsigned int)bcma_port->regs;
168 + p->membase = (void *)bcma_port->regs;
169 p->irq = bcma_port->irq;
170 p->uartclk = bcma_port->baud_base;
171 p->regshift = bcma_port->reg_shift;
172 diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
173 index b26c9c2..82ff9fd 100644
174 --- a/arch/mips/bcm47xx/setup.c
175 +++ b/arch/mips/bcm47xx/setup.c
176 @@ -52,7 +52,7 @@ EXPORT_SYMBOL(bcm47xx_bus_type);
177
178 static void bcm47xx_machine_restart(char *command)
179 {
180 - printk(KERN_ALERT "Please stand by while rebooting the system...\n");
181 + pr_alert("Please stand by while rebooting the system...\n");
182 local_irq_disable();
183 /* Set the watchdog timer to reset immediately */
184 switch (bcm47xx_bus_type) {
185 @@ -107,7 +107,7 @@ static int bcm47xx_get_invariants(struct ssb_bus *bus,
186 char buf[20];
187
188 /* Fill boardinfo structure */
189 - memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));
190 + memset(&iv->boardinfo, 0 , sizeof(struct ssb_boardinfo));
191
192 bcm47xx_fill_ssb_boardinfo(&iv->boardinfo, NULL);
193
194 @@ -126,7 +126,7 @@ static void __init bcm47xx_register_ssb(void)
195 char buf[100];
196 struct ssb_mipscore *mcore;
197
198 - err = ssb_bus_ssbbus_register(&(bcm47xx_bus.ssb), SSB_ENUM_BASE,
199 + err = ssb_bus_ssbbus_register(&bcm47xx_bus.ssb, SSB_ENUM_BASE,
200 bcm47xx_get_invariants);
201 if (err)
202 panic("Failed to initialize SSB bus (err %d)", err);
203 @@ -136,7 +136,7 @@ static void __init bcm47xx_register_ssb(void)
204 if (strstr(buf, "console=ttyS1")) {
205 struct ssb_serial_port port;
206
207 - printk(KERN_DEBUG "Swapping serial ports!\n");
208 + pr_debug("Swapping serial ports!\n");
209 /* swap serial ports */
210 memcpy(&port, &mcore->serial_ports[0], sizeof(port));
211 memcpy(&mcore->serial_ports[0], &mcore->serial_ports[1],
212 @@ -168,7 +168,7 @@ void __init plat_mem_setup(void)
213 struct cpuinfo_mips *c = &current_cpu_data;
214
215 if ((c->cputype == CPU_74K) || (c->cputype == CPU_1074K)) {
216 - printk(KERN_INFO "bcm47xx: using bcma bus\n");
217 + pr_info("Using bcma bus\n");
218 #ifdef CONFIG_BCM47XX_BCMA
219 bcm47xx_bus_type = BCM47XX_BUS_TYPE_BCMA;
220 bcm47xx_sprom_register_fallbacks();
221 @@ -179,7 +179,7 @@ void __init plat_mem_setup(void)
222 #endif
223 #endif
224 } else {
225 - printk(KERN_INFO "bcm47xx: using ssb bus\n");
226 + pr_info("Using ssb bus\n");
227 #ifdef CONFIG_BCM47XX_SSB
228 bcm47xx_bus_type = BCM47XX_BUS_TYPE_SSB;
229 bcm47xx_sprom_register_fallbacks();
230 diff --git a/arch/mips/bcm47xx/sprom.c b/arch/mips/bcm47xx/sprom.c
231 index c114b02..5d32afc 100644
232 --- a/arch/mips/bcm47xx/sprom.c
233 +++ b/arch/mips/bcm47xx/sprom.c
234 @@ -780,8 +780,8 @@ void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix,
235 bcm47xx_fill_sprom_path_r4589(sprom, prefix, fallback);
236 break;
237 default:
238 - pr_warn("Unsupported SPROM revision %d detected. Will extract"
239 - " v1\n", sprom->revision);
240 + pr_warn("Unsupported SPROM revision %d detected. Will extract v1\n",
241 + sprom->revision);
242 sprom->revision = 1;
243 bcm47xx_fill_sprom_r1234589(sprom, prefix, fallback);
244 bcm47xx_fill_sprom_r12389(sprom, prefix, fallback);
245 @@ -828,7 +828,7 @@ static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
246 bcm47xx_fill_sprom(out, prefix, false);
247 return 0;
248 } else {
249 - pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
250 + pr_warn("Unable to fill SPROM for given bustype.\n");
251 return -EINVAL;
252 }
253 }
254 @@ -893,7 +893,7 @@ static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out)
255 }
256 return 0;
257 default:
258 - pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
259 + pr_warn("Unable to fill SPROM for given bustype.\n");
260 return -EINVAL;
261 }
262 }
263 diff --git a/arch/mips/bcm47xx/time.c b/arch/mips/bcm47xx/time.c
264 index 5b46510..74224cf 100644
265 --- a/arch/mips/bcm47xx/time.c
266 +++ b/arch/mips/bcm47xx/time.c
267 @@ -22,7 +22,6 @@
268 * 675 Mass Ave, Cambridge, MA 02139, USA.
269 */
270
271 -
272 #include <linux/init.h>
273 #include <linux/ssb/ssb.h>
274 #include <asm/time.h>
275 --
276 1.8.4.5
277