Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: kempld: Switch back to earlier ->init() behavior

Commit 9e36775c22c7 ("mfd: kempld: Remove custom DMI matching code")
removes the ability to load the driver if no matching system DMI data
is found. Before this commit the driver could be loaded using
alternative methods such as ACPI or `force_device_id` in the absence
of a matching system DMI entry.

Restore this ability while keeping the refactored
`platform_device_info` table.

Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/7d2c7e92253d851194a781720051536cca2722b8.camel@secunet.com
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Heijligen, Thomas and committed by
Lee Jones
309e65d1 597b398b

+18 -14
+18 -14
drivers/mfd/kempld-core.c
··· 779 779 static int __init kempld_init(void) 780 780 { 781 781 const struct dmi_system_id *id; 782 - int ret = -ENODEV; 783 782 784 - for (id = dmi_first_match(kempld_dmi_table); id; id = dmi_first_match(id + 1)) { 785 - /* Check, if user asked for the exact device ID match */ 786 - if (force_device_id[0] && !strstr(id->ident, force_device_id)) 787 - continue; 788 - 789 - ret = kempld_create_platform_device(&kempld_platform_data_generic); 790 - if (ret) 791 - continue; 792 - 793 - break; 783 + /* 784 + * This custom DMI iteration allows the driver to be initialized in three ways: 785 + * - When a forced_device_id string matches any ident in the kempld_dmi_table, 786 + * regardless of whether the DMI device is present in the system dmi table. 787 + * - When a matching entry is present in the DMI system tabe. 788 + * - Through alternative mechanisms like ACPI. 789 + */ 790 + if (force_device_id[0]) { 791 + for (id = kempld_dmi_table; id->matches[0].slot != DMI_NONE; id++) 792 + if (strstr(id->ident, force_device_id)) 793 + if (!kempld_create_platform_device(&kempld_platform_data_generic)) 794 + break; 795 + if (id->matches[0].slot == DMI_NONE) 796 + return -ENODEV; 797 + } else { 798 + for (id = dmi_first_match(kempld_dmi_table); id; id = dmi_first_match(id+1)) 799 + if (kempld_create_platform_device(&kempld_platform_data_generic)) 800 + break; 794 801 } 795 - if (ret) 796 - return ret; 797 - 798 802 return platform_driver_register(&kempld_driver); 799 803 } 800 804