Skip to content

Commit 7117794

Browse files
committed
firmware: dmi_scan: Drop dmi_initialized
I don't think it makes sense to check for a possible bad initialization order at run time on every system when it is all decided at build time. A more efficient way to make sure developers do not introduce new calls to dmi_check_system() too early in the initialization sequence is to simply document the expected call order. That way, developers have a chance to get it right immediately, without having to test-boot their kernel, wonder why it does not work, and parse the kernel logs for a warning message. And we get rid of the run-time performance penalty as a nice side effect. Signed-off-by: Jean Delvare <[email protected]> Cc: Ingo Molnar <[email protected]>
1 parent 8cf4e6a commit 7117794

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

drivers/firmware/dmi_scan.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ static u16 dmi_num;
2626
static u8 smbios_entry_point[32];
2727
static int smbios_entry_point_size;
2828

29-
/*
30-
* Catch too early calls to dmi_check_system():
31-
*/
32-
static int dmi_initialized;
33-
3429
/* DMI system identification string used during boot */
3530
static char dmi_ids_string[128] __initdata;
3631

@@ -633,7 +628,7 @@ void __init dmi_scan_machine(void)
633628

634629
if (!dmi_smbios3_present(buf)) {
635630
dmi_available = 1;
636-
goto out;
631+
return;
637632
}
638633
}
639634
if (efi.smbios == EFI_INVALID_TABLE_ADDR)
@@ -651,7 +646,7 @@ void __init dmi_scan_machine(void)
651646

652647
if (!dmi_present(buf)) {
653648
dmi_available = 1;
654-
goto out;
649+
return;
655650
}
656651
} else if (IS_ENABLED(CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK)) {
657652
p = dmi_early_remap(0xF0000, 0x10000);
@@ -668,7 +663,7 @@ void __init dmi_scan_machine(void)
668663
if (!dmi_smbios3_present(buf)) {
669664
dmi_available = 1;
670665
dmi_early_unmap(p, 0x10000);
671-
goto out;
666+
return;
672667
}
673668
memcpy(buf, buf + 16, 16);
674669
}
@@ -686,16 +681,14 @@ void __init dmi_scan_machine(void)
686681
if (!dmi_present(buf)) {
687682
dmi_available = 1;
688683
dmi_early_unmap(p, 0x10000);
689-
goto out;
684+
return;
690685
}
691686
memcpy(buf, buf + 16, 16);
692687
}
693688
dmi_early_unmap(p, 0x10000);
694689
}
695690
error:
696691
pr_info("DMI not present or invalid.\n");
697-
out:
698-
dmi_initialized = 1;
699692
}
700693

701694
static ssize_t raw_table_read(struct file *file, struct kobject *kobj,
@@ -827,14 +820,14 @@ static bool dmi_is_end_of_table(const struct dmi_system_id *dmi)
827820
* Walk the blacklist table running matching functions until someone
828821
* returns non zero or we hit the end. Callback function is called for
829822
* each successful match. Returns the number of matches.
823+
*
824+
* dmi_scan_machine must be called before this function is called.
830825
*/
831826
int dmi_check_system(const struct dmi_system_id *list)
832827
{
833828
int count = 0;
834829
const struct dmi_system_id *d;
835830

836-
WARN(!dmi_initialized, KERN_ERR "dmi check: not initialized yet.\n");
837-
838831
for (d = list; !dmi_is_end_of_table(d); d++)
839832
if (dmi_matches(d)) {
840833
count++;
@@ -857,6 +850,8 @@ EXPORT_SYMBOL(dmi_check_system);
857850
*
858851
* Walk the blacklist table until the first match is found. Return the
859852
* pointer to the matching entry or NULL if there's no match.
853+
*
854+
* dmi_scan_machine must be called before this function is called.
860855
*/
861856
const struct dmi_system_id *dmi_first_match(const struct dmi_system_id *list)
862857
{

0 commit comments

Comments
 (0)