b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From e27e1cc9d360a347dbd5a398e9df21cfb4e60e3c Mon Sep 17 00:00:00 2001 |
| 2 | From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari@gmail.com> |
| 3 | Date: Mon, 8 Jun 2020 11:28:35 +0200 |
| 4 | Subject: [PATCH] MIPS: BCM63xx: improve CFE version detection |
| 5 | MIME-Version: 1.0 |
| 6 | Content-Type: text/plain; charset=UTF-8 |
| 7 | Content-Transfer-Encoding: 8bit |
| 8 | |
| 9 | There are some CFE variants that start with 'cfe-vd' instead of 'cfe-v', such |
| 10 | as the one used in the Huawei HG556a: "cfe-vd081.5003". In this case, the CFE |
| 11 | version is stored as is (string vs number bytes). |
| 12 | |
| 13 | Some newer devices have an additional version number, such as the Comtrend |
| 14 | VR-3032u: "1.0.38-112.118-11". |
| 15 | |
| 16 | Finally, print the string as is if the version doesn't start with "cfe-v" or |
| 17 | "cfe-vd", but starts with "cfe-". |
| 18 | |
| 19 | Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> |
| 20 | Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> |
| 21 | --- |
| 22 | arch/mips/bcm63xx/boards/board_bcm963xx.c | 22 ++++++++++++++++++---- |
| 23 | 1 file changed, 18 insertions(+), 4 deletions(-) |
| 24 | |
| 25 | --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c |
| 26 | +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c |
| 27 | @@ -760,11 +760,25 @@ void __init board_prom_init(void) |
| 28 | |
| 29 | /* dump cfe version */ |
| 30 | cfe = boot_addr + BCM963XX_CFE_VERSION_OFFSET; |
| 31 | - if (!memcmp(cfe, "cfe-v", 5)) |
| 32 | - snprintf(cfe_version, sizeof(cfe_version), "%u.%u.%u-%u.%u", |
| 33 | - cfe[5], cfe[6], cfe[7], cfe[8], cfe[9]); |
| 34 | - else |
| 35 | + if (strstarts(cfe, "cfe-")) { |
| 36 | + if(cfe[4] == 'v') { |
| 37 | + if(cfe[5] == 'd') |
| 38 | + snprintf(cfe_version, 11, "%s", |
| 39 | + (char *) &cfe[5]); |
| 40 | + else if (cfe[10] > 0) |
| 41 | + snprintf(cfe_version, sizeof(cfe_version), |
| 42 | + "%u.%u.%u-%u.%u-%u", cfe[5], cfe[6], |
| 43 | + cfe[7], cfe[8], cfe[9], cfe[10]); |
| 44 | + else |
| 45 | + snprintf(cfe_version, sizeof(cfe_version), |
| 46 | + "%u.%u.%u-%u.%u", cfe[5], cfe[6], |
| 47 | + cfe[7], cfe[8], cfe[9]); |
| 48 | + } else { |
| 49 | + snprintf(cfe_version, 12, "%s", (char *) &cfe[4]); |
| 50 | + } |
| 51 | + } else { |
| 52 | strcpy(cfe_version, "unknown"); |
| 53 | + } |
| 54 | pr_info("CFE version: %s\n", cfe_version); |
| 55 | |
| 56 | bcm63xx_nvram_init(boot_addr + BCM963XX_NVRAM_OFFSET); |