Add a patch accepted in 2.6.24-rc1 that was forgotten
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / releases / upstream / 2.6.24-rc1 / 0008-ACPI-thinkpad-acpi-keep-track-of-module-state.patch
blob3946b2a80e9cbc3769dc7195f43a82713ef876a6
1 From 8fef502e5a14df05f1e755edc9175e01c9814080 Mon Sep 17 00:00:00 2001
2 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
3 Date: Sun, 23 Sep 2007 11:39:02 -0300
4 Subject: [PATCH 07/23] ACPI: thinkpad-acpi: keep track of module state
6 Keep track of module state (init, running, exit). This makes it trivially
7 easy to avoid running any interrupt handlers, threads, or any other async
8 activity before we are ready, or when we want to go away.
10 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
11 Signed-off-by: Len Brown <len.brown@intel.com>
12 ---
13 drivers/misc/thinkpad_acpi.c | 20 +++++++++++++++++++-
14 1 files changed, 19 insertions(+), 1 deletions(-)
16 diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
17 index 0ced9d6..2155139 100644
18 --- a/drivers/misc/thinkpad_acpi.c
19 +++ b/drivers/misc/thinkpad_acpi.c
20 @@ -117,6 +117,12 @@ IBM_BIOS_MODULE_ALIAS("K[U,X-Z]");
22 #define __unused __attribute__ ((unused))
24 +static enum {
25 + TPACPI_LIFE_INIT = 0,
26 + TPACPI_LIFE_RUNNING,
27 + TPACPI_LIFE_EXITING,
28 +} tpacpi_lifecycle;
30 /****************************************************************************
31 ****************************************************************************
33 @@ -342,6 +348,9 @@ static void dispatch_acpi_notify(acpi_handle handle, u32 event, void *data)
35 struct ibm_struct *ibm = data;
37 + if (tpacpi_lifecycle != TPACPI_LIFE_RUNNING)
38 + return;
40 if (!ibm || !ibm->acpi || !ibm->acpi->notify)
41 return;
43 @@ -3899,6 +3908,9 @@ static void fan_watchdog_fire(struct work_struct *ignored)
45 int rc;
47 + if (tpacpi_lifecycle != TPACPI_LIFE_RUNNING)
48 + return;
50 printk(IBM_NOTICE "fan watchdog: enabling fan\n");
51 rc = fan_set_enable();
52 if (rc < 0) {
53 @@ -3919,7 +3931,8 @@ static void fan_watchdog_reset(void)
54 if (fan_watchdog_active)
55 cancel_delayed_work(&fan_watchdog_task);
57 - if (fan_watchdog_maxinterval > 0) {
58 + if (fan_watchdog_maxinterval > 0 &&
59 + tpacpi_lifecycle != TPACPI_LIFE_EXITING) {
60 fan_watchdog_active = 1;
61 if (!schedule_delayed_work(&fan_watchdog_task,
62 msecs_to_jiffies(fan_watchdog_maxinterval
63 @@ -4685,6 +4698,8 @@ static int __init thinkpad_acpi_module_init(void)
65 int ret, i;
67 + tpacpi_lifecycle = TPACPI_LIFE_INIT;
69 /* Parameter checking */
70 if (hotkey_report_mode > 2)
71 return -EINVAL;
72 @@ -4781,6 +4796,7 @@ static int __init thinkpad_acpi_module_init(void)
73 tp_features.input_device_registered = 1;
76 + tpacpi_lifecycle = TPACPI_LIFE_RUNNING;
77 return 0;
80 @@ -4788,6 +4804,8 @@ static void thinkpad_acpi_module_exit(void)
82 struct ibm_struct *ibm, *itmp;
84 + tpacpi_lifecycle = TPACPI_LIFE_EXITING;
86 list_for_each_entry_safe_reverse(ibm, itmp,
87 &tpacpi_all_drivers,
88 all_drivers) {
89 --
90 1.5.3.4