mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dmi: Adjust the format of EC versions to match edk2 and Windows
@ 2024-02-23 15:01 Sean Rhodes
  2024-03-21 12:27 ` Jean Delvare
  0 siblings, 1 reply; 2+ messages in thread
From: Sean Rhodes @ 2024-02-23 15:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: Sean Rhodes, Jean Delvare

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@suse.com>
Signed-off-by: Sean Rhodes <sean@starlabs.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


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

end of thread, other threads:[~2024-03-21 12:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-23 15:01 [PATCH] dmi: Adjust the format of EC versions to match edk2 and Windows Sean Rhodes
2024-03-21 12:27 ` Jean Delvare

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®