031-06-MIPS-BCM47XX-Fix-coding-style-to-match-kernel-standa.patch 8.4 KB

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