[v2] DT: Add "version" property under ibm, firmware-versions node

Message ID 20180118070043.18014-1-hegdevasant@linux.vnet.ibm.com
State Accepted
Headers show
Series
  • [v2] DT: Add "version" property under ibm, firmware-versions node
Related show

Commit Message

Vasant Hegde Jan. 18, 2018, 7 a.m.
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 <stewart@linux.vnet.ibm.com>
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
---
 core/flash.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Stewart Smith Feb. 15, 2018, 6:45 a.m. | #1
Vasant Hegde <hegdevasant@linux.vnet.ibm.com> writes:
> 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 <stewart@linux.vnet.ibm.com>
> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
> ---
>  core/flash.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)

Thanks for this, merged to master as of
44d352ed6bd06a9d9aa5dffc2caa682d5d124e66 and in v5.10-rc3

Patch

diff --git a/core/flash.c b/core/flash.c
index 2744496c0..3ea82f382 100644
--- a/core/flash.c
+++ b/core/flash.c
@@ -156,6 +156,7 @@  out:
 
 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.