[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <a2b3d8253c5915619cd70ff884e1b57e4b0bbead.1708700494.git.sean@starlabs.systems>
Date: Fri, 23 Feb 2024 15:01:58 +0000
From: Sean Rhodes <sean@...rlabs.systems>
To: linux-kernel@...r.kernel.org
Cc: Sean Rhodes <sean@...rlabs.systems>,
Jean Delvare <jdelvare@...e.com>
Subject: [PATCH] dmi: Adjust the format of EC versions to match edk2 and Windows
Currently, Linux displays the raw bytes for EC firmware versions, which can
lead to confusion due to formatting mismatches with other platforms like edk2
and Windows.
These platforms format EC versions as `%d.%02d`, ensuring that the minor
version is zero-padded to two digits. This discrepancy becomes particularly
noticeable with version numbers where the minor version could be
misinterpreted, such as interpreting `1.02` as `1.2`, which does not clearly
distinguish it from `1.20`.
To align Linux's presentation of EC firmware versions with these platforms
and to minimize confusion, this commit adjusts the format to `%d.%02d`,
matching the convention used by edk2 and Windows.
Cc: Jean Delvare <jdelvare@...e.com>
Signed-off-by: Sean Rhodes <sean@...rlabs.systems>
---
drivers/firmware/dmi-id.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
index 5f3a3e913d28..5bb921c4f62d 100644
--- a/drivers/firmware/dmi-id.c
+++ b/drivers/firmware/dmi-id.c
@@ -114,12 +114,20 @@ static ssize_t get_modalias(char *buffer, size_t buffer_size)
if (!c)
continue;
- t = kmalloc(strlen(c) + 1, GFP_KERNEL);
- if (!t)
- break;
- ascii_filter(t, c);
- l = scnprintf(p, left, ":%s%s", f->prefix, t);
- kfree(t);
+ if (f->field == DMI_EC_FIRMWARE_RELEASE) {
+ int major, minor;
+ if (sscanf(c, "%d.%d", &major, &minor) == 2)
+ l = scnprintf(p, left, ":%s%d.%02d", f->prefix, major, minor);
+ else
+ l = scnprintf(p, left, ":%s%s", f->prefix, c);
+ } else {
+ t = kmalloc(strlen(c) + 1, GFP_KERNEL);
+ if (!t)
+ break;
+ ascii_filter(t, c);
+ l = scnprintf(p, left, ":%s%s", f->prefix, t);
+ kfree(t);
+ }
p += l;
left -= l;
--
2.40.1
Powered by blists - more mailing lists