diff options
| -rw-r--r-- | drivers/firmware/dmi-sysfs.c | 2 | ||||
| -rw-r--r-- | drivers/firmware/dmi_scan.c | 64 |
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) | |||
| 652 | int val; | 652 | int val; |
| 653 | 653 | ||
| 654 | if (!dmi_kobj) { | 654 | if (!dmi_kobj) { |
| 655 | pr_err("dmi-sysfs: dmi entry is absent.\n"); | 655 | pr_debug("dmi-sysfs: dmi entry is absent.\n"); |
| 656 | error = -ENODATA; | 656 | error = -ENODATA; |
| 657 | goto err; | 657 | goto err; |
| 658 | } | 658 | } |
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); | |||
| 18 | * of and an antecedent to, SMBIOS, which stands for System | 18 | * of and an antecedent to, SMBIOS, which stands for System |
| 19 | * Management BIOS. See further: http://www.dmtf.org/standards | 19 | * Management BIOS. See further: http://www.dmtf.org/standards |
| 20 | */ | 20 | */ |
| 21 | static const char dmi_empty_string[] = " "; | 21 | static const char dmi_empty_string[] = ""; |
| 22 | 22 | ||
| 23 | static u32 dmi_ver __initdata; | 23 | static u32 dmi_ver __initdata; |
| 24 | static u32 dmi_len; | 24 | static u32 dmi_len; |
| @@ -26,11 +26,6 @@ static u16 dmi_num; | |||
| 26 | static u8 smbios_entry_point[32]; | 26 | static u8 smbios_entry_point[32]; |
| 27 | static int smbios_entry_point_size; | 27 | static int smbios_entry_point_size; |
| 28 | 28 | ||
| 29 | /* | ||
| 30 | * Catch too early calls to dmi_check_system(): | ||
| 31 | */ | ||
| 32 | static int dmi_initialized; | ||
| 33 | |||
| 34 | /* DMI system identification string used during boot */ | 29 | /* DMI system identification string used during boot */ |
| 35 | static char dmi_ids_string[128] __initdata; | 30 | static char dmi_ids_string[128] __initdata; |
| 36 | 31 | ||
| @@ -44,25 +39,21 @@ static int dmi_memdev_nr; | |||
| 44 | static const char * __init dmi_string_nosave(const struct dmi_header *dm, u8 s) | 39 | static const char * __init dmi_string_nosave(const struct dmi_header *dm, u8 s) |
| 45 | { | 40 | { |
| 46 | const u8 *bp = ((u8 *) dm) + dm->length; | 41 | const u8 *bp = ((u8 *) dm) + dm->length; |
| 42 | const u8 *nsp; | ||
| 47 | 43 | ||
| 48 | if (s) { | 44 | if (s) { |
| 49 | s--; | 45 | while (--s > 0 && *bp) |
| 50 | while (s > 0 && *bp) { | ||
| 51 | bp += strlen(bp) + 1; | 46 | bp += strlen(bp) + 1; |
| 52 | s--; | ||
| 53 | } | ||
| 54 | 47 | ||
| 55 | if (*bp != 0) { | 48 | /* Strings containing only spaces are considered empty */ |
| 56 | size_t len = strlen(bp)+1; | 49 | nsp = bp; |
| 57 | size_t cmp_len = len > 8 ? 8 : len; | 50 | while (*nsp == ' ') |
| 58 | 51 | nsp++; | |
| 59 | if (!memcmp(bp, dmi_empty_string, cmp_len)) | 52 | if (*nsp != '\0') |
| 60 | return dmi_empty_string; | ||
| 61 | return bp; | 53 | return bp; |
| 62 | } | ||
| 63 | } | 54 | } |
| 64 | 55 | ||
| 65 | return ""; | 56 | return dmi_empty_string; |
| 66 | } | 57 | } |
| 67 | 58 | ||
| 68 | static const char * __init dmi_string(const struct dmi_header *dm, u8 s) | 59 | static const char * __init dmi_string(const struct dmi_header *dm, u8 s) |
| @@ -633,7 +624,7 @@ void __init dmi_scan_machine(void) | |||
| 633 | 624 | ||
| 634 | if (!dmi_smbios3_present(buf)) { | 625 | if (!dmi_smbios3_present(buf)) { |
| 635 | dmi_available = 1; | 626 | dmi_available = 1; |
| 636 | goto out; | 627 | return; |
| 637 | } | 628 | } |
| 638 | } | 629 | } |
| 639 | if (efi.smbios == EFI_INVALID_TABLE_ADDR) | 630 | if (efi.smbios == EFI_INVALID_TABLE_ADDR) |
| @@ -651,7 +642,7 @@ void __init dmi_scan_machine(void) | |||
| 651 | 642 | ||
| 652 | if (!dmi_present(buf)) { | 643 | if (!dmi_present(buf)) { |
| 653 | dmi_available = 1; | 644 | dmi_available = 1; |
| 654 | goto out; | 645 | return; |
| 655 | } | 646 | } |
| 656 | } else if (IS_ENABLED(CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK)) { | 647 | } else if (IS_ENABLED(CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK)) { |
| 657 | p = dmi_early_remap(0xF0000, 0x10000); | 648 | p = dmi_early_remap(0xF0000, 0x10000); |
| @@ -668,7 +659,7 @@ void __init dmi_scan_machine(void) | |||
| 668 | if (!dmi_smbios3_present(buf)) { | 659 | if (!dmi_smbios3_present(buf)) { |
| 669 | dmi_available = 1; | 660 | dmi_available = 1; |
| 670 | dmi_early_unmap(p, 0x10000); | 661 | dmi_early_unmap(p, 0x10000); |
| 671 | goto out; | 662 | return; |
| 672 | } | 663 | } |
| 673 | memcpy(buf, buf + 16, 16); | 664 | memcpy(buf, buf + 16, 16); |
| 674 | } | 665 | } |
| @@ -686,7 +677,7 @@ void __init dmi_scan_machine(void) | |||
| 686 | if (!dmi_present(buf)) { | 677 | if (!dmi_present(buf)) { |
| 687 | dmi_available = 1; | 678 | dmi_available = 1; |
| 688 | dmi_early_unmap(p, 0x10000); | 679 | dmi_early_unmap(p, 0x10000); |
| 689 | goto out; | 680 | return; |
| 690 | } | 681 | } |
| 691 | memcpy(buf, buf + 16, 16); | 682 | memcpy(buf, buf + 16, 16); |
| 692 | } | 683 | } |
| @@ -694,8 +685,6 @@ void __init dmi_scan_machine(void) | |||
| 694 | } | 685 | } |
| 695 | error: | 686 | error: |
| 696 | pr_info("DMI not present or invalid.\n"); | 687 | pr_info("DMI not present or invalid.\n"); |
| 697 | out: | ||
| 698 | dmi_initialized = 1; | ||
| 699 | } | 688 | } |
| 700 | 689 | ||
| 701 | static ssize_t raw_table_read(struct file *file, struct kobject *kobj, | 690 | static ssize_t raw_table_read(struct file *file, struct kobject *kobj, |
| @@ -715,10 +704,8 @@ static int __init dmi_init(void) | |||
| 715 | u8 *dmi_table; | 704 | u8 *dmi_table; |
| 716 | int ret = -ENOMEM; | 705 | int ret = -ENOMEM; |
| 717 | 706 | ||
| 718 | if (!dmi_available) { | 707 | if (!dmi_available) |
| 719 | ret = -ENODATA; | 708 | return 0; |
| 720 | goto err; | ||
| 721 | } | ||
| 722 | 709 | ||
| 723 | /* | 710 | /* |
| 724 | * Set up dmi directory at /sys/firmware/dmi. This entry should stay | 711 | * 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) | |||
| 784 | { | 771 | { |
| 785 | int i; | 772 | int i; |
| 786 | 773 | ||
| 787 | WARN(!dmi_initialized, KERN_ERR "dmi check: not initialized yet.\n"); | ||
| 788 | |||
| 789 | for (i = 0; i < ARRAY_SIZE(dmi->matches); i++) { | 774 | for (i = 0; i < ARRAY_SIZE(dmi->matches); i++) { |
| 790 | int s = dmi->matches[i].slot; | 775 | int s = dmi->matches[i].slot; |
| 791 | if (s == DMI_NONE) | 776 | if (s == DMI_NONE) |
| 792 | break; | 777 | break; |
| 793 | if (dmi_ident[s]) { | 778 | if (dmi_ident[s]) { |
| 794 | if (!dmi->matches[i].exact_match && | 779 | if (dmi->matches[i].exact_match) { |
| 795 | strstr(dmi_ident[s], dmi->matches[i].substr)) | 780 | if (!strcmp(dmi_ident[s], |
| 796 | continue; | 781 | dmi->matches[i].substr)) |
| 797 | else if (dmi->matches[i].exact_match && | 782 | continue; |
| 798 | !strcmp(dmi_ident[s], dmi->matches[i].substr)) | 783 | } else { |
| 799 | continue; | 784 | if (strstr(dmi_ident[s], |
| 785 | dmi->matches[i].substr)) | ||
| 786 | continue; | ||
| 787 | } | ||
| 800 | } | 788 | } |
| 801 | 789 | ||
| 802 | /* No match */ | 790 | /* No match */ |
| @@ -826,6 +814,8 @@ static bool dmi_is_end_of_table(const struct dmi_system_id *dmi) | |||
| 826 | * Walk the blacklist table running matching functions until someone | 814 | * Walk the blacklist table running matching functions until someone |
| 827 | * returns non zero or we hit the end. Callback function is called for | 815 | * returns non zero or we hit the end. Callback function is called for |
| 828 | * each successful match. Returns the number of matches. | 816 | * each successful match. Returns the number of matches. |
| 817 | * | ||
| 818 | * dmi_scan_machine must be called before this function is called. | ||
| 829 | */ | 819 | */ |
| 830 | int dmi_check_system(const struct dmi_system_id *list) | 820 | int dmi_check_system(const struct dmi_system_id *list) |
| 831 | { | 821 | { |
| @@ -854,6 +844,8 @@ EXPORT_SYMBOL(dmi_check_system); | |||
| 854 | * | 844 | * |
| 855 | * Walk the blacklist table until the first match is found. Return the | 845 | * Walk the blacklist table until the first match is found. Return the |
| 856 | * pointer to the matching entry or NULL if there's no match. | 846 | * pointer to the matching entry or NULL if there's no match. |
| 847 | * | ||
| 848 | * dmi_scan_machine must be called before this function is called. | ||
| 857 | */ | 849 | */ |
| 858 | const struct dmi_system_id *dmi_first_match(const struct dmi_system_id *list) | 850 | const struct dmi_system_id *dmi_first_match(const struct dmi_system_id *list) |
| 859 | { | 851 | { |
