From: Sean Rhodes <sean@starlabs.systems>
To: linux-kernel@vger.kernel.org
Cc: Sean Rhodes <sean@starlabs.systems>, Jean Delvare <jdelvare@suse.com>
Subject: [PATCH] dmi: Adjust the format of EC versions to match edk2 and Windows
Date: Fri, 23 Feb 2024 15:01:58 +0000 [thread overview]
Message-ID: <a2b3d8253c5915619cd70ff884e1b57e4b0bbead.1708700494.git.sean@starlabs.systems> (raw)
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
next reply other threads:[~2024-02-23 15:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-23 15:01 Sean Rhodes [this message]
2024-03-21 12:27 ` Jean Delvare
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a2b3d8253c5915619cd70ff884e1b57e4b0bbead.1708700494.git.sean@starlabs.systems \
--to=sean@starlabs.systems \
--cc=jdelvare@suse.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®