summaryrefslogtreecommitdiff
path: root/recipes/linux/openzaurus-pxa-2.4.18-rmk7-pxa3-embedix20031107/fix_tosa_apm.patch
blob: 092b0dcf49e40e36b861a1cabbf827cd7ce71a8c (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

#
# Patch managed by http://www.holgerschurig.de/patcher.html
#

--- linux/arch/arm/mach-pxa/sharpsl_apm.c~fix_tosa_apm.patch
+++ linux/arch/arm/mach-pxa/sharpsl_apm.c
@@ -254,6 +254,8 @@
 	int		magic;
 	struct apm_user *	next;
 	int		suser: 1;
+        int             reader: 1;
+        int             writer: 1;
 	int		suspend_wait: 1;
 	int		suspend_result;
 	int		suspends_pending;
@@ -1596,12 +1598,12 @@
 {
 	struct apm_user *	as;
 
-	DPRINTK("event=%d\n",event);
+	DPRINTK("event=%d, sender=%p\n",event,sender);
 
 	if (user_list == NULL)
 		return;
 	for (as = user_list; as != NULL; as = as->next) {
-		if (as == sender)
+		if ((as == sender) || (!as->reader))
 			continue;
 		as->event_head = (as->event_head + 1) % APM_MAX_EVENTS;
 		if (as->event_head == as->event_tail) {
@@ -1611,8 +1613,8 @@
 			as->event_tail = (as->event_tail + 1) % APM_MAX_EVENTS;
 		}
 		as->events[as->event_head] = event;
-		if (!as->suser)
-			continue;
+                if ((!as->suser) || (!as->writer))
+                        continue;
 		switch (event) {
 		case APM_SYS_SUSPEND:
 		case APM_USER_SUSPEND:
@@ -1630,9 +1632,8 @@
 #ifdef SHARPSL_NEW_IDLE
 	current->nice = save_nice;
 	current->counter = save_counter;
-#else
-	wake_up_interruptible(&apm_waitqueue);
 #endif
+	wake_up_interruptible(&apm_waitqueue);
 }
 
 static unsigned long get_cmos_time(void)
@@ -2532,6 +2533,8 @@
 	 * privileged operation -- cevans
 	 */
 	as->suser = capable(CAP_SYS_ADMIN);
+        as->writer = (filp->f_mode & FMODE_WRITE) == FMODE_WRITE;
+        as->reader = (filp->f_mode & FMODE_READ) == FMODE_READ;
 	as->next = user_list;
 	user_list = as;
 	filp->private_data = as;
@@ -3000,6 +3003,9 @@
 #endif
 #endif
 
+        suspends_pending = 0;
+        standbys_pending = 0;
+
 	apm_proc = create_proc_info_entry("apm", 0, NULL, apm_get_info);
 	if (apm_proc)
 		SET_MODULE_OWNER(apm_proc);