Subject: [PATCH] [acpi thermal] Add timer for checking on thermal values - Add ->t_enabled to struct acpi_thermal - Add ->t_timer to struct acpi_thermal to hold the timer - Implement timer_init() to set up the timer, and call on device bind - Implement timer_exit() and call on device unbind Signed-off-by: Patrick Mochel --- drivers/acpi/drivers/thermal/driver.c | 47 ++++++++++++++++++++++++++++++++ drivers/acpi/drivers/thermal/thermal.h | 3 ++ 2 files changed, 50 insertions(+), 0 deletions(-) applies-to: 26c20a0aa06660dab2287e8c9be3b594e9106ca2 f897a0d8e1a2c5d8fe9a8faf7b4c6ee50d6ee3a2 diff --git a/drivers/acpi/drivers/thermal/driver.c b/drivers/acpi/drivers/thermal/driver.c index 11b7e73..0ca0df8 100644 --- a/drivers/acpi/drivers/thermal/driver.c +++ b/drivers/acpi/drivers/thermal/driver.c @@ -99,6 +99,49 @@ static int thermal_init(struct acpi_ther return 0; } +static void thermal_timer(unsigned long data) +{ +#if 0 + struct acpi_thermal * at = (struct acpi_thermal *)data; + if (at->t_enabled) + acpi_os_queue_for_execution(OSD_PRIORITY_GPE, + (acpi_osd_exec_callback)thermal_check, + at); +#endif +} + +static void timer_init(struct acpi_thermal * at) +{ + init_timer(&at->t_timer); + at->t_timer.data = (unsigned long) at; + at->t_timer.function = thermal_timer; +} + +static void timer_exit(struct acpi_thermal * at) +{ + /* + * Avoid any new timer events + */ + at->t_enabled = 0; + + /* + * Remove timer and wait for other CPUs to finish + */ + del_timer_sync(&at->t_timer); + + /* + * synchronize deferred task + */ + acpi_os_wait_events_complete(NULL); + + /* + * deferred task may reinsert timer. + * + * Q: What does this mean/do? + */ + del_timer_sync(&at->t_timer); +} + static int thermal_add(struct acpi_dev * ad) { struct acpi_thermal * at; @@ -118,6 +161,8 @@ static int thermal_add(struct acpi_dev * dev_set_drvdata(&ad->dev, at); + timer_init(at); + printk(KERN_INFO PREFIX "thermal [%s] (%ld C)\n", acpi_dev_bid(ad), thermal_temp_c(at->t_temp)); @@ -127,6 +172,8 @@ static int thermal_add(struct acpi_dev * static int thermal_remove(struct acpi_dev * ad) { struct acpi_thermal * at = dev_get_drvdata(&ad->dev); + + timer_exit(at); dev_set_drvdata(&ad->dev, NULL); kfree(at); return 0; diff --git a/drivers/acpi/drivers/thermal/thermal.h b/drivers/acpi/drivers/thermal/thermal.h index c363041..d4bddd3 100644 --- a/drivers/acpi/drivers/thermal/thermal.h +++ b/drivers/acpi/drivers/thermal/thermal.h @@ -66,6 +66,9 @@ struct acpi_thermal { u32 t_have_devices; struct acpi_handle_list t_devices; + + u32 t_enabled; + struct timer_list t_timer; }; extern int thermal_get_temp(struct acpi_thermal *); --- 0.99.9.GIT