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/config.h>
14 #include <linux/errno.h>
17 * These two _must_ execute atomically wrt each other.
19 static inline void wake_one_more(struct semaphore
* sem
)
21 atomic_inc((atomic_t
*)&sem
->sleepers
);
24 static inline int waking_non_zero(struct semaphore
*sem
)
29 spin_lock_irqsave(&semaphore_wake_lock
, flags
);
31 if (sem
->sleepers
> 0) {
35 spin_unlock_irqrestore(&semaphore_wake_lock
, flags
);
40 * waking_non_zero_interruptible:
45 static inline int waking_non_zero_interruptible(struct semaphore
*sem
,
46 struct task_struct
*tsk
)
51 spin_lock_irqsave(&semaphore_wake_lock
, flags
);
53 if (sem
->sleepers
> 0) {
56 } else if (signal_pending(tsk
)) {
57 atomic_inc(&sem
->count
);
60 spin_unlock_irqrestore(&semaphore_wake_lock
, flags
);
65 * waking_non_zero_trylock:
69 static inline int waking_non_zero_trylock(struct semaphore
*sem
)
74 spin_lock_irqsave(&semaphore_wake_lock
, flags
);
76 if (sem
->sleepers
<= 0)
77 atomic_inc(&sem
->count
);
82 spin_unlock_irqrestore(&semaphore_wake_lock
, flags
);