aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k
diff options
context:
space:
mode:
Diffstat (limited to 'arch/m68k')
-rw-r--r--arch/m68k/kernel/Makefile2
-rw-r--r--arch/m68k/kernel/m68k_ksyms.c6
-rw-r--r--arch/m68k/kernel/semaphore.c132
-rw-r--r--arch/m68k/lib/Makefile2
-rw-r--r--arch/m68k/lib/semaphore.S53
5 files changed, 2 insertions, 193 deletions
diff --git a/arch/m68k/kernel/Makefile b/arch/m68k/kernel/Makefile
index a806208c7fb5..7a62a718143b 100644
--- a/arch/m68k/kernel/Makefile
+++ b/arch/m68k/kernel/Makefile
@@ -10,7 +10,7 @@ endif
10extra-y += vmlinux.lds 10extra-y += vmlinux.lds
11 11
12obj-y := entry.o process.o traps.o ints.o signal.o ptrace.o module.o \ 12obj-y := entry.o process.o traps.o ints.o signal.o ptrace.o module.o \
13 sys_m68k.o time.o semaphore.o setup.o m68k_ksyms.o devres.o 13 sys_m68k.o time.o setup.o m68k_ksyms.o devres.o
14 14
15devres-y = ../../../kernel/irq/devres.o 15devres-y = ../../../kernel/irq/devres.o
16 16
diff --git a/arch/m68k/kernel/m68k_ksyms.c b/arch/m68k/kernel/m68k_ksyms.c
index 6fc69c74fe2e..d900e77e5363 100644
--- a/arch/m68k/kernel/m68k_ksyms.c
+++ b/arch/m68k/kernel/m68k_ksyms.c
@@ -1,5 +1,4 @@
1#include <linux/module.h> 1#include <linux/module.h>
2#include <asm/semaphore.h>
3 2
4asmlinkage long long __ashldi3 (long long, int); 3asmlinkage long long __ashldi3 (long long, int);
5asmlinkage long long __ashrdi3 (long long, int); 4asmlinkage long long __ashrdi3 (long long, int);
@@ -15,8 +14,3 @@ EXPORT_SYMBOL(__ashrdi3);
15EXPORT_SYMBOL(__lshrdi3); 14EXPORT_SYMBOL(__lshrdi3);
16EXPORT_SYMBOL(__muldi3); 15EXPORT_SYMBOL(__muldi3);
17 16
18EXPORT_SYMBOL(__down_failed);
19EXPORT_SYMBOL(__down_failed_interruptible);
20EXPORT_SYMBOL(__down_failed_trylock);
21EXPORT_SYMBOL(__up_wakeup);
22
diff --git a/arch/m68k/kernel/semaphore.c b/arch/m68k/kernel/semaphore.c
deleted file mode 100644
index d12cbbfe6ebd..000000000000
--- a/arch/m68k/kernel/semaphore.c
+++ /dev/null
@@ -1,132 +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 <linux/init.h>
8#include <asm/semaphore-helper.h>
9
10#ifndef CONFIG_RMW_INSNS
11spinlock_t semaphore_wake_lock;
12#endif
13
14/*
15 * Semaphores are implemented using a two-way counter:
16 * The "count" variable is decremented for each process
17 * that tries to sleep, while the "waking" variable is
18 * incremented when the "up()" code goes to wake up waiting
19 * processes.
20 *
21 * Notably, the inline "up()" and "down()" functions can
22 * efficiently test if they need to do any extra work (up
23 * needs to do something only if count was negative before
24 * the increment operation.
25 *
26 * waking_non_zero() (from asm/semaphore.h) must execute
27 * atomically.
28 *
29 * When __up() is called, the count was negative before
30 * incrementing it, and we need to wake up somebody.
31 *
32 * This routine adds one to the count of processes that need to
33 * wake up and exit. ALL waiting processes actually wake up but
34 * only the one that gets to the "waking" field first will gate
35 * through and acquire the semaphore. The others will go back
36 * to sleep.
37 *
38 * Note that these functions are only called when there is
39 * contention on the lock, and as such all this is the
40 * "non-critical" part of the whole semaphore business. The
41 * critical part is the inline stuff in <asm/semaphore.h>
42 * where we want to avoid any extra jumps and calls.
43 */
44void __up(struct semaphore *sem)
45{
46 wake_one_more(sem);
47 wake_up(&sem->wait);
48}
49
50/*
51 * Perform the "down" function. Return zero for semaphore acquired,
52 * return negative for signalled out of the function.
53 *
54 * If called from __down, the return is ignored and the wait loop is
55 * not interruptible. This means that a task waiting on a semaphore
56 * using "down()" cannot be killed until someone does an "up()" on
57 * the semaphore.
58 *
59 * If called from __down_interruptible, the return value gets checked
60 * upon return. If the return value is negative then the task continues
61 * with the negative value in the return register (it can be tested by
62 * the caller).
63 *
64 * Either form may be used in conjunction with "up()".
65 *
66 */
67
68
69#define DOWN_HEAD(task_state) \
70 \
71 \
72 current->state = (task_state); \
73 add_wait_queue(&sem->wait, &wait); \
74 \
75 /* \
76 * Ok, we're set up. sem->count is known to be less than zero \
77 * so we must wait. \
78 * \
79 * We can let go the lock for purposes of waiting. \
80 * We re-acquire it after awaking so as to protect \
81 * all semaphore operations. \
82 * \
83 * If "up()" is called before we call waking_non_zero() then \
84 * we will catch it right away. If it is called later then \
85 * we will have to go through a wakeup cycle to catch it. \
86 * \
87 * Multiple waiters contend for the semaphore lock to see \
88 * who gets to gate through and who has to wait some more. \
89 */ \
90 for (;;) {
91
92#define DOWN_TAIL(task_state) \
93 current->state = (task_state); \
94 } \
95 current->state = TASK_RUNNING; \
96 remove_wait_queue(&sem->wait, &wait);
97
98void __sched __down(struct semaphore * sem)
99{
100 DECLARE_WAITQUEUE(wait, current);
101
102 DOWN_HEAD(TASK_UNINTERRUPTIBLE)
103 if (waking_non_zero(sem))
104 break;
105 schedule();
106 DOWN_TAIL(TASK_UNINTERRUPTIBLE)
107}
108
109int __sched __down_interruptible(struct semaphore * sem)
110{
111 DECLARE_WAITQUEUE(wait, current);
112 int ret = 0;
113
114 DOWN_HEAD(TASK_INTERRUPTIBLE)
115
116 ret = waking_non_zero_interruptible(sem, current);
117 if (ret)
118 {
119 if (ret == 1)
120 /* ret != 0 only if we get interrupted -arca */
121 ret = 0;
122 break;
123 }
124 schedule();
125 DOWN_TAIL(TASK_INTERRUPTIBLE)
126 return ret;
127}
128
129int __down_trylock(struct semaphore * sem)
130{
131 return waking_non_zero_trylock(sem);
132}
diff --git a/arch/m68k/lib/Makefile b/arch/m68k/lib/Makefile
index 6bbf19f96007..a18af095cd7c 100644
--- a/arch/m68k/lib/Makefile
+++ b/arch/m68k/lib/Makefile
@@ -5,4 +5,4 @@
5EXTRA_AFLAGS := -traditional 5EXTRA_AFLAGS := -traditional
6 6
7lib-y := ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \ 7lib-y := ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \
8 checksum.o string.o semaphore.o uaccess.o 8 checksum.o string.o uaccess.o
diff --git a/arch/m68k/lib/semaphore.S b/arch/m68k/lib/semaphore.S
deleted file mode 100644
index 0215624c1602..000000000000
--- a/arch/m68k/lib/semaphore.S
+++ /dev/null
@@ -1,53 +0,0 @@
1/*
2 * linux/arch/m68k/lib/semaphore.S
3 *
4 * Copyright (C) 1996 Linus Torvalds
5 *
6 * m68k version by Andreas Schwab
7 */
8
9#include <linux/linkage.h>
10#include <asm/semaphore.h>
11
12/*
13 * The semaphore operations have a special calling sequence that
14 * allow us to do a simpler in-line version of them. These routines
15 * need to convert that sequence back into the C sequence when
16 * there is contention on the semaphore.
17 */
18ENTRY(__down_failed)
19 moveml %a0/%d0/%d1,-(%sp)
20 movel %a1,-(%sp)
21 jbsr __down
22 movel (%sp)+,%a1
23 moveml (%sp)+,%a0/%d0/%d1
24 rts
25
26ENTRY(__down_failed_interruptible)
27 movel %a0,-(%sp)
28 movel %d1,-(%sp)
29 movel %a1,-(%sp)
30 jbsr __down_interruptible
31 movel (%sp)+,%a1
32 movel (%sp)+,%d1
33 movel (%sp)+,%a0
34 rts
35
36ENTRY(__down_failed_trylock)
37 movel %a0,-(%sp)
38 movel %d1,-(%sp)
39 movel %a1,-(%sp)
40 jbsr __down_trylock
41 movel (%sp)+,%a1
42 movel (%sp)+,%d1
43 movel (%sp)+,%a0
44 rts
45
46ENTRY(__up_wakeup)
47 moveml %a0/%d0/%d1,-(%sp)
48 movel %a1,-(%sp)
49 jbsr __up
50 movel (%sp)+,%a1
51 moveml (%sp)+,%a0/%d0/%d1
52 rts
53