[PATCH] firmware: dmi_scan: Optimize dmi_save_extended_devices

From: Jean Delvare
Date: Thu Nov 26 2015 - 03:51:32 EST


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@xxxxxxx>
Cc: Jordan Hargrave <jordan_hargrave@xxxxxxxx>
Cc: Narendra K <narendra_k@xxxxxxxx>
---
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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/