From 44d352ed6bd06a9d9aa5dffc2caa682d5d124e66 Mon Sep 17 00:00:00 2001 From: Vasant Hegde Date: Thu, 18 Jan 2018 12:30:43 +0530 Subject: [PATCH] DT: Add "version" property under ibm, firmware-versions node First line of VERSION section in PNOR contains firmware version. Use that to add "version" property under firmware versions dt node. Sample output: -------------- root@xxx2:/proc/device-tree/ibm,firmware-versions# lsprop version "witherspoon-ibm-OP9_v1.19_1.94" .... ... Suggested-by: Stewart Smith Signed-off-by: Vasant Hegde Signed-off-by: Stewart Smith --- core/flash.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/flash.c b/core/flash.c index eacf55bb72be..d526ef33a220 100644 --- a/core/flash.c +++ b/core/flash.c @@ -156,6 +156,7 @@ static int flash_nvram_write(uint32_t dst, void *src, uint32_t len) static void __flash_dt_add_fw_version(struct dt_node *fw_version, char* data) { + static bool first = true; char *prop; int version_len, i; int len = strlen(data); @@ -164,6 +165,25 @@ static void __flash_dt_add_fw_version(struct dt_node *fw_version, char* data) "petitboot", "occ", "capp-ucode", "sbe", "machine-xml"}; + if (first) { + first = false; + + /* Increment past "key-" */ + if (memcmp(data, "open-power", strlen("open-power")) == 0) + prop = data + strlen("open-power"); + else + prop = strchr(data, '-'); + if (!prop) { + prlog(PR_DEBUG, + "FLASH: Invalid fw version format (%s)\n", data); + return; + } + prop++; + + dt_add_property_string(fw_version, "version", prop); + return; + } + /* * PNOR version strings are not easily consumable. Split them into * property, value.