[PATCH] smc ethernet: fix section mismatch warnings
[linux-2.6/mini2440.git] / include / asm-m68knommu / semaphore-helper.h
bloba6586417c1c2144c3231868e9d0d1b83e4254c60
1 #ifndef _M68K_SEMAPHORE_HELPER_H
2 #define _M68K_SEMAPHORE_HELPER_H
4 /*
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)
24 int ret;
25 unsigned long flags;
27 spin_lock_irqsave(&semaphore_wake_lock, flags);
28 ret = 0;
29 if (atomic_read(&sem->waking) > 0) {
30 atomic_dec(&sem->waking);
31 ret = 1;
33 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
34 return ret;
38 * waking_non_zero_interruptible:
39 * 1 got the lock
40 * 0 go to sleep
41 * -EINTR interrupted
43 static inline int waking_non_zero_interruptible(struct semaphore *sem,
44 struct task_struct *tsk)
46 int ret;
47 unsigned long flags;
49 spin_lock_irqsave(&semaphore_wake_lock, flags);
50 ret = 0;
51 if (atomic_read(&sem->waking) > 0) {
52 atomic_dec(&sem->waking);
53 ret = 1;
54 } else if (signal_pending(tsk)) {
55 atomic_inc(&sem->count);
56 ret = -EINTR;
58 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
59 return ret;
63 * waking_non_zero_trylock:
64 * 1 failed to lock
65 * 0 got the lock
67 static inline int waking_non_zero_trylock(struct semaphore *sem)
69 int ret;
70 unsigned long flags;
72 spin_lock_irqsave(&semaphore_wake_lock, flags);
73 ret = 1;
74 if (atomic_read(&sem->waking) > 0) {
75 atomic_dec(&sem->waking);
76 ret = 0;
77 } else
78 atomic_inc(&sem->count);
79 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
80 return ret;
83 #endif