aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh/therm_windtunnel.c
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2007-12-12 23:57:45 -0500
committerPaul Mackerras <paulus@samba.org>2007-12-18 23:22:02 -0500
commit98f6740ea6d532550c4010960fcead2c32bd56f5 (patch)
tree074a34daab89cc3eb73b24fd3aff31482c53478b /drivers/macintosh/therm_windtunnel.c
parent39d183d87791cdfd9d430df299396c0fc688ea7a (diff)
[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: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'drivers/macintosh/therm_windtunnel.c')
-rw-r--r--drivers/macintosh/therm_windtunnel.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c
index 5452da1bb1a5..37224025f00e 100644
--- a/drivers/macintosh/therm_windtunnel.c
+++ b/drivers/macintosh/therm_windtunnel.c
@@ -36,6 +36,7 @@
36#include <linux/i2c.h> 36#include <linux/i2c.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/init.h> 38#include <linux/init.h>
39#include <linux/kthread.h>
39 40
40#include <asm/prom.h> 41#include <asm/prom.h>
41#include <asm/machdep.h> 42#include <asm/machdep.h>
@@ -61,8 +62,7 @@ I2C_CLIENT_INSMOD;
61 62
62static struct { 63static struct {
63 volatile int running; 64 volatile int running;
64 struct completion completion; 65 struct task_struct *poll_task;
65 pid_t poll_task;
66 66
67 struct semaphore lock; 67 struct semaphore lock;
68 struct of_device *of_dev; 68 struct of_device *of_dev;
@@ -282,27 +282,27 @@ restore_regs( void )
282 write_reg( x.fan, 0x00, x.r0, 1 ); 282 write_reg( x.fan, 0x00, x.r0, 1 );
283} 283}
284 284
285static int 285static int control_loop(void *dummy)
286control_loop( void *dummy )
287{ 286{
288 daemonize("g4fand"); 287 down(&x.lock);
289
290 down( &x.lock );
291 setup_hardware(); 288 setup_hardware();
289 up(&x.lock);
292 290
293 while( x.running ) { 291 for (;;) {
294 up( &x.lock );
295
296 msleep_interruptible(8000); 292 msleep_interruptible(8000);
297 293 if (kthread_should_stop())
298 down( &x.lock ); 294 break;
295
296 down(&x.lock);
299 poll_temp(); 297 poll_temp();
298 up(&x.lock);
300 } 299 }
301 300
301 down(&x.lock);
302 restore_regs(); 302 restore_regs();
303 up( &x.lock ); 303 up(&x.lock);
304 304
305 complete_and_exit( &x.completion, 0 ); 305 return 0;
306} 306}
307 307
308 308
@@ -322,8 +322,7 @@ do_attach( struct i2c_adapter *adapter )
322 ret = i2c_probe( adapter, &addr_data, &do_probe ); 322 ret = i2c_probe( adapter, &addr_data, &do_probe );
323 if( x.thermostat && x.fan ) { 323 if( x.thermostat && x.fan ) {
324 x.running = 1; 324 x.running = 1;
325 init_completion( &x.completion ); 325 x.poll_task = kthread_run(control_loop, NULL, "g4fand");
326 x.poll_task = kernel_thread( control_loop, NULL, SIGCHLD | CLONE_KERNEL );
327 } 326 }
328 } 327 }
329 return ret; 328 return ret;
@@ -339,7 +338,8 @@ do_detach( struct i2c_client *client )
339 else { 338 else {
340 if( x.running ) { 339 if( x.running ) {
341 x.running = 0; 340 x.running = 0;
342 wait_for_completion( &x.completion ); 341 kthread_stop(x.poll_task);
342 x.poll_task = NULL;
343 } 343 }
344 if( client == x.thermostat ) 344 if( client == x.thermostat )
345 x.thermostat = NULL; 345 x.thermostat = NULL;