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; ...@@ -71,8 +71,7 @@ static enum {ADT7460, ADT7467} therm_type;
static int therm_bus, therm_address; static int therm_bus, therm_address;
static struct of_device * of_dev; static struct of_device * of_dev;
static struct thermostat* thermostat; static struct thermostat* thermostat;
static int monitor_running; static struct task_struct *thread_therm = NULL;
static struct completion monitor_task_compl;
static int attach_one_thermostat(struct i2c_adapter *adapter, int addr, int busno); static int attach_one_thermostat(struct i2c_adapter *adapter, int addr, int busno);
static void write_both_fan_speed(struct thermostat *th, int speed); static void write_both_fan_speed(struct thermostat *th, int speed);
...@@ -136,9 +135,8 @@ detach_thermostat(struct i2c_adapter *adapter) ...@@ -136,9 +135,8 @@ detach_thermostat(struct i2c_adapter *adapter)
th = thermostat; th = thermostat;
if (monitor_running) { if (thread_therm != NULL) {
monitor_running = 0; kthread_stop(thread_therm);
wait_for_completion(&monitor_task_compl);
} }
printk(KERN_INFO "adt746x: Putting max temperatures back from %d, %d, %d," printk(KERN_INFO "adt746x: Putting max temperatures back from %d, %d, %d,"
...@@ -237,9 +235,7 @@ static int monitor_task(void *arg) ...@@ -237,9 +235,7 @@ static int monitor_task(void *arg)
#ifdef DEBUG #ifdef DEBUG
int mfan_speed; int mfan_speed;
#endif #endif
monitor_running = 1; while(!kthread_should_stop())
while(monitor_running)
{ {
msleep_interruptible(2000); msleep_interruptible(2000);
...@@ -316,7 +312,6 @@ static int monitor_task(void *arg) ...@@ -316,7 +312,6 @@ static int monitor_task(void *arg)
#endif #endif
} }
complete_and_exit(&monitor_task_compl, 0);
return 0; return 0;
} }
...@@ -382,7 +377,7 @@ attach_one_thermostat(struct i2c_adapter *adapter, int addr, int busno) ...@@ -382,7 +377,7 @@ attach_one_thermostat(struct i2c_adapter *adapter, int addr, int busno)
thermostat = th; thermostat = th;
if (i2c_attach_client(&th->clt)) { 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; thermostat = NULL;
kfree(th); kfree(th);
return -ENODEV; return -ENODEV;
...@@ -398,9 +393,13 @@ attach_one_thermostat(struct i2c_adapter *adapter, int addr, int busno) ...@@ -398,9 +393,13 @@ attach_one_thermostat(struct i2c_adapter *adapter, int addr, int busno)
write_both_fan_speed(th, -1); 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; 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