diff -Naru a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c --- a/drivers/macintosh/therm_adt746x.c 2005-04-14 03:20:33 -07:00 +++ b/drivers/macintosh/therm_adt746x.c 2005-04-14 03:20:33 -07:00 @@ -71,8 +71,7 @@ static int therm_bus, therm_address; static struct of_device * of_dev; static struct thermostat* thermostat; -static int monitor_running; -static struct completion monitor_task_compl; +static struct task_struct *thread_therm = NULL; static int attach_one_thermostat(struct i2c_adapter *adapter, int addr, int busno); static void write_both_fan_speed(struct thermostat *th, int speed); @@ -136,9 +135,8 @@ th = thermostat; - if (monitor_running) { - monitor_running = 0; - wait_for_completion(&monitor_task_compl); + if (thread_therm != NULL) { + kthread_stop(thread_therm); } printk(KERN_INFO "adt746x: Putting max temperatures back from %d, %d, %d," @@ -237,9 +235,7 @@ #ifdef DEBUG int mfan_speed; #endif - monitor_running = 1; - - while(monitor_running) + while(!kthread_should_stop()) { msleep_interruptible(2000); @@ -316,7 +312,6 @@ #endif } - complete_and_exit(&monitor_task_compl, 0); return 0; } @@ -382,7 +377,7 @@ thermostat = th; if (i2c_attach_client(&th->clt)) { - printk("adt746x: Thermostat failed to attach client !\n"); + printk(KERN_INFO "adt746x: Thermostat failed to attach client !\n"); thermostat = NULL; kfree(th); return -ENODEV; @@ -398,9 +393,13 @@ write_both_fan_speed(th, -1); } - init_completion(&monitor_task_compl); - - kthread_run(monitor_task, th, "kfand"); + thread_therm = kthread_run(monitor_task, th, "kfand"); + + if (thread_therm == ERR_PTR(-ENOMEM)) { + printk(KERN_INFO "adt746x: Kthread creation failed\n"); + thread_therm = NULL; + return -ENOMEM; + } return 0; } # This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/10/03 09:14:13-07:00 colin@colino.net # [PATCH] use kthread_stop in therm_adt746x # # Use kthread_stop() and kthread_should_stop() instead of monitor_running and # wait_completion(). # # Signed-off-by: Colin Leroy # Signed-off-by: Andrew Morton # Signed-off-by: Linus Torvalds # # drivers/macintosh/therm_adt746x.c # 2004/10/02 21:04:57-07:00 colin@colino.net +12 -13 # use kthread_stop in therm_adt746x #