db7f50
From c43afb47fcbadabe2655fe7863a1e2ea9af1446c Mon Sep 17 00:00:00 2001
db7f50
From: Jean Delvare <jdelvare@suse.de>
db7f50
Date: Tue, 15 Jan 2019 12:59:00 +0100
db7f50
Subject: [PATCH 2/4] dmidecode: Use the most appropriate unit for cache size
db7f50
db7f50
As newer CPUs have larger and larger cache, using kB to represent the
db7f50
cache size is getting less convenient. Reuse the same function we have
db7f50
for system memory size so that large units will be used as
db7f50
appropriate. For example, a cache size reported as "20 MB" looks nicer
db7f50
than as "20480 kB".
db7f50
db7f50
Signed-off-by: Jean Delvare <jdelvare@suse.de>
db7f50
Acked-by: Neil Horman <nhorman@tuxdriver.com>
db7f50
---
db7f50
 dmidecode.c | 17 +++++++++++------
db7f50
 1 file changed, 11 insertions(+), 6 deletions(-)
db7f50
db7f50
diff --git a/dmidecode.c b/dmidecode.c
db7f50
index 7ac6438..162e0c5 100644
db7f50
--- a/dmidecode.c
db7f50
+++ b/dmidecode.c
db7f50
@@ -1560,17 +1560,22 @@ static void dmi_cache_size(u16 code)
db7f50
 
db7f50
 static void dmi_cache_size_2(u32 code)
db7f50
 {
db7f50
+	u64 size;
db7f50
+
db7f50
 	if (code & 0x80000000)
db7f50
 	{
db7f50
 		code &= 0x7FFFFFFFLU;
db7f50
-		/* Use a more convenient unit for large cache size */
db7f50
-		if (code >= 0x8000)
db7f50
-			printf(" %u MB", code >> 4);
db7f50
-		else
db7f50
-			printf(" %u kB", code << 6);
db7f50
+		size.l = code << 6;
db7f50
+		size.h = code >> 26;
db7f50
 	}
db7f50
 	else
db7f50
-		printf(" %u kB", code);
db7f50
+	{
db7f50
+		size.l = code;
db7f50
+		size.h = 0;
db7f50
+	}
db7f50
+
db7f50
+	/* Use a more convenient unit for large cache size */
db7f50
+	dmi_print_memory_size(size, 1);
db7f50
 }
db7f50
 
db7f50
 static void dmi_cache_types(u16 code, const char *sep)
db7f50
-- 
db7f50
2.17.1
db7f50