Skip to content

Commit c8a622e

Browse files
Ard Biesheuvelgregkh
authored andcommitted
ACPI / button: make module loadable when booted in non-ACPI mode
commit ac1e55b upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 63d9df9 commit c8a622e

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
@@ -595,4 +595,26 @@ module_param_call(lid_init_state,
595595
NULL, 0644);
596596
MODULE_PARM_DESC(lid_init_state, "Behavior for reporting LID initial state");
597597

598-
module_acpi_driver(acpi_button_driver);
598+
static int acpi_button_register_driver(struct acpi_driver *driver)
599+
{
600+
/*
601+
* Modules such as nouveau.ko and i915.ko have a link time dependency
602+
* on acpi_lid_open(), and would therefore not be loadable on ACPI
603+
* capable kernels booted in non-ACPI mode if the return value of
604+
* acpi_bus_register_driver() is returned from here with ACPI disabled
605+
* when this driver is built as a module.
606+
*/
607+
if (acpi_disabled)
608+
return 0;
609+
610+
return acpi_bus_register_driver(driver);
611+
}
612+
613+
static void acpi_button_unregister_driver(struct acpi_driver *driver)
614+
{
615+
if (!acpi_disabled)
616+
acpi_bus_unregister_driver(driver);
617+
}
618+
619+
module_driver(acpi_button_driver, acpi_button_register_driver,
620+
acpi_button_unregister_driver);

0 commit comments

Comments
 (0)