]>
Commit | Line | Data |
---|---|---|
82779205 GKH |
1 | From ac1e55b1fdb27c1b07a0a6fe519f1291ff1e7d40 Mon Sep 17 00:00:00 2001 |
2 | From: Ard Biesheuvel <ard.biesheuvel@linaro.org> | |
3 | Date: Mon, 23 Apr 2018 11:16:56 +0200 | |
4 | Subject: ACPI / button: make module loadable when booted in non-ACPI mode | |
5 | ||
6 | From: Ard Biesheuvel <ard.biesheuvel@linaro.org> | |
7 | ||
8 | commit ac1e55b1fdb27c1b07a0a6fe519f1291ff1e7d40 upstream. | |
9 | ||
10 | Modules such as nouveau.ko and i915.ko have a link time dependency on | |
11 | acpi_lid_open(), and due to its use of acpi_bus_register_driver(), | |
12 | the button.ko module that provides it is only loadable when booted in | |
13 | ACPI mode. However, the ACPI button driver can be built into the core | |
14 | kernel as well, in which case the dependency can always be satisfied, | |
15 | and the dependent modules can be loaded regardless of whether the | |
16 | system was booted in ACPI mode or not. | |
17 | ||
18 | So let's fix this asymmetry by making the ACPI button driver loadable | |
19 | as a module even if not booted in ACPI mode, so it can provide the | |
20 | acpi_lid_open() symbol in the same way as when built into the kernel. | |
21 | ||
22 | Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> | |
23 | [ rjw: Minor adjustments of comments, whitespace and names. ] | |
24 | Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | |
25 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
26 | ||
27 | --- | |
28 | drivers/acpi/button.c | 24 +++++++++++++++++++++++- | |
29 | 1 file changed, 23 insertions(+), 1 deletion(-) | |
30 | ||
31 | --- a/drivers/acpi/button.c | |
32 | +++ b/drivers/acpi/button.c | |
33 | @@ -595,4 +595,26 @@ module_param_call(lid_init_state, | |
34 | NULL, 0644); | |
35 | MODULE_PARM_DESC(lid_init_state, "Behavior for reporting LID initial state"); | |
36 | ||
37 | -module_acpi_driver(acpi_button_driver); | |
38 | +static int acpi_button_register_driver(struct acpi_driver *driver) | |
39 | +{ | |
40 | + /* | |
41 | + * Modules such as nouveau.ko and i915.ko have a link time dependency | |
42 | + * on acpi_lid_open(), and would therefore not be loadable on ACPI | |
43 | + * capable kernels booted in non-ACPI mode if the return value of | |
44 | + * acpi_bus_register_driver() is returned from here with ACPI disabled | |
45 | + * when this driver is built as a module. | |
46 | + */ | |
47 | + if (acpi_disabled) | |
48 | + return 0; | |
49 | + | |
50 | + return acpi_bus_register_driver(driver); | |
51 | +} | |
52 | + | |
53 | +static void acpi_button_unregister_driver(struct acpi_driver *driver) | |
54 | +{ | |
55 | + if (!acpi_disabled) | |
56 | + acpi_bus_unregister_driver(driver); | |
57 | +} | |
58 | + | |
59 | +module_driver(acpi_button_driver, acpi_button_register_driver, | |
60 | + acpi_button_unregister_driver); |