Skip to content

Commit

Permalink
Merge tag 'platform-drivers-x86-v4.16-6' of git://git.infradead.org/l…
Browse files Browse the repository at this point in the history
…inux-platform-drivers-x86

Pull x86 platform driver fixes from Darren Hart:
 "Correct a module loading race condition between the DELL_SMBIOS
  backend modules and the first user by converting them to bool features
  of the DELL_SMBIOS driver. Fixup the resulting Kconfig dependency
  issue with DCDBAS"

* tag 'platform-drivers-x86-v4.16-6' of git://git.infradead.org/linux-platform-drivers-x86:
  platform/x86: dell-smbios: Resolve dependency error on DCDBAS
  platform/x86: Allow for SMBIOS backend defaults
  platform/x86: dell-smbios: Link all dell-smbios-* modules together
  platform/x86: dell-smbios: Rename dell-smbios source to dell-smbios-base
  platform/x86: dell-smbios: Correct some style warnings
  • Loading branch information
torvalds committed Mar 10, 2018
2 parents cdb06e9 + 32d7b19 commit b3337a6
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 38 deletions.
27 changes: 20 additions & 7 deletions drivers/platform/x86/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -105,31 +105,44 @@ config ASUS_LAPTOP

If you have an ACPI-compatible ASUS laptop, say Y or M here.

#
# If the DELL_SMBIOS_SMM feature is enabled, the DELL_SMBIOS driver
# becomes dependent on the DCDBAS driver. The "depends" line prevents a
# configuration where DELL_SMBIOS=y while DCDBAS=m.
#
config DELL_SMBIOS
tristate
tristate "Dell SMBIOS driver"
depends on DCDBAS || DCDBAS=n
---help---
This provides support for the Dell SMBIOS calling interface.
If you have a Dell computer you should enable this option.

Be sure to select at least one backend for it to work properly.

config DELL_SMBIOS_WMI
tristate "Dell SMBIOS calling interface (WMI implementation)"
bool "Dell SMBIOS driver WMI backend"
default y
depends on ACPI_WMI
select DELL_WMI_DESCRIPTOR
select DELL_SMBIOS
depends on DELL_SMBIOS
---help---
This provides an implementation for the Dell SMBIOS calling interface
communicated over ACPI-WMI.

If you have a Dell computer from >2007 you should say Y or M here.
If you have a Dell computer from >2007 you should say Y here.
If you aren't sure and this module doesn't work for your computer
it just won't load.

config DELL_SMBIOS_SMM
tristate "Dell SMBIOS calling interface (SMM implementation)"
bool "Dell SMBIOS driver SMM backend"
default y
depends on DCDBAS
select DELL_SMBIOS
depends on DELL_SMBIOS
---help---
This provides an implementation for the Dell SMBIOS calling interface
communicated over SMI/SMM.

If you have a Dell computer from <=2017 you should say Y or M here.
If you have a Dell computer from <=2017 you should say Y here.
If you aren't sure and this module doesn't work for your computer
it just won't load.

Expand Down
5 changes: 3 additions & 2 deletions drivers/platform/x86/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o
obj-$(CONFIG_ACPI_CMPC) += classmate-laptop.o
obj-$(CONFIG_COMPAL_LAPTOP) += compal-laptop.o
obj-$(CONFIG_DELL_SMBIOS) += dell-smbios.o
obj-$(CONFIG_DELL_SMBIOS_WMI) += dell-smbios-wmi.o
obj-$(CONFIG_DELL_SMBIOS_SMM) += dell-smbios-smm.o
dell-smbios-objs := dell-smbios-base.o
dell-smbios-$(CONFIG_DELL_SMBIOS_WMI) += dell-smbios-wmi.o
dell-smbios-$(CONFIG_DELL_SMBIOS_SMM) += dell-smbios-smm.o
obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o
obj-$(CONFIG_DELL_WMI) += dell-wmi.o
obj-$(CONFIG_DELL_WMI_DESCRIPTOR) += dell-wmi-descriptor.o
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static DEFINE_MUTEX(smbios_mutex);
struct smbios_device {
struct list_head list;
struct device *device;
int (*call_fn)(struct calling_interface_buffer *);
int (*call_fn)(struct calling_interface_buffer *arg);
};

struct smbios_call {
Expand Down Expand Up @@ -352,8 +352,10 @@ static void __init parse_da_table(const struct dmi_header *dm)
struct calling_interface_structure *table =
container_of(dm, struct calling_interface_structure, header);

/* 4 bytes of table header, plus 7 bytes of Dell header, plus at least
6 bytes of entry */
/*
* 4 bytes of table header, plus 7 bytes of Dell header
* plus at least 6 bytes of entry
*/

if (dm->length < 17)
return;
Expand Down Expand Up @@ -554,7 +556,7 @@ static void free_group(struct platform_device *pdev)
static int __init dell_smbios_init(void)
{
const struct dmi_device *valid;
int ret;
int ret, wmi, smm;

valid = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, "Dell System", NULL);
if (!valid) {
Expand Down Expand Up @@ -589,8 +591,24 @@ static int __init dell_smbios_init(void)
if (ret)
goto fail_create_group;

/* register backends */
wmi = init_dell_smbios_wmi();
if (wmi)
pr_debug("Failed to initialize WMI backend: %d\n", wmi);
smm = init_dell_smbios_smm();
if (smm)
pr_debug("Failed to initialize SMM backend: %d\n", smm);
if (wmi && smm) {
pr_err("No SMBIOS backends available (wmi: %d, smm: %d)\n",
wmi, smm);
goto fail_sysfs;
}

return 0;

fail_sysfs:
free_group(platform_device);

fail_create_group:
platform_device_del(platform_device);

Expand All @@ -607,6 +625,8 @@ static int __init dell_smbios_init(void)

static void __exit dell_smbios_exit(void)
{
exit_dell_smbios_wmi();
exit_dell_smbios_smm();
mutex_lock(&smbios_mutex);
if (platform_device) {
free_group(platform_device);
Expand All @@ -623,5 +643,6 @@ module_exit(dell_smbios_exit);
MODULE_AUTHOR("Matthew Garrett <[email protected]>");
MODULE_AUTHOR("Gabriele Mazzotta <[email protected]>");
MODULE_AUTHOR("Pali Rohár <[email protected]>");
MODULE_AUTHOR("Mario Limonciello <[email protected]>");
MODULE_DESCRIPTION("Common functions for kernel modules using Dell SMBIOS");
MODULE_LICENSE("GPL");
18 changes: 4 additions & 14 deletions drivers/platform/x86/dell-smbios-smm.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static const struct dmi_system_id dell_device_table[] __initconst = {
};
MODULE_DEVICE_TABLE(dmi, dell_device_table);

static void __init parse_da_table(const struct dmi_header *dm)
static void parse_da_table(const struct dmi_header *dm)
{
struct calling_interface_structure *table =
container_of(dm, struct calling_interface_structure, header);
Expand All @@ -73,7 +73,7 @@ static void __init parse_da_table(const struct dmi_header *dm)
da_command_code = table->cmdIOCode;
}

static void __init find_cmd_address(const struct dmi_header *dm, void *dummy)
static void find_cmd_address(const struct dmi_header *dm, void *dummy)
{
switch (dm->type) {
case 0xda: /* Calling interface */
Expand Down Expand Up @@ -128,7 +128,7 @@ static bool test_wsmt_enabled(void)
return false;
}

static int __init dell_smbios_smm_init(void)
int init_dell_smbios_smm(void)
{
int ret;
/*
Expand Down Expand Up @@ -176,21 +176,11 @@ static int __init dell_smbios_smm_init(void)
return ret;
}

static void __exit dell_smbios_smm_exit(void)
void exit_dell_smbios_smm(void)
{
if (platform_device) {
dell_smbios_unregister_device(&platform_device->dev);
platform_device_unregister(platform_device);
free_page((unsigned long)buffer);
}
}

subsys_initcall(dell_smbios_smm_init);
module_exit(dell_smbios_smm_exit);

MODULE_AUTHOR("Matthew Garrett <[email protected]>");
MODULE_AUTHOR("Gabriele Mazzotta <[email protected]>");
MODULE_AUTHOR("Pali Rohár <[email protected]>");
MODULE_AUTHOR("Mario Limonciello <[email protected]>");
MODULE_DESCRIPTION("Dell SMBIOS communications over SMI");
MODULE_LICENSE("GPL");
14 changes: 4 additions & 10 deletions drivers/platform/x86/dell-smbios-wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ static const struct wmi_device_id dell_smbios_wmi_id_table[] = {
{ },
};

static void __init parse_b1_table(const struct dmi_header *dm)
static void parse_b1_table(const struct dmi_header *dm)
{
struct misc_bios_flags_structure *flags =
container_of(dm, struct misc_bios_flags_structure, header);
Expand All @@ -242,7 +242,7 @@ static void __init parse_b1_table(const struct dmi_header *dm)
wmi_supported = 1;
}

static void __init find_b1(const struct dmi_header *dm, void *dummy)
static void find_b1(const struct dmi_header *dm, void *dummy)
{
switch (dm->type) {
case 0xb1: /* misc bios flags */
Expand All @@ -261,7 +261,7 @@ static struct wmi_driver dell_smbios_wmi_driver = {
.filter_callback = dell_smbios_wmi_filter,
};

static int __init init_dell_smbios_wmi(void)
int init_dell_smbios_wmi(void)
{
dmi_walk(find_b1, NULL);

Expand All @@ -271,15 +271,9 @@ static int __init init_dell_smbios_wmi(void)
return wmi_driver_register(&dell_smbios_wmi_driver);
}

static void __exit exit_dell_smbios_wmi(void)
void exit_dell_smbios_wmi(void)
{
wmi_driver_unregister(&dell_smbios_wmi_driver);
}

module_init(init_dell_smbios_wmi);
module_exit(exit_dell_smbios_wmi);

MODULE_ALIAS("wmi:" DELL_WMI_SMBIOS_GUID);
MODULE_AUTHOR("Mario Limonciello <[email protected]>");
MODULE_DESCRIPTION("Dell SMBIOS communications over WMI");
MODULE_LICENSE("GPL");
27 changes: 26 additions & 1 deletion drivers/platform/x86/dell-smbios.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,29 @@ int dell_laptop_register_notifier(struct notifier_block *nb);
int dell_laptop_unregister_notifier(struct notifier_block *nb);
void dell_laptop_call_notifier(unsigned long action, void *data);

#endif
/* for the supported backends */
#ifdef CONFIG_DELL_SMBIOS_WMI
int init_dell_smbios_wmi(void);
void exit_dell_smbios_wmi(void);
#else /* CONFIG_DELL_SMBIOS_WMI */
static inline int init_dell_smbios_wmi(void)
{
return -ENODEV;
}
static inline void exit_dell_smbios_wmi(void)
{}
#endif /* CONFIG_DELL_SMBIOS_WMI */

#ifdef CONFIG_DELL_SMBIOS_SMM
int init_dell_smbios_smm(void);
void exit_dell_smbios_smm(void);
#else /* CONFIG_DELL_SMBIOS_SMM */
static inline int init_dell_smbios_smm(void)
{
return -ENODEV;
}
static inline void exit_dell_smbios_smm(void)
{}
#endif /* CONFIG_DELL_SMBIOS_SMM */

#endif /* _DELL_SMBIOS_H_ */

0 comments on commit b3337a6

Please sign in to comment.