Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1278091 > unrolled thread

[PATCH] firmware: dmi_scan: Optimize dmi_save_extended_devices

Started byJean Delvare <jdelvare@suse.de>
First post2015-11-26 10:00 +0100
Last post2015-11-27 13:50 +0100
Articles 2 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] firmware: dmi_scan: Optimize dmi_save_extended_devices Jean Delvare <jdelvare@suse.de> - 2015-11-26 10:00 +0100
    [PATCH] firmware: dmi_scan: Clarify dmi_save_extended_devices Jean Delvare <jdelvare@suse.de> - 2015-11-27 13:50 +0100

#1278091 — [PATCH] firmware: dmi_scan: Optimize dmi_save_extended_devices

FromJean Delvare <jdelvare@suse.de>
Date2015-11-26 10:00 +0100
Subject[PATCH] firmware: dmi_scan: Optimize dmi_save_extended_devices
Message-ID<qz0zf-2JX-3@gated-at.bofh.it>
Calling dmi_string_nosave isn't cheap, so avoid calling it twice in a
row for the same string.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Jordan Hargrave <jordan_hargrave@dell.com>
Cc: Narendra K <narendra_k@dell.com>
---
 drivers/firmware/dmi_scan.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- linux-4.3.orig/drivers/firmware/dmi_scan.c	2015-11-25 20:32:26.565009189 +0100
+++ linux-4.3/drivers/firmware/dmi_scan.c	2015-11-26 09:44:34.242605581 +0100
@@ -345,15 +345,17 @@ static void __init dmi_save_dev_onboard(
 
 static void __init dmi_save_extended_devices(const struct dmi_header *dm)
 {
+	const char *name;
 	const u8 *d = (u8 *) dm + 5;
 
 	/* Skip disabled device */
 	if ((*d & 0x80) == 0)
 		return;
 
+	name = dmi_string_nosave(dm, *(d - 1));
 	dmi_save_dev_onboard(*(d+1), *(u16 *)(d+2), *(d+4), *(d+5),
-			     dmi_string_nosave(dm, *(d-1)));
-	dmi_save_one_device(*d & 0x7f, dmi_string_nosave(dm, *(d - 1)));
+			     name);
+	dmi_save_one_device(*d & 0x7f, name);
 }
 
 static void __init count_mem_devices(const struct dmi_header *dm, void *v)

-- 
Jean Delvare
SUSE L3 Support
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1278791 — [PATCH] firmware: dmi_scan: Clarify dmi_save_extended_devices

FromJean Delvare <jdelvare@suse.de>
Date2015-11-27 13:50 +0100
Subject[PATCH] firmware: dmi_scan: Clarify dmi_save_extended_devices
Message-ID<qzqDn-2Ve-5@gated-at.bofh.it>
In reply to#1278091
Get rid of the arbitrary 5-byte pointer offset, it served no purpose
and made it harder to match the code with the SMBIOS specification.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Jordan Hargrave <jordan_hargrave@dell.com>
Cc: Narendra K <narendra_k@dell.com>
---
Note: goes on top of the patch "Optimize dmi_save_extended_devices" I
sent yesterday. Also both patches collide with Jordan's current work,
but I will take care of merging everything, don't worry.

 drivers/firmware/dmi_scan.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

--- linux-4.3.orig/drivers/firmware/dmi_scan.c	2015-11-27 13:30:59.855014180 +0100
+++ linux-4.3/drivers/firmware/dmi_scan.c	2015-11-27 13:36:03.264773918 +0100
@@ -346,16 +346,15 @@ static void __init dmi_save_dev_onboard(
 static void __init dmi_save_extended_devices(const struct dmi_header *dm)
 {
 	const char *name;
-	const u8 *d = (u8 *) dm + 5;
+	const u8 *d = (u8 *)dm;
 
 	/* Skip disabled device */
-	if ((*d & 0x80) == 0)
+	if ((d[0x5] & 0x80) == 0)
 		return;
 
-	name = dmi_string_nosave(dm, *(d - 1));
-	dmi_save_dev_onboard(*(d+1), *(u16 *)(d+2), *(d+4), *(d+5),
-			     name);
-	dmi_save_one_device(*d & 0x7f, name);
+	name = dmi_string_nosave(dm, d[0x4]);
+	dmi_save_dev_onboard(d[0x6], *(u16 *)(d + 0x7), d[0x9], d[0xA], name);
+	dmi_save_one_device(d[0x5] & 0x7f, name);
 }
 
 static void __init count_mem_devices(const struct dmi_header *dm, void *v)

-- 
Jean Delvare
SUSE L3 Support
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web