kernel: update 4.0 to 4.0.5
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-4.0 / 030-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 --- a/arch/mips/bcm47xx/bcm47xx_private.h
29 +++ b/arch/mips/bcm47xx/bcm47xx_private.h
30 @@ -1,6 +1,10 @@
31 #ifndef LINUX_BCM47XX_PRIVATE_H_
32 #define LINUX_BCM47XX_PRIVATE_H_
33
34 +#ifndef pr_fmt
35 +#define pr_fmt(fmt) "bcm47xx: " fmt
36 +#endif
37 +
38 #include <linux/kernel.h>
39
40 /* prom.c */
41 --- a/arch/mips/bcm47xx/board.c
42 +++ b/arch/mips/bcm47xx/board.c
43 @@ -330,9 +330,8 @@ void __init bcm47xx_board_detect(void)
44 err = bcm47xx_nvram_getenv("boardtype", buf, sizeof(buf));
45
46 /* init of nvram failed, probably too early now */
47 - if (err == -ENXIO) {
48 + if (err == -ENXIO)
49 return;
50 - }
51
52 board_detected = bcm47xx_board_get_nvram();
53 bcm47xx_board.board = board_detected->board;
54 --- a/arch/mips/bcm47xx/nvram.c
55 +++ b/arch/mips/bcm47xx/nvram.c
56 @@ -18,8 +18,10 @@
57 #include <linux/mtd/mtd.h>
58 #include <linux/bcm47xx_nvram.h>
59
60 -#define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */
61 -#define NVRAM_SPACE 0x8000
62 +#define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */
63 +#define NVRAM_SPACE 0x8000
64 +#define NVRAM_MAX_GPIO_ENTRIES 32
65 +#define NVRAM_MAX_GPIO_VALUE_LEN 30
66
67 #define FLASH_MIN 0x00020000 /* Minimum flash size */
68
69 @@ -97,8 +99,8 @@ found:
70 pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
71 header->len, NVRAM_SPACE);
72
73 - src = (u32 *) header;
74 - dst = (u32 *) nvram_buf;
75 + src = (u32 *)header;
76 + dst = (u32 *)nvram_buf;
77 for (i = 0; i < sizeof(struct nvram_header); i += 4)
78 *dst++ = __raw_readl(src++);
79 for (; i < header->len && i < NVRAM_SPACE && i < size; i += 4)
80 @@ -189,7 +191,8 @@ int bcm47xx_nvram_getenv(const char *nam
81 /* Look for name=value and return value */
82 var = &nvram_buf[sizeof(struct nvram_header)];
83 end = nvram_buf + sizeof(nvram_buf) - 2;
84 - end[0] = end[1] = '\0';
85 + end[0] = '\0';
86 + end[1] = '\0';
87 for (; *var; var = value + strlen(value) + 1) {
88 data_left = end - var;
89
90 @@ -197,11 +200,10 @@ int bcm47xx_nvram_getenv(const char *nam
91 if (!eq)
92 break;
93 value = eq + 1;
94 - if ((eq - var) == strlen(name) &&
95 - strncmp(var, name, (eq - var)) == 0) {
96 + if (eq - var == strlen(name) &&
97 + strncmp(var, name, eq - var) == 0)
98 return snprintf(val, val_len, "%s", value);
99 }
100 - }
101 return -ENOENT;
102 }
103 EXPORT_SYMBOL(bcm47xx_nvram_getenv);
104 @@ -209,10 +211,11 @@ EXPORT_SYMBOL(bcm47xx_nvram_getenv);
105 int bcm47xx_nvram_gpio_pin(const char *name)
106 {
107 int i, err;
108 - char nvram_var[10];
109 - char buf[30];
110 + char nvram_var[] = "gpioXX";
111 + char buf[NVRAM_MAX_GPIO_VALUE_LEN];
112
113 - for (i = 0; i < 32; i++) {
114 + /* TODO: Optimize it to don't call getenv so many times */
115 + for (i = 0; i < NVRAM_MAX_GPIO_ENTRIES; i++) {
116 err = snprintf(nvram_var, sizeof(nvram_var), "gpio%i", i);
117 if (err <= 0)
118 continue;
119 --- a/arch/mips/bcm47xx/prom.c
120 +++ b/arch/mips/bcm47xx/prom.c
121 @@ -35,7 +35,6 @@
122 #include <bcm47xx.h>
123 #include <bcm47xx_board.h>
124
125 -
126 static char bcm47xx_system_type[20] = "Broadcom BCM47XX";
127
128 const char *get_system_type(void)
129 @@ -83,7 +82,7 @@ static __init void prom_init_mem(void)
130 /* Loop condition may be not enough, off may be over 1 MiB */
131 if (off + mem >= max) {
132 mem = max;
133 - printk(KERN_DEBUG "assume 128MB RAM\n");
134 + pr_debug("Assume 128MB RAM\n");
135 break;
136 }
137 if (!memcmp(prom_init, prom_init + mem, 32))
138 --- a/arch/mips/bcm47xx/serial.c
139 +++ b/arch/mips/bcm47xx/serial.c
140 @@ -36,8 +36,8 @@ static int __init uart8250_init_ssb(void
141 struct plat_serial8250_port *p = &(uart8250_data[i]);
142 struct ssb_serial_port *ssb_port = &(mcore->serial_ports[i]);
143
144 - p->mapbase = (unsigned int) ssb_port->regs;
145 - p->membase = (void *) ssb_port->regs;
146 + p->mapbase = (unsigned int)ssb_port->regs;
147 + p->membase = (void *)ssb_port->regs;
148 p->irq = ssb_port->irq + 2;
149 p->uartclk = ssb_port->baud_base;
150 p->regshift = ssb_port->reg_shift;
151 @@ -62,8 +62,8 @@ static int __init uart8250_init_bcma(voi
152 struct bcma_serial_port *bcma_port;
153 bcma_port = &(cc->serial_ports[i]);
154
155 - p->mapbase = (unsigned int) bcma_port->regs;
156 - p->membase = (void *) bcma_port->regs;
157 + p->mapbase = (unsigned int)bcma_port->regs;
158 + p->membase = (void *)bcma_port->regs;
159 p->irq = bcma_port->irq;
160 p->uartclk = bcma_port->baud_base;
161 p->regshift = bcma_port->reg_shift;
162 --- a/arch/mips/bcm47xx/setup.c
163 +++ b/arch/mips/bcm47xx/setup.c
164 @@ -52,7 +52,7 @@ EXPORT_SYMBOL(bcm47xx_bus_type);
165
166 static void bcm47xx_machine_restart(char *command)
167 {
168 - printk(KERN_ALERT "Please stand by while rebooting the system...\n");
169 + pr_alert("Please stand by while rebooting the system...\n");
170 local_irq_disable();
171 /* Set the watchdog timer to reset immediately */
172 switch (bcm47xx_bus_type) {
173 @@ -107,7 +107,7 @@ static int bcm47xx_get_invariants(struct
174 char buf[20];
175
176 /* Fill boardinfo structure */
177 - memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));
178 + memset(&iv->boardinfo, 0 , sizeof(struct ssb_boardinfo));
179
180 bcm47xx_fill_ssb_boardinfo(&iv->boardinfo, NULL);
181
182 @@ -126,7 +126,7 @@ static void __init bcm47xx_register_ssb(
183 char buf[100];
184 struct ssb_mipscore *mcore;
185
186 - err = ssb_bus_ssbbus_register(&(bcm47xx_bus.ssb), SSB_ENUM_BASE,
187 + err = ssb_bus_ssbbus_register(&bcm47xx_bus.ssb, SSB_ENUM_BASE,
188 bcm47xx_get_invariants);
189 if (err)
190 panic("Failed to initialize SSB bus (err %d)", err);
191 @@ -136,7 +136,7 @@ static void __init bcm47xx_register_ssb(
192 if (strstr(buf, "console=ttyS1")) {
193 struct ssb_serial_port port;
194
195 - printk(KERN_DEBUG "Swapping serial ports!\n");
196 + pr_debug("Swapping serial ports!\n");
197 /* swap serial ports */
198 memcpy(&port, &mcore->serial_ports[0], sizeof(port));
199 memcpy(&mcore->serial_ports[0], &mcore->serial_ports[1],
200 @@ -168,7 +168,7 @@ void __init plat_mem_setup(void)
201 struct cpuinfo_mips *c = &current_cpu_data;
202
203 if ((c->cputype == CPU_74K) || (c->cputype == CPU_1074K)) {
204 - printk(KERN_INFO "bcm47xx: using bcma bus\n");
205 + pr_info("Using bcma bus\n");
206 #ifdef CONFIG_BCM47XX_BCMA
207 bcm47xx_bus_type = BCM47XX_BUS_TYPE_BCMA;
208 bcm47xx_sprom_register_fallbacks();
209 @@ -179,7 +179,7 @@ void __init plat_mem_setup(void)
210 #endif
211 #endif
212 } else {
213 - printk(KERN_INFO "bcm47xx: using ssb bus\n");
214 + pr_info("Using ssb bus\n");
215 #ifdef CONFIG_BCM47XX_SSB
216 bcm47xx_bus_type = BCM47XX_BUS_TYPE_SSB;
217 bcm47xx_sprom_register_fallbacks();
218 --- a/arch/mips/bcm47xx/sprom.c
219 +++ b/arch/mips/bcm47xx/sprom.c
220 @@ -780,8 +780,8 @@ void bcm47xx_fill_sprom(struct ssb_sprom
221 bcm47xx_fill_sprom_path_r4589(sprom, prefix, fallback);
222 break;
223 default:
224 - pr_warn("Unsupported SPROM revision %d detected. Will extract"
225 - " v1\n", sprom->revision);
226 + pr_warn("Unsupported SPROM revision %d detected. Will extract v1\n",
227 + sprom->revision);
228 sprom->revision = 1;
229 bcm47xx_fill_sprom_r1234589(sprom, prefix, fallback);
230 bcm47xx_fill_sprom_r12389(sprom, prefix, fallback);
231 @@ -828,7 +828,7 @@ static int bcm47xx_get_sprom_ssb(struct
232 bcm47xx_fill_sprom(out, prefix, false);
233 return 0;
234 } else {
235 - pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
236 + pr_warn("Unable to fill SPROM for given bustype.\n");
237 return -EINVAL;
238 }
239 }
240 @@ -893,7 +893,7 @@ static int bcm47xx_get_sprom_bcma(struct
241 }
242 return 0;
243 default:
244 - pr_warn("bcm47xx: unable to fill SPROM for given bustype.\n");
245 + pr_warn("Unable to fill SPROM for given bustype.\n");
246 return -EINVAL;
247 }
248 }
249 --- a/arch/mips/bcm47xx/time.c
250 +++ b/arch/mips/bcm47xx/time.c
251 @@ -22,7 +22,6 @@
252 * 675 Mass Ave, Cambridge, MA 02139, USA.
253 */
254
255 -
256 #include <linux/init.h>
257 #include <linux/ssb/ssb.h>
258 #include <asm/time.h>