1 #ifndef _H8300_SEMAPHORE_HELPER_H
2 #define _H8300_SEMAPHORE_HELPER_H
5 * SMP- and interrupt-safe semaphores helper functions.
7 * (C) Copyright 1996 Linus Torvalds
10 * m68k version by Andreas Schwab
13 #include <linux/errno.h>
16 * These two _must_ execute atomically wrt each other.
18 static inline void wake_one_more(struct semaphore
* sem
)
20 atomic_inc((atomic_t
*)&sem
->sleepers
);
23 static inline int waking_non_zero(struct semaphore
*sem
)
28 spin_lock_irqsave(&semaphore_wake_lock
, flags
);
30 if (sem
->sleepers
> 0) {
34 spin_unlock_irqrestore(&semaphore_wake_lock
, flags
);
39 * waking_non_zero_interruptible:
44 static inline int waking_non_zero_interruptible(struct semaphore
*sem
,
45 struct task_struct
*tsk
)
50 spin_lock_irqsave(&semaphore_wake_lock
, flags
);
52 if (sem
->sleepers
> 0) {
55 } else if (signal_pending(tsk
)) {
56 atomic_inc(&sem
->count
);
59 spin_unlock_irqrestore(&semaphore_wake_lock
, flags
);
64 * waking_non_zero_trylock:
68 static inline int waking_non_zero_trylock(struct semaphore
*sem
)
73 spin_lock_irqsave(&semaphore_wake_lock
, flags
);
75 if (sem
->sleepers
<= 0)
76 atomic_inc(&sem
->count
);
81 spin_unlock_irqrestore(&semaphore_wake_lock
, flags
);