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 static inline int waking_non_zero(struct semaphore
*sem
)
25 #ifndef CONFIG_RMW_INSNS
28 spin_lock_irqsave(&semaphore_wake_lock
, flags
);
30 if (atomic_read(&sem
->waking
) > 0) {
31 atomic_dec(&sem
->waking
);
34 spin_unlock_irqrestore(&semaphore_wake_lock
, flags
);
46 : "=d" (ret
), "=d" (tmp1
), "=d" (tmp2
)
47 : "m" (sem
->waking
), "0" (0), "1" (sem
->waking
));
54 * waking_non_zero_interruptible:
59 static inline int waking_non_zero_interruptible(struct semaphore
*sem
,
60 struct task_struct
*tsk
)
63 #ifndef CONFIG_RMW_INSNS
66 spin_lock_irqsave(&semaphore_wake_lock
, flags
);
68 if (atomic_read(&sem
->waking
) > 0) {
69 atomic_dec(&sem
->waking
);
71 } else if (signal_pending(tsk
)) {
72 atomic_inc(&sem
->count
);
75 spin_unlock_irqrestore(&semaphore_wake_lock
, flags
);
88 : "=d" (ret
), "=d" (tmp1
), "=d" (tmp2
)
89 : "m" (sem
->waking
), "i" (&&next
), "0" (0), "1" (sem
->waking
));
90 if (signal_pending(tsk
)) {
91 atomic_inc(&sem
->count
);
101 * waking_non_zero_trylock:
105 static inline int waking_non_zero_trylock(struct semaphore
*sem
)
108 #ifndef CONFIG_RMW_INSNS
111 spin_lock_irqsave(&semaphore_wake_lock
, flags
);
113 if (atomic_read(&sem
->waking
) > 0) {
114 atomic_dec(&sem
->waking
);
117 atomic_inc(&sem
->count
);
118 spin_unlock_irqrestore(&semaphore_wake_lock
, flags
);
130 : "=d" (ret
), "=d" (tmp1
), "=d" (tmp2
)
131 : "m" (sem
->waking
), "0" (1), "1" (sem
->waking
));
133 atomic_inc(&sem
->count
);