X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fsbus%2Fchar%2Fenvctrl.c;fp=drivers%2Fsbus%2Fchar%2Fenvctrl.c;h=19e8eddf887a8538325307d135d38883d3dbb08c;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=f6ed35b24f43167e689d836b2b3081421aecd84a;hpb=cee37fe97739d85991964371c1f3a745c00dd236;p=linux-2.6.git diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c index f6ed35b24..19e8eddf8 100644 --- a/drivers/sbus/char/envctrl.c +++ b/drivers/sbus/char/envctrl.c @@ -19,9 +19,13 @@ * Daniele Bellucci */ +#define __KERNEL_SYSCALLS__ +static int errno; + #include #include #include +#include #include #include #include @@ -35,10 +39,6 @@ #include #include -#define __KERNEL_SYSCALLS__ -static int errno; -#include - #define ENVCTRL_MINOR 162 #define PCF8584_ADDRESS 0x55 @@ -654,9 +654,8 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) /* Function Description: Command what to read. Mapped to user ioctl(). * Return: Gives 0 for implemented commands, -EINVAL otherwise. */ -static int -envctrl_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) +static long +envctrl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { char __user *infobuf; @@ -715,11 +714,14 @@ envctrl_release(struct inode *inode, struct file *file) } static struct file_operations envctrl_fops = { - .owner = THIS_MODULE, - .read = envctrl_read, - .ioctl = envctrl_ioctl, - .open = envctrl_open, - .release = envctrl_release, + .owner = THIS_MODULE, + .read = envctrl_read, + .unlocked_ioctl = envctrl_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = envctrl_ioctl, +#endif + .open = envctrl_open, + .release = envctrl_release, }; static struct miscdevice envctrl_dev = { @@ -1007,21 +1009,15 @@ static int kenvctrld(void *__unused) return -ENODEV; } - poll_interval = 5 * HZ; /* TODO env_mon_interval */ - - daemonize("kenvctrld"); - allow_signal(SIGKILL); - - kenvctrld_task = current; + poll_interval = 5000; /* TODO env_mon_interval */ printk(KERN_INFO "envctrl: %s starting...\n", current->comm); for (;;) { - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(poll_interval); + msleep_interruptible(poll_interval); - if(signal_pending(current)) + if (kthread_should_stop()) break; - + for (whichcpu = 0; whichcpu < ENVCTRL_MAX_CPU; ++whichcpu) { if (0 < envctrl_read_cpu_info(whichcpu, cputemp, ENVCTRL_CPUTEMP_MON, @@ -1043,7 +1039,6 @@ static int kenvctrld(void *__unused) static int __init envctrl_init(void) { -#ifdef CONFIG_PCI struct linux_ebus *ebus = NULL; struct linux_ebus_device *edev = NULL; struct linux_ebus_child *edev_child = NULL; @@ -1120,9 +1115,11 @@ done: i2c_childlist[i].addr, (0 == i) ? ("\n") : (" ")); } - err = kernel_thread(kenvctrld, NULL, CLONE_FS | CLONE_FILES); - if (err < 0) + kenvctrld_task = kthread_run(kenvctrld, NULL, "kenvctrld"); + if (IS_ERR(kenvctrld_task)) { + err = PTR_ERR(kenvctrld_task); goto out_deregister; + } return 0; @@ -1130,50 +1127,23 @@ out_deregister: misc_deregister(&envctrl_dev); out_iounmap: iounmap(i2c); - for (i = 0; i < ENVCTRL_MAX_CPU * 2; i++) { - if (i2c_childlist[i].tables) - kfree(i2c_childlist[i].tables); - } + for (i = 0; i < ENVCTRL_MAX_CPU * 2; i++) + kfree(i2c_childlist[i].tables); + return err; -#else - return -ENODEV; -#endif } static void __exit envctrl_cleanup(void) { int i; - if (NULL != kenvctrld_task) { - force_sig(SIGKILL, kenvctrld_task); - for (;;) { - struct task_struct *p; - int found = 0; - - read_lock(&tasklist_lock); - for_each_process(p) { - if (p == kenvctrld_task) { - found = 1; - break; - } - } - read_unlock(&tasklist_lock); - - if (!found) - break; - - msleep(1000); - } - kenvctrld_task = NULL; - } + kthread_stop(kenvctrld_task); iounmap(i2c); misc_deregister(&envctrl_dev); - for (i = 0; i < ENVCTRL_MAX_CPU * 2; i++) { - if (i2c_childlist[i].tables) - kfree(i2c_childlist[i].tables); - } + for (i = 0; i < ENVCTRL_MAX_CPU * 2; i++) + kfree(i2c_childlist[i].tables); } module_init(envctrl_init);