Blame SOURCES/dmidecode-use-common-function-to-put-SMBIOS-in-dumpf.patch

4f8197
From d4a148740afb211dc519945a8fc8b5eaa0adf280 Mon Sep 17 00:00:00 2001
4f8197
From: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
4f8197
Date: Thu, 15 Jan 2015 02:28:22 +0200
4f8197
Subject: [PATCH 2/4] dmidecode: use common function to put SMBIOS in dumpfile
4f8197
4f8197
It's needed in order to generalize code before adding dmi sysfs
4f8197
support. It' more convenient to hold common code in separate function.
4f8197
4f8197
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
4f8197
---
4f8197
 dmidecode.c | 30 +++++++++++++++++++-----------
4f8197
 1 file changed, 19 insertions(+), 11 deletions(-)
4f8197
4f8197
diff --git a/dmidecode.c b/dmidecode.c
4f8197
index c4b4fd1..4e4a82f 100644
4f8197
--- a/dmidecode.c
4f8197
+++ b/dmidecode.c
4f8197
@@ -4503,6 +4503,24 @@ static void overwrite_dmi_address(u8 *buf)
4f8197
 	buf[0x0B] = 0;
4f8197
 }
4f8197
 
4f8197
+/**
4f8197
+ * smbios_in_dumpfile - put SMBIOS entry table in dump file
4f8197
+ * @smbios: pointer on SMBIOS entry table
4f8197
+ */
4f8197
+static void smbios_in_dumpfile(unsigned char *smbios)
4f8197
+{
4f8197
+	u8 crafted[32];
4f8197
+
4f8197
+	memcpy(crafted, smbios, 32);
4f8197
+	overwrite_dmi_address(crafted + 0x10);
4f8197
+
4f8197
+	if (!(opt.flags & FLAG_QUIET))
4f8197
+		printf("# Writing %d bytes to %s.\n", crafted[0x05],
4f8197
+		       opt.dumpfile);
4f8197
+
4f8197
+	write_dump(0, crafted[0x05], crafted, opt.dumpfile, 1);
4f8197
+}
4f8197
+
4f8197
 static int smbios_decode(u8 *buf, const char *devmem)
4f8197
 {
4f8197
 	u16 ver;
4f8197
@@ -4518,17 +4536,7 @@ static int smbios_decode(u8 *buf, const char *devmem)
4f8197
 		ver, devmem);
4f8197
 
4f8197
 	if (opt.flags & FLAG_DUMP_BIN)
4f8197
-	{
4f8197
-		u8 crafted[32];
4f8197
-
4f8197
-		memcpy(crafted, buf, 32);
4f8197
-		overwrite_dmi_address(crafted + 0x10);
4f8197
-
4f8197
-		if (!(opt.flags & FLAG_QUIET))
4f8197
-			printf("# Writing %d bytes to %s.\n", crafted[0x05],
4f8197
-				opt.dumpfile);
4f8197
-		write_dump(0, crafted[0x05], crafted, opt.dumpfile, 1);
4f8197
-	}
4f8197
+		smbios_in_dumpfile(buf);
4f8197
 
4f8197
 	return 1;
4f8197
 }
4f8197
-- 
4f8197
1.9.3
4f8197