Blob Blame History Raw
From 941591e24564e4c6d6584dbaa868976f9e80e925 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Tue, 15 Jan 2019 12:59:08 +0100
Subject: [PATCH 4/5] dmidecode: Use dmi_cache_size_2 in dmi_cache_size

Redirect dmi_cache_size() to dmi_cache_size_2() so that the cache
size is always reported using the most appropriate unit, even if the
BIOS does not populate the 32-bit cache size fields.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
---
 dmidecode.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/dmidecode.c b/dmidecode.c
index 162e0c50ba26..903ef356ea9e 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -1550,14 +1550,6 @@ static const char *dmi_cache_location(u8 code)
 	return location[code];
 }
 
-static void dmi_cache_size(u16 code)
-{
-	if (code & 0x8000)
-		printf(" %u kB", (code & 0x7FFF) << 6);
-	else
-		printf(" %u kB", code);
-}
-
 static void dmi_cache_size_2(u32 code)
 {
 	u64 size;
@@ -1578,6 +1570,11 @@ static void dmi_cache_size_2(u32 code)
 	dmi_print_memory_size(size, 1);
 }
 
+static void dmi_cache_size(u16 code)
+{
+	dmi_cache_size_2((((u32)code & 0x8000LU) << 16) | (code & 0x7FFFLU));
+}
+
 static void dmi_cache_types(u16 code, const char *sep)
 {
 	/* 7.8.2 */
-- 
2.17.1