Commit 8fef502e authored by Henrique de Moraes Holschuh's avatar Henrique de Moraes Holschuh Committed by Len Brown

ACPI: thinkpad-acpi: keep track of module state

Keep track of module state (init, running, exit).  This makes it trivially
easy to avoid running any interrupt handlers, threads, or any other async
activity before we are ready, or when we want to go away.
Signed-off-by: default avatarHenrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent 8523ed6f
...@@ -117,6 +117,12 @@ IBM_BIOS_MODULE_ALIAS("K[U,X-Z]"); ...@@ -117,6 +117,12 @@ IBM_BIOS_MODULE_ALIAS("K[U,X-Z]");
#define __unused __attribute__ ((unused)) #define __unused __attribute__ ((unused))
static enum {
TPACPI_LIFE_INIT = 0,
TPACPI_LIFE_RUNNING,
TPACPI_LIFE_EXITING,
} tpacpi_lifecycle;
/**************************************************************************** /****************************************************************************
**************************************************************************** ****************************************************************************
* *
...@@ -342,6 +348,9 @@ static void dispatch_acpi_notify(acpi_handle handle, u32 event, void *data) ...@@ -342,6 +348,9 @@ static void dispatch_acpi_notify(acpi_handle handle, u32 event, void *data)
{ {
struct ibm_struct *ibm = data; struct ibm_struct *ibm = data;
if (tpacpi_lifecycle != TPACPI_LIFE_RUNNING)
return;
if (!ibm || !ibm->acpi || !ibm->acpi->notify) if (!ibm || !ibm->acpi || !ibm->acpi->notify)
return; return;
...@@ -3899,6 +3908,9 @@ static void fan_watchdog_fire(struct work_struct *ignored) ...@@ -3899,6 +3908,9 @@ static void fan_watchdog_fire(struct work_struct *ignored)
{ {
int rc; int rc;
if (tpacpi_lifecycle != TPACPI_LIFE_RUNNING)
return;
printk(IBM_NOTICE "fan watchdog: enabling fan\n"); printk(IBM_NOTICE "fan watchdog: enabling fan\n");
rc = fan_set_enable(); rc = fan_set_enable();
if (rc < 0) { if (rc < 0) {
...@@ -3919,7 +3931,8 @@ static void fan_watchdog_reset(void) ...@@ -3919,7 +3931,8 @@ static void fan_watchdog_reset(void)
if (fan_watchdog_active) if (fan_watchdog_active)
cancel_delayed_work(&fan_watchdog_task); cancel_delayed_work(&fan_watchdog_task);
if (fan_watchdog_maxinterval > 0) { if (fan_watchdog_maxinterval > 0 &&
tpacpi_lifecycle != TPACPI_LIFE_EXITING) {
fan_watchdog_active = 1; fan_watchdog_active = 1;
if (!schedule_delayed_work(&fan_watchdog_task, if (!schedule_delayed_work(&fan_watchdog_task,
msecs_to_jiffies(fan_watchdog_maxinterval msecs_to_jiffies(fan_watchdog_maxinterval
...@@ -4685,6 +4698,8 @@ static int __init thinkpad_acpi_module_init(void) ...@@ -4685,6 +4698,8 @@ static int __init thinkpad_acpi_module_init(void)
{ {
int ret, i; int ret, i;
tpacpi_lifecycle = TPACPI_LIFE_INIT;
/* Parameter checking */ /* Parameter checking */
if (hotkey_report_mode > 2) if (hotkey_report_mode > 2)
return -EINVAL; return -EINVAL;
...@@ -4781,6 +4796,7 @@ static int __init thinkpad_acpi_module_init(void) ...@@ -4781,6 +4796,7 @@ static int __init thinkpad_acpi_module_init(void)
tp_features.input_device_registered = 1; tp_features.input_device_registered = 1;
} }
tpacpi_lifecycle = TPACPI_LIFE_RUNNING;
return 0; return 0;
} }
...@@ -4788,6 +4804,8 @@ static void thinkpad_acpi_module_exit(void) ...@@ -4788,6 +4804,8 @@ static void thinkpad_acpi_module_exit(void)
{ {
struct ibm_struct *ibm, *itmp; struct ibm_struct *ibm, *itmp;
tpacpi_lifecycle = TPACPI_LIFE_EXITING;
list_for_each_entry_safe_reverse(ibm, itmp, list_for_each_entry_safe_reverse(ibm, itmp,
&tpacpi_all_drivers, &tpacpi_all_drivers,
all_drivers) { all_drivers) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment