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
)
27 spin_lock_irqsave(&semaphore_wake_lock
, flags
);
29 if (atomic_read(&sem
->waking
) > 0) {
30 atomic_dec(&sem
->waking
);
33 spin_unlock_irqrestore(&semaphore_wake_lock
, flags
);
38 * waking_non_zero_interruptible:
43 static inline int waking_non_zero_interruptible(struct semaphore
*sem
,
44 struct task_struct
*tsk
)
49 spin_lock_irqsave(&semaphore_wake_lock
, flags
);
51 if (atomic_read(&sem
->waking
) > 0) {
52 atomic_dec(&sem
->waking
);
54 } else if (signal_pending(tsk
)) {
55 atomic_inc(&sem
->count
);
58 spin_unlock_irqrestore(&semaphore_wake_lock
, flags
);
63 * waking_non_zero_trylock:
67 static inline int waking_non_zero_trylock(struct semaphore
*sem
)
72 spin_lock_irqsave(&semaphore_wake_lock
, flags
);
74 if (atomic_read(&sem
->waking
) > 0) {
75 atomic_dec(&sem
->waking
);
78 atomic_inc(&sem
->count
);
79 spin_unlock_irqrestore(&semaphore_wake_lock
, flags
);