Skip to content

Commit ac1e55b

Browse files
Ard Biesheuvelrafaeljw
authored andcommitted
ACPI / button: make module loadable when booted in non-ACPI mode
Modules such as nouveau.ko and i915.ko have a link time dependency on acpi_lid_open(), and due to its use of acpi_bus_register_driver(), the button.ko module that provides it is only loadable when booted in ACPI mode. However, the ACPI button driver can be built into the core kernel as well, in which case the dependency can always be satisfied, and the dependent modules can be loaded regardless of whether the system was booted in ACPI mode or not. So let's fix this asymmetry by making the ACPI button driver loadable as a module even if not booted in ACPI mode, so it can provide the acpi_lid_open() symbol in the same way as when built into the kernel. Signed-off-by: Ard Biesheuvel <[email protected]> [ rjw: Minor adjustments of comments, whitespace and names. ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 6d08b06 commit ac1e55b

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

drivers/acpi/button.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,4 +635,26 @@ module_param_call(lid_init_state,
635635
NULL, 0644);
636636
MODULE_PARM_DESC(lid_init_state, "Behavior for reporting LID initial state");
637637

638-
module_acpi_driver(acpi_button_driver);
638+
static int acpi_button_register_driver(struct acpi_driver *driver)
639+
{
640+
/*
641+
* Modules such as nouveau.ko and i915.ko have a link time dependency
642+
* on acpi_lid_open(), and would therefore not be loadable on ACPI
643+
* capable kernels booted in non-ACPI mode if the return value of
644+
* acpi_bus_register_driver() is returned from here with ACPI disabled
645+
* when this driver is built as a module.
646+
*/
647+
if (acpi_disabled)
648+
return 0;
649+
650+
return acpi_bus_register_driver(driver);
651+
}
652+
653+
static void acpi_button_unregister_driver(struct acpi_driver *driver)
654+
{
655+
if (!acpi_disabled)
656+
acpi_bus_unregister_driver(driver);
657+
}
658+
659+
module_driver(acpi_button_driver, acpi_button_register_driver,
660+
acpi_button_unregister_driver);

0 commit comments

Comments
 (0)