1 #ifndef _M68K_SEMAPHORE_HELPER_H
2 #define _M68K_SEMAPHORE_HELPER_H
5 * SMP- and interrupt-safe semaphores helper functions.
7 * (C) Copyright 1996 Linus Torvalds
9 * m68k version by Andreas Schwab
12 #include <linux/config.h>
15 * These two _must_ execute atomically wrt each other.
17 static inline void wake_one_more(struct semaphore
* sem
)
19 atomic_inc(&sem
->waking
);
22 #ifndef CONFIG_RMW_INSNS
23 extern spinlock_t semaphore_wake_lock
;
26 static inline int waking_non_zero(struct semaphore
*sem
)
29 #ifndef CONFIG_RMW_INSNS
32 spin_lock_irqsave(&semaphore_wake_lock
, flags
);
34 if (atomic_read(&sem
->waking
) > 0) {
35 atomic_dec(&sem
->waking
);
38 spin_unlock_irqrestore(&semaphore_wake_lock
, flags
);
50 : "=d" (ret
), "=d" (tmp1
), "=d" (tmp2
)
51 : "m" (sem
->waking
), "0" (0), "1" (sem
->waking
));
58 * waking_non_zero_interruptible:
63 static inline int waking_non_zero_interruptible(struct semaphore
*sem
,
64 struct task_struct
*tsk
)
67 #ifndef CONFIG_RMW_INSNS
70 spin_lock_irqsave(&semaphore_wake_lock
, flags
);
72 if (atomic_read(&sem
->waking
) > 0) {
73 atomic_dec(&sem
->waking
);
75 } else if (signal_pending(tsk
)) {
76 atomic_inc(&sem
->count
);
79 spin_unlock_irqrestore(&semaphore_wake_lock
, flags
);
92 : "=d" (ret
), "=d" (tmp1
), "=d" (tmp2
)
93 : "m" (sem
->waking
), "i" (&&next
), "0" (0), "1" (sem
->waking
));
94 if (signal_pending(tsk
)) {
95 atomic_inc(&sem
->count
);
105 * waking_non_zero_trylock:
109 static inline int waking_non_zero_trylock(struct semaphore
*sem
)
112 #ifndef CONFIG_RMW_INSNS
115 spin_lock_irqsave(&semaphore_wake_lock
, flags
);
117 if (atomic_read(&sem
->waking
) > 0) {
118 atomic_dec(&sem
->waking
);
121 atomic_inc(&sem
->count
);
122 spin_unlock_irqrestore(&semaphore_wake_lock
, flags
);
134 : "=d" (ret
), "=d" (tmp1
), "=d" (tmp2
)
135 : "m" (sem
->waking
), "0" (1), "1" (sem
->waking
));
137 atomic_inc(&sem
->count
);