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

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) ...@@ -652,7 +652,7 @@ static int __init dmi_sysfs_init(void)
int val; int val;
if (!dmi_kobj) { if (!dmi_kobj) {
pr_err("dmi-sysfs: dmi entry is absent.\n"); pr_debug("dmi-sysfs: dmi entry is absent.\n");
error = -ENODATA; error = -ENODATA;
goto err; goto err;
} }
......
...@@ -18,7 +18,7 @@ EXPORT_SYMBOL_GPL(dmi_kobj); ...@@ -18,7 +18,7 @@ EXPORT_SYMBOL_GPL(dmi_kobj);
* of and an antecedent to, SMBIOS, which stands for System * of and an antecedent to, SMBIOS, which stands for System
* Management BIOS. See further: http://www.dmtf.org/standards * 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_ver __initdata;
static u32 dmi_len; static u32 dmi_len;
...@@ -26,11 +26,6 @@ static u16 dmi_num; ...@@ -26,11 +26,6 @@ static u16 dmi_num;
static u8 smbios_entry_point[32]; static u8 smbios_entry_point[32];
static int smbios_entry_point_size; 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 */ /* DMI system identification string used during boot */
static char dmi_ids_string[128] __initdata; static char dmi_ids_string[128] __initdata;
...@@ -44,25 +39,21 @@ static int dmi_memdev_nr; ...@@ -44,25 +39,21 @@ static int dmi_memdev_nr;
static const char * __init dmi_string_nosave(const struct dmi_header *dm, u8 s) static const char * __init dmi_string_nosave(const struct dmi_header *dm, u8 s)
{ {
const u8 *bp = ((u8 *) dm) + dm->length; const u8 *bp = ((u8 *) dm) + dm->length;
const u8 *nsp;
if (s) { if (s) {
s--; while (--s > 0 && *bp)
while (s > 0 && *bp) {
bp += strlen(bp) + 1; bp += strlen(bp) + 1;
s--;
}
if (*bp != 0) { /* Strings containing only spaces are considered empty */
size_t len = strlen(bp)+1; nsp = bp;
size_t cmp_len = len > 8 ? 8 : len; while (*nsp == ' ')
nsp++;
if (!memcmp(bp, dmi_empty_string, cmp_len)) if (*nsp != '\0')
return dmi_empty_string;
return bp; return bp;
} }
}
return ""; return dmi_empty_string;
} }
static const char * __init dmi_string(const struct dmi_header *dm, u8 s) static const char * __init dmi_string(const struct dmi_header *dm, u8 s)
...@@ -633,7 +624,7 @@ void __init dmi_scan_machine(void) ...@@ -633,7 +624,7 @@ void __init dmi_scan_machine(void)
if (!dmi_smbios3_present(buf)) { if (!dmi_smbios3_present(buf)) {
dmi_available = 1; dmi_available = 1;
goto out; return;
} }
} }
if (efi.smbios == EFI_INVALID_TABLE_ADDR) if (efi.smbios == EFI_INVALID_TABLE_ADDR)
...@@ -651,7 +642,7 @@ void __init dmi_scan_machine(void) ...@@ -651,7 +642,7 @@ void __init dmi_scan_machine(void)
if (!dmi_present(buf)) { if (!dmi_present(buf)) {
dmi_available = 1; dmi_available = 1;
goto out; return;
} }
} else if (IS_ENABLED(CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK)) { } else if (IS_ENABLED(CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK)) {
p = dmi_early_remap(0xF0000, 0x10000); p = dmi_early_remap(0xF0000, 0x10000);
...@@ -668,7 +659,7 @@ void __init dmi_scan_machine(void) ...@@ -668,7 +659,7 @@ void __init dmi_scan_machine(void)
if (!dmi_smbios3_present(buf)) { if (!dmi_smbios3_present(buf)) {
dmi_available = 1; dmi_available = 1;
dmi_early_unmap(p, 0x10000); dmi_early_unmap(p, 0x10000);
goto out; return;
} }
memcpy(buf, buf + 16, 16); memcpy(buf, buf + 16, 16);
} }
...@@ -686,7 +677,7 @@ void __init dmi_scan_machine(void) ...@@ -686,7 +677,7 @@ void __init dmi_scan_machine(void)
if (!dmi_present(buf)) { if (!dmi_present(buf)) {
dmi_available = 1; dmi_available = 1;
dmi_early_unmap(p, 0x10000); dmi_early_unmap(p, 0x10000);
goto out; return;
} }
memcpy(buf, buf + 16, 16); memcpy(buf, buf + 16, 16);
} }
...@@ -694,8 +685,6 @@ void __init dmi_scan_machine(void) ...@@ -694,8 +685,6 @@ void __init dmi_scan_machine(void)
} }
error: error:
pr_info("DMI not present or invalid.\n"); pr_info("DMI not present or invalid.\n");
out:
dmi_initialized = 1;
} }
static ssize_t raw_table_read(struct file *file, struct kobject *kobj, static ssize_t raw_table_read(struct file *file, struct kobject *kobj,
...@@ -715,10 +704,8 @@ static int __init dmi_init(void) ...@@ -715,10 +704,8 @@ static int __init dmi_init(void)
u8 *dmi_table; u8 *dmi_table;
int ret = -ENOMEM; int ret = -ENOMEM;
if (!dmi_available) { if (!dmi_available)
ret = -ENODATA; return 0;
goto err;
}
/* /*
* Set up dmi directory at /sys/firmware/dmi. This entry should stay * Set up dmi directory at /sys/firmware/dmi. This entry should stay
...@@ -784,20 +771,21 @@ static bool dmi_matches(const struct dmi_system_id *dmi) ...@@ -784,20 +771,21 @@ static bool dmi_matches(const struct dmi_system_id *dmi)
{ {
int i; int i;
WARN(!dmi_initialized, KERN_ERR "dmi check: not initialized yet.\n");
for (i = 0; i < ARRAY_SIZE(dmi->matches); i++) { for (i = 0; i < ARRAY_SIZE(dmi->matches); i++) {
int s = dmi->matches[i].slot; int s = dmi->matches[i].slot;
if (s == DMI_NONE) if (s == DMI_NONE)
break; break;
if (dmi_ident[s]) { if (dmi_ident[s]) {
if (!dmi->matches[i].exact_match && if (dmi->matches[i].exact_match) {
strstr(dmi_ident[s], dmi->matches[i].substr)) if (!strcmp(dmi_ident[s],
dmi->matches[i].substr))
continue; continue;
else if (dmi->matches[i].exact_match && } else {
!strcmp(dmi_ident[s], dmi->matches[i].substr)) if (strstr(dmi_ident[s],
dmi->matches[i].substr))
continue; continue;
} }
}
/* No match */ /* No match */
return false; return false;
...@@ -826,6 +814,8 @@ static bool dmi_is_end_of_table(const struct dmi_system_id *dmi) ...@@ -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 * Walk the blacklist table running matching functions until someone
* returns non zero or we hit the end. Callback function is called for * returns non zero or we hit the end. Callback function is called for
* each successful match. Returns the number of matches. * 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) int dmi_check_system(const struct dmi_system_id *list)
{ {
...@@ -854,6 +844,8 @@ EXPORT_SYMBOL(dmi_check_system); ...@@ -854,6 +844,8 @@ EXPORT_SYMBOL(dmi_check_system);
* *
* Walk the blacklist table until the first match is found. Return the * Walk the blacklist table until the first match is found. Return the
* pointer to the matching entry or NULL if there's no match. * 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) 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