Commit 98f6740e authored by Paul Mackerras's avatar Paul Mackerras

[POWERPC] Convert therm_windtunnel.c to use the kthread API

This is fairly straightforward, and lets us get rid of x.completion
as well.
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent 39d183d8
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kthread.h>
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/machdep.h> #include <asm/machdep.h>
...@@ -61,8 +62,7 @@ I2C_CLIENT_INSMOD; ...@@ -61,8 +62,7 @@ I2C_CLIENT_INSMOD;
static struct { static struct {
volatile int running; volatile int running;
struct completion completion; struct task_struct *poll_task;
pid_t poll_task;
struct semaphore lock; struct semaphore lock;
struct of_device *of_dev; struct of_device *of_dev;
...@@ -282,27 +282,27 @@ restore_regs( void ) ...@@ -282,27 +282,27 @@ restore_regs( void )
write_reg( x.fan, 0x00, x.r0, 1 ); write_reg( x.fan, 0x00, x.r0, 1 );
} }
static int static int control_loop(void *dummy)
control_loop( void *dummy )
{ {
daemonize("g4fand"); down(&x.lock);
down( &x.lock );
setup_hardware(); setup_hardware();
up(&x.lock);
while( x.running ) { for (;;) {
up( &x.lock );
msleep_interruptible(8000); msleep_interruptible(8000);
if (kthread_should_stop())
down( &x.lock ); break;
down(&x.lock);
poll_temp(); poll_temp();
up(&x.lock);
} }
down(&x.lock);
restore_regs(); restore_regs();
up( &x.lock ); up(&x.lock);
complete_and_exit( &x.completion, 0 ); return 0;
} }
...@@ -322,8 +322,7 @@ do_attach( struct i2c_adapter *adapter ) ...@@ -322,8 +322,7 @@ do_attach( struct i2c_adapter *adapter )
ret = i2c_probe( adapter, &addr_data, &do_probe ); ret = i2c_probe( adapter, &addr_data, &do_probe );
if( x.thermostat && x.fan ) { if( x.thermostat && x.fan ) {
x.running = 1; x.running = 1;
init_completion( &x.completion ); x.poll_task = kthread_run(control_loop, NULL, "g4fand");
x.poll_task = kernel_thread( control_loop, NULL, SIGCHLD | CLONE_KERNEL );
} }
} }
return ret; return ret;
...@@ -339,7 +338,8 @@ do_detach( struct i2c_client *client ) ...@@ -339,7 +338,8 @@ do_detach( struct i2c_client *client )
else { else {
if( x.running ) { if( x.running ) {
x.running = 0; x.running = 0;
wait_for_completion( &x.completion ); kthread_stop(x.poll_task);
x.poll_task = NULL;
} }
if( client == x.thermostat ) if( client == x.thermostat )
x.thermostat = NULL; x.thermostat = NULL;
......
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