[PATCH] bcm43xx: Fix array overrun in bcm43xx_geo_init
[linux-2.6/kmemtrace.git] / include / asm-sparc64 / rwsem.h
blobcef5e8270421beda324419c8210b4ffa3a7e294d
1 /* $Id: rwsem.h,v 1.5 2001/11/18 00:12:56 davem Exp $
2 * rwsem.h: R/W semaphores implemented using CAS
4 * Written by David S. Miller (davem@redhat.com), 2001.
5 * Derived from asm-i386/rwsem.h
6 */
7 #ifndef _SPARC64_RWSEM_H
8 #define _SPARC64_RWSEM_H
10 #ifndef _LINUX_RWSEM_H
11 #error "please don't include asm/rwsem.h directly, use linux/rwsem.h instead"
12 #endif
14 #ifdef __KERNEL__
16 #include <linux/list.h>
17 #include <linux/spinlock.h>
18 #include <asm/rwsem-const.h>
20 struct rwsem_waiter;
22 struct rw_semaphore {
23 signed int count;
24 spinlock_t wait_lock;
25 struct list_head wait_list;
28 #define __RWSEM_INITIALIZER(name) \
29 { RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, LIST_HEAD_INIT((name).wait_list) }
31 #define DECLARE_RWSEM(name) \
32 struct rw_semaphore name = __RWSEM_INITIALIZER(name)
34 static __inline__ void init_rwsem(struct rw_semaphore *sem)
36 sem->count = RWSEM_UNLOCKED_VALUE;
37 spin_lock_init(&sem->wait_lock);
38 INIT_LIST_HEAD(&sem->wait_list);
41 extern void __down_read(struct rw_semaphore *sem);
42 extern int __down_read_trylock(struct rw_semaphore *sem);
43 extern void __down_write(struct rw_semaphore *sem);
44 extern int __down_write_trylock(struct rw_semaphore *sem);
45 extern void __up_read(struct rw_semaphore *sem);
46 extern void __up_write(struct rw_semaphore *sem);
47 extern void __downgrade_write(struct rw_semaphore *sem);
49 static inline int rwsem_atomic_update(int delta, struct rw_semaphore *sem)
51 return atomic_add_return(delta, (atomic_t *)(&sem->count));
54 static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem)
56 atomic_add(delta, (atomic_t *)(&sem->count));
59 static inline int rwsem_is_locked(struct rw_semaphore *sem)
61 return (sem->count != 0);
64 #endif /* __KERNEL__ */
66 #endif /* _SPARC64_RWSEM_H */