diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/saa7134/saa7134-tvaudio.c | 42 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134.h | 5 |
2 files changed, 17 insertions, 30 deletions
diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c index 30395d6b5f14..18b4817b4aac 100644 --- a/drivers/media/video/saa7134/saa7134-tvaudio.c +++ b/drivers/media/video/saa7134/saa7134-tvaudio.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/moduleparam.h> | 26 | #include <linux/moduleparam.h> |
27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
28 | #include <linux/kthread.h> | ||
28 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
29 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
30 | #include <asm/div64.h> | 31 | #include <asm/div64.h> |
@@ -341,10 +342,8 @@ static void tvaudio_setmode(struct saa7134_dev *dev, | |||
341 | 342 | ||
342 | static int tvaudio_sleep(struct saa7134_dev *dev, int timeout) | 343 | static int tvaudio_sleep(struct saa7134_dev *dev, int timeout) |
343 | { | 344 | { |
344 | DECLARE_WAITQUEUE(wait, current); | 345 | if (dev->thread.scan1 == dev->thread.scan2 && |
345 | 346 | !kthread_should_stop()) { | |
346 | add_wait_queue(&dev->thread.wq, &wait); | ||
347 | if (dev->thread.scan1 == dev->thread.scan2 && !dev->thread.shutdown) { | ||
348 | if (timeout < 0) { | 347 | if (timeout < 0) { |
349 | set_current_state(TASK_INTERRUPTIBLE); | 348 | set_current_state(TASK_INTERRUPTIBLE); |
350 | schedule(); | 349 | schedule(); |
@@ -353,7 +352,6 @@ static int tvaudio_sleep(struct saa7134_dev *dev, int timeout) | |||
353 | (msecs_to_jiffies(timeout)); | 352 | (msecs_to_jiffies(timeout)); |
354 | } | 353 | } |
355 | } | 354 | } |
356 | remove_wait_queue(&dev->thread.wq, &wait); | ||
357 | return dev->thread.scan1 != dev->thread.scan2; | 355 | return dev->thread.scan1 != dev->thread.scan2; |
358 | } | 356 | } |
359 | 357 | ||
@@ -505,11 +503,10 @@ static int tvaudio_thread(void *data) | |||
505 | unsigned int i, audio, nscan; | 503 | unsigned int i, audio, nscan; |
506 | int max1,max2,carrier,rx,mode,lastmode,default_carrier; | 504 | int max1,max2,carrier,rx,mode,lastmode,default_carrier; |
507 | 505 | ||
508 | daemonize("%s", dev->name); | ||
509 | allow_signal(SIGTERM); | 506 | allow_signal(SIGTERM); |
510 | for (;;) { | 507 | for (;;) { |
511 | tvaudio_sleep(dev,-1); | 508 | tvaudio_sleep(dev,-1); |
512 | if (dev->thread.shutdown || signal_pending(current)) | 509 | if (kthread_should_stop() || signal_pending(current)) |
513 | goto done; | 510 | goto done; |
514 | 511 | ||
515 | restart: | 512 | restart: |
@@ -618,7 +615,7 @@ static int tvaudio_thread(void *data) | |||
618 | for (;;) { | 615 | for (;;) { |
619 | if (tvaudio_sleep(dev,5000)) | 616 | if (tvaudio_sleep(dev,5000)) |
620 | goto restart; | 617 | goto restart; |
621 | if (dev->thread.shutdown || signal_pending(current)) | 618 | if (kthread_should_stop() || signal_pending(current)) |
622 | break; | 619 | break; |
623 | if (UNSET == dev->thread.mode) { | 620 | if (UNSET == dev->thread.mode) { |
624 | rx = tvaudio_getstereo(dev,&tvaudio[i]); | 621 | rx = tvaudio_getstereo(dev,&tvaudio[i]); |
@@ -634,7 +631,6 @@ static int tvaudio_thread(void *data) | |||
634 | } | 631 | } |
635 | 632 | ||
636 | done: | 633 | done: |
637 | complete_and_exit(&dev->thread.exit, 0); | ||
638 | return 0; | 634 | return 0; |
639 | } | 635 | } |
640 | 636 | ||
@@ -782,7 +778,6 @@ static int tvaudio_thread_ddep(void *data) | |||
782 | struct saa7134_dev *dev = data; | 778 | struct saa7134_dev *dev = data; |
783 | u32 value, norms, clock; | 779 | u32 value, norms, clock; |
784 | 780 | ||
785 | daemonize("%s", dev->name); | ||
786 | allow_signal(SIGTERM); | 781 | allow_signal(SIGTERM); |
787 | 782 | ||
788 | clock = saa7134_boards[dev->board].audio_clock; | 783 | clock = saa7134_boards[dev->board].audio_clock; |
@@ -796,7 +791,7 @@ static int tvaudio_thread_ddep(void *data) | |||
796 | 791 | ||
797 | for (;;) { | 792 | for (;;) { |
798 | tvaudio_sleep(dev,-1); | 793 | tvaudio_sleep(dev,-1); |
799 | if (dev->thread.shutdown || signal_pending(current)) | 794 | if (kthread_should_stop() || signal_pending(current)) |
800 | goto done; | 795 | goto done; |
801 | 796 | ||
802 | restart: | 797 | restart: |
@@ -876,7 +871,6 @@ static int tvaudio_thread_ddep(void *data) | |||
876 | } | 871 | } |
877 | 872 | ||
878 | done: | 873 | done: |
879 | complete_and_exit(&dev->thread.exit, 0); | ||
880 | return 0; | 874 | return 0; |
881 | } | 875 | } |
882 | 876 | ||
@@ -973,7 +967,6 @@ int saa7134_tvaudio_getstereo(struct saa7134_dev *dev) | |||
973 | 967 | ||
974 | int saa7134_tvaudio_init2(struct saa7134_dev *dev) | 968 | int saa7134_tvaudio_init2(struct saa7134_dev *dev) |
975 | { | 969 | { |
976 | DECLARE_MUTEX_LOCKED(sem); | ||
977 | int (*my_thread)(void *data) = NULL; | 970 | int (*my_thread)(void *data) = NULL; |
978 | 971 | ||
979 | switch (dev->pci->device) { | 972 | switch (dev->pci->device) { |
@@ -986,15 +979,15 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev) | |||
986 | break; | 979 | break; |
987 | } | 980 | } |
988 | 981 | ||
989 | dev->thread.pid = -1; | 982 | dev->thread.thread = NULL; |
990 | if (my_thread) { | 983 | if (my_thread) { |
991 | /* start tvaudio thread */ | 984 | /* start tvaudio thread */ |
992 | init_waitqueue_head(&dev->thread.wq); | 985 | dev->thread.thread = kthread_run(my_thread, dev, "%s", dev->name); |
993 | init_completion(&dev->thread.exit); | 986 | if (IS_ERR(dev->thread.thread)) { |
994 | dev->thread.pid = kernel_thread(my_thread,dev,0); | ||
995 | if (dev->thread.pid < 0) | ||
996 | printk(KERN_WARNING "%s: kernel_thread() failed\n", | 987 | printk(KERN_WARNING "%s: kernel_thread() failed\n", |
997 | dev->name); | 988 | dev->name); |
989 | /* XXX: missing error handling here */ | ||
990 | } | ||
998 | saa7134_tvaudio_do_scan(dev); | 991 | saa7134_tvaudio_do_scan(dev); |
999 | } | 992 | } |
1000 | 993 | ||
@@ -1005,11 +998,9 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev) | |||
1005 | int saa7134_tvaudio_fini(struct saa7134_dev *dev) | 998 | int saa7134_tvaudio_fini(struct saa7134_dev *dev) |
1006 | { | 999 | { |
1007 | /* shutdown tvaudio thread */ | 1000 | /* shutdown tvaudio thread */ |
1008 | if (dev->thread.pid > 0) { | 1001 | if (dev->thread.thread) |
1009 | dev->thread.shutdown = 1; | 1002 | kthread_stop(dev->thread.thread); |
1010 | wake_up_interruptible(&dev->thread.wq); | 1003 | |
1011 | wait_for_completion(&dev->thread.exit); | ||
1012 | } | ||
1013 | saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x07, 0x00); /* LINE1 */ | 1004 | saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x07, 0x00); /* LINE1 */ |
1014 | return 0; | 1005 | return 0; |
1015 | } | 1006 | } |
@@ -1020,10 +1011,10 @@ int saa7134_tvaudio_do_scan(struct saa7134_dev *dev) | |||
1020 | dprintk("sound IF not in use, skipping scan\n"); | 1011 | dprintk("sound IF not in use, skipping scan\n"); |
1021 | dev->automute = 0; | 1012 | dev->automute = 0; |
1022 | saa7134_tvaudio_setmute(dev); | 1013 | saa7134_tvaudio_setmute(dev); |
1023 | } else if (dev->thread.pid >= 0) { | 1014 | } else if (dev->thread.thread) { |
1024 | dev->thread.mode = UNSET; | 1015 | dev->thread.mode = UNSET; |
1025 | dev->thread.scan2++; | 1016 | dev->thread.scan2++; |
1026 | wake_up_interruptible(&dev->thread.wq); | 1017 | wake_up_process(dev->thread.thread); |
1027 | } else { | 1018 | } else { |
1028 | dev->automute = 0; | 1019 | dev->automute = 0; |
1029 | saa7134_tvaudio_setmute(dev); | 1020 | saa7134_tvaudio_setmute(dev); |
@@ -1040,4 +1031,3 @@ EXPORT_SYMBOL(saa7134_tvaudio_setmute); | |||
1040 | * c-basic-offset: 8 | 1031 | * c-basic-offset: 8 |
1041 | * End: | 1032 | * End: |
1042 | */ | 1033 | */ |
1043 | |||
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 6389c0e617a4..d32a856192d7 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
@@ -328,10 +328,7 @@ struct saa7134_pgtable { | |||
328 | 328 | ||
329 | /* tvaudio thread status */ | 329 | /* tvaudio thread status */ |
330 | struct saa7134_thread { | 330 | struct saa7134_thread { |
331 | pid_t pid; | 331 | struct task_struct *thread; |
332 | struct completion exit; | ||
333 | wait_queue_head_t wq; | ||
334 | unsigned int shutdown; | ||
335 | unsigned int scan1; | 332 | unsigned int scan1; |
336 | unsigned int scan2; | 333 | unsigned int scan2; |
337 | unsigned int mode; | 334 | unsigned int mode; |