linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MIPS: BCM63xx: improve CFE version detection
@ 2020-06-08  9:28 Álvaro Fernández Rojas
  2020-07-24 11:09 ` Thomas Bogendoerfer
  0 siblings, 1 reply; 2+ messages in thread
From: Álvaro Fernández Rojas @ 2020-06-08  9:28 UTC (permalink / raw)
  To: tsbogend, f.fainelli, jonas.gorski, bcm-kernel-feedback-list,
	linux-mips, linux-arm-kernel, linux-kernel
  Cc: Álvaro Fernández Rojas

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>
---
 arch/mips/bcm63xx/boards/board_bcm963xx.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/arch/mips/bcm63xx/boards/board_bcm963xx.c b/arch/mips/bcm63xx/boards/board_bcm963xx.c
index 36ec3dc2c999..38f812383998 100644
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
@@ -763,11 +763,25 @@ void __init board_prom_init(void)
 
 	/* dump cfe version */
 	cfe = boot_addr + BCM963XX_CFE_VERSION_OFFSET;
-	if (!memcmp(cfe, "cfe-v", 5))
-		snprintf(cfe_version, sizeof(cfe_version), "%u.%u.%u-%u.%u",
-			 cfe[5], cfe[6], cfe[7], cfe[8], cfe[9]);
-	else
+	if (strstarts(cfe, "cfe-")) {
+		if(cfe[4] == 'v') {
+			if(cfe[5] == 'd')
+				snprintf(cfe_version, 11, "%s",
+					 (char *) &cfe[5]);
+			else if (cfe[10] > 0)
+				snprintf(cfe_version, sizeof(cfe_version),
+					 "%u.%u.%u-%u.%u-%u", cfe[5], cfe[6],
+					 cfe[7], cfe[8], cfe[9], cfe[10]);
+			else
+				snprintf(cfe_version, sizeof(cfe_version),
+					 "%u.%u.%u-%u.%u", cfe[5], cfe[6],
+					 cfe[7], cfe[8], cfe[9]);
+		} else {
+			snprintf(cfe_version, 12, "%s", (char *) &cfe[4]);
+		}
+	} else {
 		strcpy(cfe_version, "unknown");
+	}
 	pr_info("CFE version: %s\n", cfe_version);
 
 	bcm63xx_nvram_init(boot_addr + BCM963XX_NVRAM_OFFSET);
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] MIPS: BCM63xx: improve CFE version detection
  2020-06-08  9:28 [PATCH] MIPS: BCM63xx: improve CFE version detection Álvaro Fernández Rojas
@ 2020-07-24 11:09 ` Thomas Bogendoerfer
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Bogendoerfer @ 2020-07-24 11:09 UTC (permalink / raw)
  To: Álvaro Fernández Rojas
  Cc: f.fainelli, jonas.gorski, bcm-kernel-feedback-list, linux-mips,
	linux-arm-kernel, linux-kernel

On Mon, Jun 08, 2020 at 11:28:35AM +0200, Álvaro Fernández Rojas wrote:
> 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>
> ---
>  arch/mips/bcm63xx/boards/board_bcm963xx.c | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-24 11:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-08  9:28 [PATCH] MIPS: BCM63xx: improve CFE version detection Álvaro Fernández Rojas
2020-07-24 11:09 ` Thomas Bogendoerfer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).