summaryrefslogtreecommitdiff
blob: 5b9150bdeece10b0b5f85def74fe30b3904d9946 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#bug 200508

--- /var/tmp/portage/app-misc/lirc-0.8.3_pre1/work/lirc-0.8.3pre1/drivers/lirc_dev/lirc_dev.c	2007-09-27 15:47:20.000000000 -0400
+++ lirc-0.8.3pre1/drivers/lirc_dev/lirc_dev.c	2007-11-27 11:06:41.000000000 -0500
@@ -41,6 +41,7 @@
 #include <linux/fs.h>
 #include <linux/poll.h>
 #include <linux/smp_lock.h>
+#include <linux/completion.h>
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)
 #include <linux/uaccess.h>
 #include <linux/errno.h>
@@ -86,8 +87,8 @@
 	struct lirc_buffer *buf;
 
 	int tpid;
-	struct semaphore *t_notify;
-	struct semaphore *t_notify2;
+	struct completion *t_notify;
+	struct completion *t_notify2;
 	int shutdown;
 	long jiffies_to_wait;
 
@@ -193,7 +194,7 @@
 	daemonize("lirc_dev");
 
 	if (ir->t_notify != NULL)
-		up(ir->t_notify);
+		complete(ir->t_notify);
 
 	dprintk(LOGHEAD "poll thread started\n", ir->p.name, ir->p.minor);
 
@@ -218,11 +219,11 @@
 	} while (!ir->shutdown);
 
 	if (ir->t_notify2 != NULL)
-		down(ir->t_notify2);
+		wait_for_completion(ir->t_notify2);
 
 	ir->tpid = -1;
 	if (ir->t_notify != NULL)
-		up(ir->t_notify);
+		complete(ir->t_notify);
 
 	dprintk(LOGHEAD "poll thread ended\n", ir->p.name, ir->p.minor);
 
@@ -238,7 +239,7 @@
 #ifdef LIRC_HAVE_DEVFS_24
 	char name[16];
 #endif
-	DECLARE_MUTEX_LOCKED(tn);
+	DECLARE_COMPLETION(tn);
 
 	if (!p) {
 		printk(KERN_ERR "lirc_dev: lirc_register_plugin: "
@@ -389,7 +390,7 @@
 			err = -ECHILD;
 			goto out_sysfs;
 		}
-		down(&tn);
+		wait_for_completion(&tn);
 		ir->t_notify = NULL;
 	}
 	ir->attached = 1;
@@ -425,8 +426,8 @@
 int lirc_unregister_plugin(int minor)
 {
 	struct irctl *ir;
-	DECLARE_MUTEX_LOCKED(tn);
-	DECLARE_MUTEX_LOCKED(tn2);
+	DECLARE_COMPLETION(tn);
+	DECLARE_COMPLETION(tn2);
 
 	if (minor < 0 || minor >= MAX_IRCTL_DEVICES) {
 		printk(KERN_ERR "lirc_dev: lirc_unregister_plugin: "
@@ -462,8 +463,8 @@
 		/* 2.2.x does not export wake_up_process() */
 		wake_up_interruptible(ir->p.get_queue(ir->p.data));
 #endif
-		up(&tn2);
-		down(&tn);
+		complete(&tn2);
+		wait_for_completion(&tn);
 		ir->t_notify = NULL;
 		ir->t_notify2 = NULL;
 	}