diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-06-01 20:18:52 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-06-01 20:18:52 -0300 |
commit | 4e4c168746908b7dc88bb1fe46b7308164fb145c (patch) | |
tree | f69dfba3f28b1359e0bae7a238c7c4b1684c8878 /linux/drivers/media/video/saa7134 | |
parent | 8391e4a8e4148d94a9eaecf3fbd242d959ace901 (diff) | |
download | mediapointer-dvb-s2-4e4c168746908b7dc88bb1fe46b7308164fb145c.tar.gz mediapointer-dvb-s2-4e4c168746908b7dc88bb1fe46b7308164fb145c.tar.bz2 |
Reverting last changeset. There were two different patches merged together
From: Mauro Carvalho Chehab <mchehab@infradead.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux/drivers/media/video/saa7134')
-rw-r--r-- | linux/drivers/media/video/saa7134/saa7134-tvaudio.c | 42 | ||||
-rw-r--r-- | linux/drivers/media/video/saa7134/saa7134.h | 5 |
2 files changed, 30 insertions, 17 deletions
diff --git a/linux/drivers/media/video/saa7134/saa7134-tvaudio.c b/linux/drivers/media/video/saa7134/saa7134-tvaudio.c index b4d741aef..3a7c2b019 100644 --- a/linux/drivers/media/video/saa7134/saa7134-tvaudio.c +++ b/linux/drivers/media/video/saa7134/saa7134-tvaudio.c @@ -25,7 +25,6 @@ #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/kernel.h> -#include <linux/kthread.h> #include <linux/slab.h> #include <linux/delay.h> #include <asm/div64.h> @@ -343,8 +342,10 @@ static void tvaudio_setmode(struct saa7134_dev *dev, static int tvaudio_sleep(struct saa7134_dev *dev, int timeout) { - if (dev->thread.scan1 == dev->thread.scan2 && - !kthread_should_stop()) { + DECLARE_WAITQUEUE(wait, current); + + add_wait_queue(&dev->thread.wq, &wait); + if (dev->thread.scan1 == dev->thread.scan2 && !dev->thread.shutdown) { if (timeout < 0) { set_current_state(TASK_INTERRUPTIBLE); schedule(); @@ -353,6 +354,7 @@ static int tvaudio_sleep(struct saa7134_dev *dev, int timeout) (msecs_to_jiffies(timeout)); } } + remove_wait_queue(&dev->thread.wq, &wait); return dev->thread.scan1 != dev->thread.scan2; } @@ -528,11 +530,12 @@ static int tvaudio_thread(void *data) sprintf(current->comm, "%s", dev->name); unlock_kernel(); #else + daemonize("%s", dev->name); allow_signal(SIGTERM); #endif for (;;) { tvaudio_sleep(dev,-1); - if (kthread_should_stop() || signal_pending(current)) + if (dev->thread.shutdown || signal_pending(current)) goto done; restart: @@ -641,7 +644,7 @@ static int tvaudio_thread(void *data) for (;;) { if (tvaudio_sleep(dev,5000)) goto restart; - if (kthread_should_stop() || signal_pending(current)) + if (dev->thread.shutdown || signal_pending(current)) break; if (UNSET == dev->thread.mode) { rx = tvaudio_getstereo(dev,&tvaudio[i]); @@ -657,6 +660,7 @@ static int tvaudio_thread(void *data) } done: + complete_and_exit(&dev->thread.exit, 0); return 0; } @@ -829,6 +833,7 @@ static int tvaudio_thread_ddep(void *data) sprintf(current->comm, "%s", dev->name); unlock_kernel(); #else + daemonize("%s", dev->name); allow_signal(SIGTERM); #endif @@ -843,7 +848,7 @@ static int tvaudio_thread_ddep(void *data) for (;;) { tvaudio_sleep(dev,-1); - if (kthread_should_stop() || signal_pending(current)) + if (dev->thread.shutdown || signal_pending(current)) goto done; restart: @@ -923,6 +928,7 @@ static int tvaudio_thread_ddep(void *data) } done: + complete_and_exit(&dev->thread.exit, 0); return 0; } @@ -1019,6 +1025,7 @@ int saa7134_tvaudio_getstereo(struct saa7134_dev *dev) int saa7134_tvaudio_init2(struct saa7134_dev *dev) { + DECLARE_MUTEX_LOCKED(sem); int (*my_thread)(void *data) = NULL; switch (dev->pci->device) { @@ -1031,15 +1038,15 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev) break; } - dev->thread.thread = NULL; + dev->thread.pid = -1; if (my_thread) { /* start tvaudio thread */ - dev->thread.thread = kthread_run(my_thread, dev, "%s", dev->name); - if (IS_ERR(dev->thread.thread)) { + init_waitqueue_head(&dev->thread.wq); + init_completion(&dev->thread.exit); + dev->thread.pid = kernel_thread(my_thread,dev,0); + if (dev->thread.pid < 0) printk(KERN_WARNING "%s: kernel_thread() failed\n", dev->name); - /* XXX: missing error handling here */ - } saa7134_tvaudio_do_scan(dev); } @@ -1050,9 +1057,11 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev) int saa7134_tvaudio_fini(struct saa7134_dev *dev) { /* shutdown tvaudio thread */ - if (dev->thread.thread) - kthread_stop(dev->thread.thread); - + if (dev->thread.pid >= 0) { + dev->thread.shutdown = 1; + wake_up_interruptible(&dev->thread.wq); + wait_for_completion(&dev->thread.exit); + } saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x07, 0x00); /* LINE1 */ return 0; } @@ -1063,10 +1072,10 @@ int saa7134_tvaudio_do_scan(struct saa7134_dev *dev) dprintk("sound IF not in use, skipping scan\n"); dev->automute = 0; saa7134_tvaudio_setmute(dev); - } else if (dev->thread.thread) { + } else if (dev->thread.pid >= 0) { dev->thread.mode = UNSET; dev->thread.scan2++; - wake_up_process(dev->thread.thread); + wake_up_interruptible(&dev->thread.wq); } else { dev->automute = 0; saa7134_tvaudio_setmute(dev); @@ -1083,3 +1092,4 @@ EXPORT_SYMBOL(saa7134_tvaudio_setmute); * c-basic-offset: 8 * End: */ + diff --git a/linux/drivers/media/video/saa7134/saa7134.h b/linux/drivers/media/video/saa7134/saa7134.h index f1b4de448..d6f4bd0b4 100644 --- a/linux/drivers/media/video/saa7134/saa7134.h +++ b/linux/drivers/media/video/saa7134/saa7134.h @@ -335,7 +335,10 @@ struct saa7134_pgtable { /* tvaudio thread status */ struct saa7134_thread { - struct task_struct *thread; + pid_t pid; + struct completion exit; + wait_queue_head_t wq; + unsigned int shutdown; unsigned int scan1; unsigned int scan2; unsigned int mode; |