aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/thinkpad_acpi.c
diff options
context:
space:
mode:
authorHenrique de Moraes Holschuh <hmh@hmh.eng.br>2007-09-23 10:39:02 -0400
committerLen Brown <len.brown@intel.com>2007-09-23 22:38:14 -0400
commit8fef502e5a14df05f1e755edc9175e01c9814080 (patch)
treeb01f587c353c478f4805a5a6681e5593e51f8b1d /drivers/misc/thinkpad_acpi.c
parent8523ed6fb2ca04973fe759fda8ab4af72492fc7e (diff)
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: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/misc/thinkpad_acpi.c')
-rw-r--r--drivers/misc/thinkpad_acpi.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 0ced9d65c6be..2155139793b1 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -117,6 +117,12 @@ IBM_BIOS_MODULE_ALIAS("K[U,X-Z]");
117 117
118#define __unused __attribute__ ((unused)) 118#define __unused __attribute__ ((unused))
119 119
120static enum {
121 TPACPI_LIFE_INIT = 0,
122 TPACPI_LIFE_RUNNING,
123 TPACPI_LIFE_EXITING,
124} tpacpi_lifecycle;
125
120/**************************************************************************** 126/****************************************************************************
121 **************************************************************************** 127 ****************************************************************************
122 * 128 *
@@ -342,6 +348,9 @@ static void dispatch_acpi_notify(acpi_handle handle, u32 event, void *data)
342{ 348{
343 struct ibm_struct *ibm = data; 349 struct ibm_struct *ibm = data;
344 350
351 if (tpacpi_lifecycle != TPACPI_LIFE_RUNNING)
352 return;
353
345 if (!ibm || !ibm->acpi || !ibm->acpi->notify) 354 if (!ibm || !ibm->acpi || !ibm->acpi->notify)
346 return; 355 return;
347 356
@@ -3899,6 +3908,9 @@ static void fan_watchdog_fire(struct work_struct *ignored)
3899{ 3908{
3900 int rc; 3909 int rc;
3901 3910
3911 if (tpacpi_lifecycle != TPACPI_LIFE_RUNNING)
3912 return;
3913
3902 printk(IBM_NOTICE "fan watchdog: enabling fan\n"); 3914 printk(IBM_NOTICE "fan watchdog: enabling fan\n");
3903 rc = fan_set_enable(); 3915 rc = fan_set_enable();
3904 if (rc < 0) { 3916 if (rc < 0) {
@@ -3919,7 +3931,8 @@ static void fan_watchdog_reset(void)
3919 if (fan_watchdog_active) 3931 if (fan_watchdog_active)
3920 cancel_delayed_work(&fan_watchdog_task); 3932 cancel_delayed_work(&fan_watchdog_task);
3921 3933
3922 if (fan_watchdog_maxinterval > 0) { 3934 if (fan_watchdog_maxinterval > 0 &&
3935 tpacpi_lifecycle != TPACPI_LIFE_EXITING) {
3923 fan_watchdog_active = 1; 3936 fan_watchdog_active = 1;
3924 if (!schedule_delayed_work(&fan_watchdog_task, 3937 if (!schedule_delayed_work(&fan_watchdog_task,
3925 msecs_to_jiffies(fan_watchdog_maxinterval 3938 msecs_to_jiffies(fan_watchdog_maxinterval
@@ -4685,6 +4698,8 @@ static int __init thinkpad_acpi_module_init(void)
4685{ 4698{
4686 int ret, i; 4699 int ret, i;
4687 4700
4701 tpacpi_lifecycle = TPACPI_LIFE_INIT;
4702
4688 /* Parameter checking */ 4703 /* Parameter checking */
4689 if (hotkey_report_mode > 2) 4704 if (hotkey_report_mode > 2)
4690 return -EINVAL; 4705 return -EINVAL;
@@ -4781,6 +4796,7 @@ static int __init thinkpad_acpi_module_init(void)
4781 tp_features.input_device_registered = 1; 4796 tp_features.input_device_registered = 1;
4782 } 4797 }
4783 4798
4799 tpacpi_lifecycle = TPACPI_LIFE_RUNNING;
4784 return 0; 4800 return 0;
4785} 4801}
4786 4802
@@ -4788,6 +4804,8 @@ static void thinkpad_acpi_module_exit(void)
4788{ 4804{
4789 struct ibm_struct *ibm, *itmp; 4805 struct ibm_struct *ibm, *itmp;
4790 4806
4807 tpacpi_lifecycle = TPACPI_LIFE_EXITING;
4808
4791 list_for_each_entry_safe_reverse(ibm, itmp, 4809 list_for_each_entry_safe_reverse(ibm, itmp,
4792 &tpacpi_all_drivers, 4810 &tpacpi_all_drivers,
4793 all_drivers) { 4811 all_drivers) {