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

MIPS: BCM63xx: improve CFE version detection

There are some CFE variants that start with 'cfe-vd' instead of 'cfe-v', such
as the one used in the Huawei HG556a: "cfe-vd081.5003". In this case, the CFE
version is stored as is (string vs number bytes).

Some newer devices have an additional version number, such as the Comtrend
VR-3032u: "1.0.38-112.118-11".

Finally, print the string as is if the version doesn't start with "cfe-v" or
"cfe-vd", but starts with "cfe-".

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Álvaro Fernández Rojas and committed by
Thomas Bogendoerfer
e27e1cc9 0d10d17b

+18 -4
+18 -4
arch/mips/bcm63xx/boards/board_bcm963xx.c
··· 760 760 761 761 /* dump cfe version */ 762 762 cfe = boot_addr + BCM963XX_CFE_VERSION_OFFSET; 763 - if (!memcmp(cfe, "cfe-v", 5)) 764 - snprintf(cfe_version, sizeof(cfe_version), "%u.%u.%u-%u.%u", 765 - cfe[5], cfe[6], cfe[7], cfe[8], cfe[9]); 766 - else 763 + if (strstarts(cfe, "cfe-")) { 764 + if(cfe[4] == 'v') { 765 + if(cfe[5] == 'd') 766 + snprintf(cfe_version, 11, "%s", 767 + (char *) &cfe[5]); 768 + else if (cfe[10] > 0) 769 + snprintf(cfe_version, sizeof(cfe_version), 770 + "%u.%u.%u-%u.%u-%u", cfe[5], cfe[6], 771 + cfe[7], cfe[8], cfe[9], cfe[10]); 772 + else 773 + snprintf(cfe_version, sizeof(cfe_version), 774 + "%u.%u.%u-%u.%u", cfe[5], cfe[6], 775 + cfe[7], cfe[8], cfe[9]); 776 + } else { 777 + snprintf(cfe_version, 12, "%s", (char *) &cfe[4]); 778 + } 779 + } else { 767 780 strcpy(cfe_version, "unknown"); 781 + } 768 782 pr_info("CFE version: %s\n", cfe_version); 769 783 770 784 bcm63xx_nvram_init(boot_addr + BCM963XX_NVRAM_OFFSET);