Received: by 2002:a05:7208:3188:b0:7e:5202:c8b4 with SMTP id r8csp897859rbd; Fri, 23 Feb 2024 07:02:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXsm8QTxKaRN2+B7PWRWgoq8RViODWTjDAPd/f005OAF03YasSI/7wGq5APIsAYTLa99OZriWoT7fzxO5zg2ZvvwBGaPpPrtbdGwdbLRg== X-Google-Smtp-Source: AGHT+IHOeLQpbZhbvKxNFWf+xaI/TjJ9hY7XtF6N5dafRlEoXEnPSzexCM9bbtMclbcerc7XKR0Q X-Received: by 2002:a05:620a:1a0e:b0:785:c9d1:547d with SMTP id bk14-20020a05620a1a0e00b00785c9d1547dmr41702qkb.78.1708700544521; Fri, 23 Feb 2024 07:02:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708700544; cv=pass; d=google.com; s=arc-20160816; b=wL3YC4sbqM0aaAD5tF4ipoChn6mLn7oWBdCm8S2kMZWRaLIAFZRvUsJ6Nj7x0h0Ryx xXXm18YtO1pKXmxGH/OgNFhbJAodSWYVhodF0rF8YesvJD7IB5QtVL4worLZZtfpBb2y J37e1HDR5MquOJG4xTPKljaq27BRYxAh4XFmYRoHOqN6STLfAWnSTI3sFSF6rvFy/YvD 7+VElhb25N35o8lTirgMHkmsyba0Xsm8ybCYuNWft5hgJk48RVOoVK4NIqx1lx8CCL49 ebT/3k4+QN6Ed3CD4xtT3aoUzv/1BsOP8EBOwnbLxjNhLZhUZgqWT+PZo8MrIidiVE+D fwXw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=feedback-id:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=Ci8PMP1Pzu30o6eQ/UkO3C2lOnB6ykVjgbgAHidq5Rg=; fh=dm92o28IZ7FulkllDw/laVtlt7WszpicqasS4Q6JFH8=; b=F+ktyDnDxrOH1/T2Ykigg9RmdBICcoRK41nCfMwBIY8yUnqkyGqhYDQccGu9LE5fsr nX2vGDvu8nhk97jbTqbaB3Xd8uum4hO/91OhZxg4vJJeEhw7BTSPalVWWGjaDrwOM13f HQvsVKMYcqDS0hhKwQUjtmnA1BCI90ZAyiqi6eP2YMCsZS9l5TuZow4oWLFG/7vsGqv2 gadsInriIK/LXcYr/xZNeiMmO3W8qssM11E/gtN2DsRYzlho+UgfdSzSdKfJ6BV6kuS3 BekHOPzgKruWXOTwL1UDSFOwhpuDrWDKN5KOpe9XG+JBKR7h/YFVA5n1872QpHVzCt2y +DIw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78561-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78561-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=starlabs.systems Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id i15-20020a05620a144f00b007817072c0fesi15466635qkl.493.2024.02.23.07.02.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 07:02:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78561-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78561-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78561-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=starlabs.systems Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3C4E51C214DF for ; Fri, 23 Feb 2024 15:02:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 593FD6E60D; Fri, 23 Feb 2024 15:02:20 +0000 (UTC) Received: from queue02a.mail.zen.net.uk (queue02a.mail.zen.net.uk [212.23.3.234]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E00F341C76 for ; Fri, 23 Feb 2024 15:02:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.23.3.234 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708700539; cv=none; b=fhFUF37v/56QtzDwW7lNYoqhUCWyc/iVvYtz+XoXvYhsYolxXIh/Ot0m0jastTwHArQpeMEjK/8WQ21YKm60N3cKuEmoAoHQtBUDjWfsbqPaic/McXwf6kEsvw7eApswZiLJqRXr0mM1r8KmyIf5mZj1s5CXLkgtaTieRxEV5sI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708700539; c=relaxed/simple; bh=/cLHYZZ6PldVNqvvFBCjmN34dbuA1TWWS/tli9lxHSw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=uTkxpqW2Yf4CKDaV7WBrQni5fV6MrI8fZOqDy4vvf9VG8q/LBUfVtDAcJ1aX6dGMkMAVx1UZiIFeYAkL/W3QMermjaIGBeNzPxCVTAiaw2xlUb44jD2RCGZ52ZZ/wSjA7nd5w/2wN/U9Gaj56lRmSrlGTM+ToIV1eFBjftbW+7s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=starlabs.systems; spf=fail smtp.mailfrom=starlabs.systems; arc=none smtp.client-ip=212.23.3.234 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=starlabs.systems Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=starlabs.systems Received: from [212.23.1.21] (helo=smarthost01b.ixn.mail.zen.net.uk) by queue02a.mail.zen.net.uk with esmtp (Exim 4.95) (envelope-from ) id 1rdX3u-00BOzE-6W for linux-kernel@vger.kernel.org; Fri, 23 Feb 2024 15:02:07 +0000 Received: from [51.148.147.4] (helo=starbook..) by smarthost01b.ixn.mail.zen.net.uk with esmtp (Exim 4.95) (envelope-from ) id 1rdX3n-00AVCM-Hr; Fri, 23 Feb 2024 15:02:00 +0000 From: Sean Rhodes To: linux-kernel@vger.kernel.org Cc: Sean Rhodes , Jean Delvare Subject: [PATCH] dmi: Adjust the format of EC versions to match edk2 and Windows Date: Fri, 23 Feb 2024 15:01:58 +0000 Message-Id: X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Originating-smarthost01b-IP: [51.148.147.4] Feedback-ID: 51.148.147.4 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 Signed-off-by: Sean Rhodes --- 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