diff options
Diffstat (limited to 'drivers/sbus/char')
-rw-r--r-- | drivers/sbus/char/bbc_envctrl.c | 39 | ||||
-rw-r--r-- | drivers/sbus/char/envctrl.c | 45 | ||||
-rw-r--r-- | drivers/sbus/char/vfc.h | 2 | ||||
-rw-r--r-- | drivers/sbus/char/vfc_dev.c | 1 | ||||
-rw-r--r-- | drivers/sbus/char/vfc_i2c.c | 19 |
5 files changed, 22 insertions, 84 deletions
diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c index b8a2c7353b0a..d44205d52bf3 100644 --- a/drivers/sbus/char/bbc_envctrl.c +++ b/drivers/sbus/char/bbc_envctrl.c @@ -7,6 +7,7 @@ #define __KERNEL_SYSCALLS__ #include <linux/kernel.h> +#include <linux/kthread.h> #include <linux/sched.h> #include <linux/slab.h> #include <linux/delay.h> @@ -459,10 +460,6 @@ static struct task_struct *kenvctrld_task; static int kenvctrld(void *__unused) { - daemonize("kenvctrld"); - allow_signal(SIGKILL); - kenvctrld_task = current; - printk(KERN_INFO "bbc_envctrl: kenvctrld starting...\n"); last_warning_jiffies = jiffies - WARN_INTERVAL; for (;;) { @@ -470,7 +467,7 @@ static int kenvctrld(void *__unused) struct bbc_fan_control *fp; msleep_interruptible(POLL_INTERVAL); - if (signal_pending(current)) + if (kthread_should_stop()) break; for (tp = all_bbc_temps; tp; tp = tp->next) { @@ -577,7 +574,6 @@ int bbc_envctrl_init(void) int temp_index = 0; int fan_index = 0; int devidx = 0; - int err = 0; while ((echild = bbc_i2c_getdev(devidx++)) != NULL) { if (!strcmp(echild->prom_name, "temperature")) @@ -585,9 +581,13 @@ int bbc_envctrl_init(void) if (!strcmp(echild->prom_name, "fan-control")) attach_one_fan(echild, fan_index++); } - if (temp_index != 0 && fan_index != 0) - err = kernel_thread(kenvctrld, NULL, CLONE_FS | CLONE_FILES); - return err; + if (temp_index != 0 && fan_index != 0) { + kenvctrld_task = kthread_run(kenvctrld, NULL, "kenvctrld"); + if (IS_ERR(kenvctrld_task)) + return PTR_ERR(kenvctrld_task); + } + + return 0; } static void destroy_one_temp(struct bbc_cpu_temperature *tp) @@ -607,26 +607,7 @@ void bbc_envctrl_cleanup(void) struct bbc_cpu_temperature *tp; struct bbc_fan_control *fp; - if (kenvctrld_task != NULL) { - 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); tp = all_bbc_temps; while (tp != NULL) { diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c index 9a8c572554f5..d765cc1bf060 100644 --- a/drivers/sbus/char/envctrl.c +++ b/drivers/sbus/char/envctrl.c @@ -24,6 +24,7 @@ #include <linux/config.h> #include <linux/module.h> #include <linux/sched.h> +#include <linux/kthread.h> #include <linux/errno.h> #include <linux/delay.h> #include <linux/ioport.h> @@ -1010,16 +1011,13 @@ static int kenvctrld(void *__unused) poll_interval = 5000; /* TODO env_mon_interval */ - daemonize("kenvctrld"); - allow_signal(SIGKILL); - - kenvctrld_task = current; - printk(KERN_INFO "envctrl: %s starting...\n", current->comm); for (;;) { - if(msleep_interruptible(poll_interval)) - break; + msleep_interruptible(poll_interval); + if (kthread_should_stop()) + break; + for (whichcpu = 0; whichcpu < ENVCTRL_MAX_CPU; ++whichcpu) { if (0 < envctrl_read_cpu_info(whichcpu, cputemp, ENVCTRL_CPUTEMP_MON, @@ -1041,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; @@ -1118,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; @@ -1133,37 +1132,13 @@ out_iounmap: 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); diff --git a/drivers/sbus/char/vfc.h b/drivers/sbus/char/vfc.h index e56a43af0f62..a7782e7da42e 100644 --- a/drivers/sbus/char/vfc.h +++ b/drivers/sbus/char/vfc.h @@ -129,8 +129,6 @@ struct vfc_dev { struct vfc_regs *phys_regs; unsigned int control_reg; struct semaphore device_lock_sem; - struct timer_list poll_timer; - wait_queue_head_t poll_wait; int instance; int busy; unsigned long which_io; diff --git a/drivers/sbus/char/vfc_dev.c b/drivers/sbus/char/vfc_dev.c index 86ce54130954..7a103698fa3c 100644 --- a/drivers/sbus/char/vfc_dev.c +++ b/drivers/sbus/char/vfc_dev.c @@ -137,7 +137,6 @@ int init_vfc_devstruct(struct vfc_dev *dev, int instance) dev->instance=instance; init_MUTEX(&dev->device_lock_sem); dev->control_reg=0; - init_waitqueue_head(&dev->poll_wait); dev->busy=0; return 0; } diff --git a/drivers/sbus/char/vfc_i2c.c b/drivers/sbus/char/vfc_i2c.c index 1faf1e75f71f..739cad9b19a1 100644 --- a/drivers/sbus/char/vfc_i2c.c +++ b/drivers/sbus/char/vfc_i2c.c @@ -79,25 +79,10 @@ int vfc_pcf8584_init(struct vfc_dev *dev) return 0; } -void vfc_i2c_delay_wakeup(struct vfc_dev *dev) -{ - /* Used to profile code and eliminate too many delays */ - VFC_I2C_DEBUG_PRINTK(("vfc%d: Delaying\n", dev->instance)); - wake_up(&dev->poll_wait); -} - void vfc_i2c_delay_no_busy(struct vfc_dev *dev, unsigned long usecs) { - DEFINE_WAIT(wait); - init_timer(&dev->poll_timer); - dev->poll_timer.expires = jiffies + usecs_to_jiffies(usecs); - dev->poll_timer.data=(unsigned long)dev; - dev->poll_timer.function=(void *)(unsigned long)vfc_i2c_delay_wakeup; - add_timer(&dev->poll_timer); - prepare_to_wait(&dev->poll_wait, &wait, TASK_UNINTERRUPTIBLE); - schedule(); - del_timer(&dev->poll_timer); - finish_wait(&dev->poll_wait, &wait); + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(usecs_to_jiffies(usecs)); } void inline vfc_i2c_delay(struct vfc_dev *dev) |