X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fmacintosh%2Ftherm_windtunnel.c;h=d11821af3b8d07e7a70c5d07f3ac84bc5859b52e;hb=e4e0fadcd929138aa82130a1c5f22206d86d7bb2;hp=b66da74caa55b868c8a9ba401942e7ceebab9abd;hpb=91525300baf162e83e923b09ca286f9205e21522;p=linux-2.6 diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c index b66da74caa..d11821af3b 100644 --- a/drivers/macintosh/therm_windtunnel.c +++ b/drivers/macintosh/therm_windtunnel.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -59,8 +60,7 @@ I2C_CLIENT_INSMOD; static struct { volatile int running; - struct completion completion; - pid_t poll_task; + struct task_struct *poll_task; struct semaphore lock; struct of_device *of_dev; @@ -221,6 +221,7 @@ static void setup_hardware( void ) { int val; + int err; /* save registers (if we unload the module) */ x.r0 = read_reg( x.fan, 0x00, 1 ); @@ -263,8 +264,11 @@ setup_hardware( void ) x.upind = -1; /* tune_fan( fan_up_table[x.upind].fan_setting ); */ - device_create_file( &x.of_dev->dev, &dev_attr_cpu_temperature ); - device_create_file( &x.of_dev->dev, &dev_attr_case_temperature ); + err = device_create_file( &x.of_dev->dev, &dev_attr_cpu_temperature ); + err |= device_create_file( &x.of_dev->dev, &dev_attr_case_temperature ); + if (err) + printk(KERN_WARNING + "Failed to create temperature attribute file(s).\n"); } static void @@ -280,27 +284,27 @@ restore_regs( void ) write_reg( x.fan, 0x00, x.r0, 1 ); } -static int -control_loop( void *dummy ) +static int control_loop(void *dummy) { - daemonize("g4fand"); - - down( &x.lock ); + down(&x.lock); setup_hardware(); + up(&x.lock); - while( x.running ) { - up( &x.lock ); - + for (;;) { msleep_interruptible(8000); - - down( &x.lock ); + if (kthread_should_stop()) + break; + + down(&x.lock); poll_temp(); + up(&x.lock); } + down(&x.lock); restore_regs(); - up( &x.lock ); + up(&x.lock); - complete_and_exit( &x.completion, 0 ); + return 0; } @@ -320,8 +324,7 @@ do_attach( struct i2c_adapter *adapter ) ret = i2c_probe( adapter, &addr_data, &do_probe ); if( x.thermostat && x.fan ) { x.running = 1; - init_completion( &x.completion ); - x.poll_task = kernel_thread( control_loop, NULL, SIGCHLD | CLONE_KERNEL ); + x.poll_task = kthread_run(control_loop, NULL, "g4fand"); } } return ret; @@ -337,7 +340,8 @@ do_detach( struct i2c_client *client ) else { if( x.running ) { x.running = 0; - wait_for_completion( &x.completion ); + kthread_stop(x.poll_task); + x.poll_task = NULL; } if( client == x.thermostat ) x.thermostat = NULL;