summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/firmware/dmi-sysfs.c2
-rw-r--r--drivers/firmware/dmi_scan.c64
2 files changed, 29 insertions, 37 deletions
diff --git a/drivers/firmware/dmi-sysfs.c b/drivers/firmware/dmi-sysfs.c
index d5de6ee8466d..ecf2eeb5f6f9 100644
--- a/drivers/firmware/dmi-sysfs.c
+++ b/drivers/firmware/dmi-sysfs.c
@@ -652,7 +652,7 @@ static int __init dmi_sysfs_init(void)
int val;
if (!dmi_kobj) {
- pr_err("dmi-sysfs: dmi entry is absent.\n");
+ pr_debug("dmi-sysfs: dmi entry is absent.\n");
error = -ENODATA;
goto err;
}
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 783041964439..e763e1484331 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -18,7 +18,7 @@ EXPORT_SYMBOL_GPL(dmi_kobj);
* of and an antecedent to, SMBIOS, which stands for System
* Management BIOS. See further: http://www.dmtf.org/standards
*/
-static const char dmi_empty_string[] = " ";
+static const char dmi_empty_string[] = "";
static u32 dmi_ver __initdata;
static u32 dmi_len;
@@ -26,11 +26,6 @@ static u16 dmi_num;
static u8 smbios_entry_point[32];
static int smbios_entry_point_size;
-/*
- * Catch too early calls to dmi_check_system():
- */
-static int dmi_initialized;
-
/* DMI system identification string used during boot */
static char dmi_ids_string[128] __initdata;
@@ -44,25 +39,21 @@ static int dmi_memdev_nr;
static const char * __init dmi_string_nosave(const struct dmi_header *dm, u8 s)
{
const u8 *bp = ((u8 *) dm) + dm->length;
+ const u8 *nsp;
if (s) {
- s--;
- while (s > 0 && *bp) {
+ while (--s > 0 && *bp)
bp += strlen(bp) + 1;
- s--;
- }
- if (*bp != 0) {
- size_t len = strlen(bp)+1;
- size_t cmp_len = len > 8 ? 8 : len;
-
- if (!memcmp(bp, dmi_empty_string, cmp_len))
- return dmi_empty_string;
+ /* Strings containing only spaces are considered empty */
+ nsp = bp;
+ while (*nsp == ' ')
+ nsp++;
+ if (*nsp != '\0')
return bp;
- }
}
- return "";
+ return dmi_empty_string;
}
static const char * __init dmi_string(const struct dmi_header *dm, u8 s)
@@ -633,7 +624,7 @@ void __init dmi_scan_machine(void)
if (!dmi_smbios3_present(buf)) {
dmi_available = 1;
- goto out;
+ return;
}
}
if (efi.smbios == EFI_INVALID_TABLE_ADDR)
@@ -651,7 +642,7 @@ void __init dmi_scan_machine(void)
if (!dmi_present(buf)) {
dmi_available = 1;
- goto out;
+ return;
}
} else if (IS_ENABLED(CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK)) {
p = dmi_early_remap(0xF0000, 0x10000);
@@ -668,7 +659,7 @@ void __init dmi_scan_machine(void)
if (!dmi_smbios3_present(buf)) {
dmi_available = 1;
dmi_early_unmap(p, 0x10000);
- goto out;
+ return;
}
memcpy(buf, buf + 16, 16);
}
@@ -686,7 +677,7 @@ void __init dmi_scan_machine(void)
if (!dmi_present(buf)) {
dmi_available = 1;
dmi_early_unmap(p, 0x10000);
- goto out;
+ return;
}
memcpy(buf, buf + 16, 16);
}
@@ -694,8 +685,6 @@ void __init dmi_scan_machine(void)
}
error:
pr_info("DMI not present or invalid.\n");
- out:
- dmi_initialized = 1;
}
static ssize_t raw_table_read(struct file *file, struct kobject *kobj,
@@ -715,10 +704,8 @@ static int __init dmi_init(void)
u8 *dmi_table;
int ret = -ENOMEM;
- if (!dmi_available) {
- ret = -ENODATA;
- goto err;
- }
+ if (!dmi_available)
+ return 0;
/*
* Set up dmi directory at /sys/firmware/dmi. This entry should stay
@@ -784,19 +771,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 */
@@ -826,6 +814,8 @@ static bool dmi_is_end_of_table(const struct dmi_system_id *dmi)
* Walk the blacklist table running matching functions until someone
* returns non zero or we hit the end. Callback function is called for
* each successful match. Returns the number of matches.
+ *
+ * dmi_scan_machine must be called before this function is called.
*/
int dmi_check_system(const struct dmi_system_id *list)
{
@@ -854,6 +844,8 @@ EXPORT_SYMBOL(dmi_check_system);
*
* Walk the blacklist table until the first match is found. Return the
* pointer to the matching entry or NULL if there's no match.
+ *
+ * dmi_scan_machine must be called before this function is called.
*/
const struct dmi_system_id *dmi_first_match(const struct dmi_system_id *list)
{