summaryrefslogtreecommitdiffstats
path: root/drivers/firmware
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2018-02-03 11:25:20 +0100
committerJean Delvare <jdelvare@suse.de>2018-02-03 11:25:20 +0100
commit8cf4e6a04f734e831c2ac7f405071d1cde690ba8 (patch)
tree6ccfdf2f05682eaf5455bce675f92cb34176fe4d /drivers/firmware
parentd8a5b80568a9cb66810e75b182018e9edb68e8ff (diff)
downloadlinux-8cf4e6a04f734e831c2ac7f405071d1cde690ba8.tar.gz
linux-8cf4e6a04f734e831c2ac7f405071d1cde690ba8.tar.bz2
linux-8cf4e6a04f734e831c2ac7f405071d1cde690ba8.zip
firmware: dmi: Optimize dmi_matches
Function dmi_matches can me made a bit faster: * The documented purpose of dmi_initialized is to catch too early calls to dmi_check_system(). I'm not fully convinced it justifies slowing down the initialization of all systems out there, but at least the check should not have been moved from dmi_check_system() to dmi_matches(). dmi_matches() is being called for every entry of the table passed to dmi_check_system(), causing the same redundant check to be performed again and again. So move it back to dmi_check_system(), reverting this specific portion of commit d7b1956fed33 ("DMI: Introduce dmi_first_match to make the interface more flexible"). * Don't check for the exact_match flag again when we already know its value. Signed-off-by: Jean Delvare <jdelvare@suse.de> Fixes: d7b1956fed33 ("DMI: Introduce dmi_first_match to make the interface more flexible") Cc: Jani Nikula <jani.nikula@linux.intel.com> Cc: Daniel Vetter <daniel.vetter@intel.com> Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Cc: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/firmware')
-rw-r--r--drivers/firmware/dmi_scan.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 783041964439..84356d86f359 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -784,19 +784,20 @@ static bool dmi_matches(const struct dmi_system_id *dmi)
{
int i;
- WARN(!dmi_initialized, KERN_ERR "dmi check: not initialized yet.\n");
-
for (i = 0; i < ARRAY_SIZE(dmi->matches); i++) {
int s = dmi->matches[i].slot;
if (s == DMI_NONE)
break;
if (dmi_ident[s]) {
- if (!dmi->matches[i].exact_match &&
- strstr(dmi_ident[s], dmi->matches[i].substr))
- continue;
- else if (dmi->matches[i].exact_match &&
- !strcmp(dmi_ident[s], dmi->matches[i].substr))
- continue;
+ if (dmi->matches[i].exact_match) {
+ if (!strcmp(dmi_ident[s],
+ dmi->matches[i].substr))
+ continue;
+ } else {
+ if (strstr(dmi_ident[s],
+ dmi->matches[i].substr))
+ continue;
+ }
}
/* No match */
@@ -832,6 +833,8 @@ int dmi_check_system(const struct dmi_system_id *list)
int count = 0;
const struct dmi_system_id *d;
+ WARN(!dmi_initialized, KERN_ERR "dmi check: not initialized yet.\n");
+
for (d = list; !dmi_is_end_of_table(d); d++)
if (dmi_matches(d)) {
count++;