]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.40/acpi-button-make-module-loadable-when-booted-in-non-acpi-mode.patch
Linux 4.14.95
[thirdparty/kernel/stable-queue.git] / releases / 4.14.40 / acpi-button-make-module-loadable-when-booted-in-non-acpi-mode.patch
CommitLineData
82779205
GKH
1From ac1e55b1fdb27c1b07a0a6fe519f1291ff1e7d40 Mon Sep 17 00:00:00 2001
2From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
3Date: Mon, 23 Apr 2018 11:16:56 +0200
4Subject: ACPI / button: make module loadable when booted in non-ACPI mode
5
6From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
7
8commit ac1e55b1fdb27c1b07a0a6fe519f1291ff1e7d40 upstream.
9
10Modules such as nouveau.ko and i915.ko have a link time dependency on
11acpi_lid_open(), and due to its use of acpi_bus_register_driver(),
12the button.ko module that provides it is only loadable when booted in
13ACPI mode. However, the ACPI button driver can be built into the core
14kernel as well, in which case the dependency can always be satisfied,
15and the dependent modules can be loaded regardless of whether the
16system was booted in ACPI mode or not.
17
18So let's fix this asymmetry by making the ACPI button driver loadable
19as a module even if not booted in ACPI mode, so it can provide the
20acpi_lid_open() symbol in the same way as when built into the kernel.
21
22Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
23[ rjw: Minor adjustments of comments, whitespace and names. ]
24Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
25Signed-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);