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
14 * These two _must_ execute atomically wrt each other.
16 static inline void wake_one_more(struct semaphore
* sem
)
18 atomic_inc(&sem
->waking
);
21 static inline int waking_non_zero(struct semaphore
*sem
)
26 spin_lock_irqsave(&semaphore_wake_lock
, flags
);
28 if (atomic_read(&sem
->waking
) > 0) {
29 atomic_dec(&sem
->waking
);
32 spin_unlock_irqrestore(&semaphore_wake_lock
, flags
);
37 * waking_non_zero_interruptible:
42 static inline int waking_non_zero_interruptible(struct semaphore
*sem
,
43 struct task_struct
*tsk
)
48 spin_lock_irqsave(&semaphore_wake_lock
, flags
);
50 if (atomic_read(&sem
->waking
) > 0) {
51 atomic_dec(&sem
->waking
);
53 } else if (signal_pending(tsk
)) {
54 atomic_inc(&sem
->count
);
57 spin_unlock_irqrestore(&semaphore_wake_lock
, flags
);
62 * waking_non_zero_trylock:
66 static inline int waking_non_zero_trylock(struct semaphore
*sem
)
71 spin_lock_irqsave(&semaphore_wake_lock
, flags
);
73 if (atomic_read(&sem
->waking
) > 0) {
74 atomic_dec(&sem
->waking
);
77 atomic_inc(&sem
->count
);
78 spin_unlock_irqrestore(&semaphore_wake_lock
, flags
);