Commit 85b8bac9 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'dmi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging

Pull dmi subsystem updates/fixes from Jean Delvare.

* 'dmi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging:
  firmware: dmi: handle missing DMI data gracefully
  firmware: dmi_scan: Fix handling of empty DMI strings
  firmware: dmi_scan: Drop dmi_initialized
  firmware: dmi: Optimize dmi_matches
parents 1726aa70 a81114d0
......@@ -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;
}
......
......@@ -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)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment