diff options
Diffstat (limited to 'arch/cris')
-rw-r--r-- | arch/cris/kernel/Makefile | 3 | ||||
-rw-r--r-- | arch/cris/kernel/crisksyms.c | 7 | ||||
-rw-r--r-- | arch/cris/kernel/semaphore.c | 129 |
3 files changed, 1 insertions, 138 deletions
diff --git a/arch/cris/kernel/Makefile b/arch/cris/kernel/Makefile index c8e8ea570989..ee7bcd4d20b2 100644 --- a/arch/cris/kernel/Makefile +++ b/arch/cris/kernel/Makefile | |||
@@ -5,8 +5,7 @@ | |||
5 | 5 | ||
6 | extra-y := vmlinux.lds | 6 | extra-y := vmlinux.lds |
7 | 7 | ||
8 | obj-y := process.o traps.o irq.o ptrace.o setup.o \ | 8 | obj-y := process.o traps.o irq.o ptrace.o setup.o time.o sys_cris.o |
9 | time.o sys_cris.o semaphore.o | ||
10 | 9 | ||
11 | obj-$(CONFIG_MODULES) += crisksyms.o | 10 | obj-$(CONFIG_MODULES) += crisksyms.o |
12 | obj-$(CONFIG_MODULES) += module.o | 11 | obj-$(CONFIG_MODULES) += module.o |
diff --git a/arch/cris/kernel/crisksyms.c b/arch/cris/kernel/crisksyms.c index 62f0e752915a..7ac000f6a888 100644 --- a/arch/cris/kernel/crisksyms.c +++ b/arch/cris/kernel/crisksyms.c | |||
@@ -9,7 +9,6 @@ | |||
9 | #include <linux/string.h> | 9 | #include <linux/string.h> |
10 | #include <linux/tty.h> | 10 | #include <linux/tty.h> |
11 | 11 | ||
12 | #include <asm/semaphore.h> | ||
13 | #include <asm/processor.h> | 12 | #include <asm/processor.h> |
14 | #include <asm/uaccess.h> | 13 | #include <asm/uaccess.h> |
15 | #include <asm/checksum.h> | 14 | #include <asm/checksum.h> |
@@ -49,12 +48,6 @@ EXPORT_SYMBOL(__negdi2); | |||
49 | EXPORT_SYMBOL(__ioremap); | 48 | EXPORT_SYMBOL(__ioremap); |
50 | EXPORT_SYMBOL(iounmap); | 49 | EXPORT_SYMBOL(iounmap); |
51 | 50 | ||
52 | /* Semaphore functions */ | ||
53 | EXPORT_SYMBOL(__up); | ||
54 | EXPORT_SYMBOL(__down); | ||
55 | EXPORT_SYMBOL(__down_interruptible); | ||
56 | EXPORT_SYMBOL(__down_trylock); | ||
57 | |||
58 | /* Userspace access functions */ | 51 | /* Userspace access functions */ |
59 | EXPORT_SYMBOL(__copy_user_zeroing); | 52 | EXPORT_SYMBOL(__copy_user_zeroing); |
60 | EXPORT_SYMBOL(__copy_user); | 53 | EXPORT_SYMBOL(__copy_user); |
diff --git a/arch/cris/kernel/semaphore.c b/arch/cris/kernel/semaphore.c deleted file mode 100644 index f137a439041f..000000000000 --- a/arch/cris/kernel/semaphore.c +++ /dev/null | |||
@@ -1,129 +0,0 @@ | |||
1 | /* | ||
2 | * Generic semaphore code. Buyer beware. Do your own | ||
3 | * specific changes in <asm/semaphore-helper.h> | ||
4 | */ | ||
5 | |||
6 | #include <linux/sched.h> | ||
7 | #include <asm/semaphore-helper.h> | ||
8 | |||
9 | /* | ||
10 | * Semaphores are implemented using a two-way counter: | ||
11 | * The "count" variable is decremented for each process | ||
12 | * that tries to sleep, while the "waking" variable is | ||
13 | * incremented when the "up()" code goes to wake up waiting | ||
14 | * processes. | ||
15 | * | ||
16 | * Notably, the inline "up()" and "down()" functions can | ||
17 | * efficiently test if they need to do any extra work (up | ||
18 | * needs to do something only if count was negative before | ||
19 | * the increment operation. | ||
20 | * | ||
21 | * waking_non_zero() (from asm/semaphore.h) must execute | ||
22 | * atomically. | ||
23 | * | ||
24 | * When __up() is called, the count was negative before | ||
25 | * incrementing it, and we need to wake up somebody. | ||
26 | * | ||
27 | * This routine adds one to the count of processes that need to | ||
28 | * wake up and exit. ALL waiting processes actually wake up but | ||
29 | * only the one that gets to the "waking" field first will gate | ||
30 | * through and acquire the semaphore. The others will go back | ||
31 | * to sleep. | ||
32 | * | ||
33 | * Note that these functions are only called when there is | ||
34 | * contention on the lock, and as such all this is the | ||
35 | * "non-critical" part of the whole semaphore business. The | ||
36 | * critical part is the inline stuff in <asm/semaphore.h> | ||
37 | * where we want to avoid any extra jumps and calls. | ||
38 | */ | ||
39 | void __up(struct semaphore *sem) | ||
40 | { | ||
41 | wake_one_more(sem); | ||
42 | wake_up(&sem->wait); | ||
43 | } | ||
44 | |||
45 | /* | ||
46 | * Perform the "down" function. Return zero for semaphore acquired, | ||
47 | * return negative for signalled out of the function. | ||
48 | * | ||
49 | * If called from __down, the return is ignored and the wait loop is | ||
50 | * not interruptible. This means that a task waiting on a semaphore | ||
51 | * using "down()" cannot be killed until someone does an "up()" on | ||
52 | * the semaphore. | ||
53 | * | ||
54 | * If called from __down_interruptible, the return value gets checked | ||
55 | * upon return. If the return value is negative then the task continues | ||
56 | * with the negative value in the return register (it can be tested by | ||
57 | * the caller). | ||
58 | * | ||
59 | * Either form may be used in conjunction with "up()". | ||
60 | * | ||
61 | */ | ||
62 | |||
63 | #define DOWN_VAR \ | ||
64 | struct task_struct *tsk = current; \ | ||
65 | wait_queue_t wait; \ | ||
66 | init_waitqueue_entry(&wait, tsk); | ||
67 | |||
68 | #define DOWN_HEAD(task_state) \ | ||
69 | \ | ||
70 | \ | ||
71 | tsk->state = (task_state); \ | ||
72 | add_wait_queue(&sem->wait, &wait); \ | ||
73 | \ | ||
74 | /* \ | ||
75 | * Ok, we're set up. sem->count is known to be less than zero \ | ||
76 | * so we must wait. \ | ||
77 | * \ | ||
78 | * We can let go the lock for purposes of waiting. \ | ||
79 | * We re-acquire it after awaking so as to protect \ | ||
80 | * all semaphore operations. \ | ||
81 | * \ | ||
82 | * If "up()" is called before we call waking_non_zero() then \ | ||
83 | * we will catch it right away. If it is called later then \ | ||
84 | * we will have to go through a wakeup cycle to catch it. \ | ||
85 | * \ | ||
86 | * Multiple waiters contend for the semaphore lock to see \ | ||
87 | * who gets to gate through and who has to wait some more. \ | ||
88 | */ \ | ||
89 | for (;;) { | ||
90 | |||
91 | #define DOWN_TAIL(task_state) \ | ||
92 | tsk->state = (task_state); \ | ||
93 | } \ | ||
94 | tsk->state = TASK_RUNNING; \ | ||
95 | remove_wait_queue(&sem->wait, &wait); | ||
96 | |||
97 | void __sched __down(struct semaphore * sem) | ||
98 | { | ||
99 | DOWN_VAR | ||
100 | DOWN_HEAD(TASK_UNINTERRUPTIBLE) | ||
101 | if (waking_non_zero(sem)) | ||
102 | break; | ||
103 | schedule(); | ||
104 | DOWN_TAIL(TASK_UNINTERRUPTIBLE) | ||
105 | } | ||
106 | |||
107 | int __sched __down_interruptible(struct semaphore * sem) | ||
108 | { | ||
109 | int ret = 0; | ||
110 | DOWN_VAR | ||
111 | DOWN_HEAD(TASK_INTERRUPTIBLE) | ||
112 | |||
113 | ret = waking_non_zero_interruptible(sem, tsk); | ||
114 | if (ret) | ||
115 | { | ||
116 | if (ret == 1) | ||
117 | /* ret != 0 only if we get interrupted -arca */ | ||
118 | ret = 0; | ||
119 | break; | ||
120 | } | ||
121 | schedule(); | ||
122 | DOWN_TAIL(TASK_INTERRUPTIBLE) | ||
123 | return ret; | ||
124 | } | ||
125 | |||
126 | int __down_trylock(struct semaphore * sem) | ||
127 | { | ||
128 | return waking_non_zero_trylock(sem); | ||
129 | } | ||