Commit 5fe20d6e authored by Colin Leroy's avatar Colin Leroy Committed by Linus Torvalds

[PATCH] use kthread_stop in therm_adt746x

Use kthread_stop() and kthread_should_stop() instead of monitor_running and
wait_completion().
Signed-off-by: default avatarColin Leroy <colin@colino.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent e0568ece
......@@ -71,8 +71,7 @@ static enum {ADT7460, ADT7467} therm_type;
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 @@ detach_thermostat(struct i2c_adapter *adapter)
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 @@ static int monitor_task(void *arg)
#ifdef DEBUG
int mfan_speed;
#endif
monitor_running = 1;
while(monitor_running)
while(!kthread_should_stop())
{
msleep_interruptible(2000);
......@@ -316,7 +312,6 @@ static int monitor_task(void *arg)
#endif
}
complete_and_exit(&monitor_task_compl, 0);
return 0;
}
......@@ -382,7 +377,7 @@ attach_one_thermostat(struct i2c_adapter *adapter, int addr, int busno)
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 @@ attach_one_thermostat(struct i2c_adapter *adapter, int addr, int busno)
write_both_fan_speed(th, -1);
}
init_completion(&monitor_task_compl);
thread_therm = kthread_run(monitor_task, th, "kfand");
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;
}
......
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