Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: BCM47xx: Fetch board info directly in callback function

This drops another symbol dependency between setup.c and sprom.c which
will allow us to make SPROM code a separated module (and share it with
ARM).
Patch tested on Linksys WRT300N V1.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Cc: Hauke Mehrtens <hauke@hauke-m.de>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/11360/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Rafał Miłecki and committed by
Ralf Baechle
d8cfb503 2f94acde

+18 -19
+18 -1
arch/mips/bcm47xx/setup.c
··· 105 105 struct ssb_init_invariants *iv) 106 106 { 107 107 char buf[20]; 108 + int len, err; 108 109 109 110 /* Fill boardinfo structure */ 110 111 memset(&iv->boardinfo, 0 , sizeof(struct ssb_boardinfo)); 111 112 112 - bcm47xx_fill_ssb_boardinfo(&iv->boardinfo, NULL); 113 + len = bcm47xx_nvram_getenv("boardvendor", buf, sizeof(buf)); 114 + if (len > 0) { 115 + err = kstrtou16(strim(buf), 0, &iv->boardinfo.vendor); 116 + if (err) 117 + pr_warn("Couldn't parse nvram board vendor entry with value \"%s\"\n", 118 + buf); 119 + } 120 + if (!iv->boardinfo.vendor) 121 + iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM; 122 + 123 + len = bcm47xx_nvram_getenv("boardtype", buf, sizeof(buf)); 124 + if (len > 0) { 125 + err = kstrtou16(strim(buf), 0, &iv->boardinfo.type); 126 + if (err) 127 + pr_warn("Couldn't parse nvram board type entry with value \"%s\"\n", 128 + buf); 129 + } 113 130 114 131 memset(&iv->sprom, 0, sizeof(struct ssb_sprom)); 115 132 bcm47xx_fill_sprom(&iv->sprom, NULL, false);
-13
arch/mips/bcm47xx/sprom.c
··· 599 599 bcm47xx_sprom_fill_auto(sprom, prefix, fallback); 600 600 } 601 601 602 - #ifdef CONFIG_BCM47XX_SSB 603 - void bcm47xx_fill_ssb_boardinfo(struct ssb_boardinfo *boardinfo, 604 - const char *prefix) 605 - { 606 - nvram_read_u16(prefix, NULL, "boardvendor", &boardinfo->vendor, 0, 607 - true); 608 - if (!boardinfo->vendor) 609 - boardinfo->vendor = SSB_BOARDVENDOR_BCM; 610 - 611 - nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0, true); 612 - } 613 - #endif 614 - 615 602 #if defined(CONFIG_BCM47XX_SSB) 616 603 static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out) 617 604 {
-5
arch/mips/include/asm/mach-bcm47xx/bcm47xx.h
··· 48 48 void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix, 49 49 bool fallback); 50 50 51 - #ifdef CONFIG_BCM47XX_SSB 52 - void bcm47xx_fill_ssb_boardinfo(struct ssb_boardinfo *boardinfo, 53 - const char *prefix); 54 - #endif 55 - 56 51 void bcm47xx_set_system_type(u16 chip_id); 57 52 58 53 #endif /* __ASM_BCM47XX_H */