diff options
Diffstat (limited to 'include/asm-sparc/rwsem.h')
-rw-r--r-- | include/asm-sparc/rwsem.h | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/include/asm-sparc/rwsem.h b/include/asm-sparc/rwsem.h deleted file mode 100644 index 1dc129ac2feb..000000000000 --- a/include/asm-sparc/rwsem.h +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | /* | ||
2 | * rwsem.h: R/W semaphores implemented using CAS | ||
3 | * | ||
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 | ||
9 | |||
10 | #ifndef _LINUX_RWSEM_H | ||
11 | #error "please don't include asm/rwsem.h directly, use linux/rwsem.h instead" | ||
12 | #endif | ||
13 | |||
14 | #ifdef __KERNEL__ | ||
15 | |||
16 | #include <linux/list.h> | ||
17 | #include <linux/spinlock.h> | ||
18 | #include <asm/rwsem-const.h> | ||
19 | |||
20 | struct rwsem_waiter; | ||
21 | |||
22 | struct rw_semaphore { | ||
23 | signed int count; | ||
24 | spinlock_t wait_lock; | ||
25 | struct list_head wait_list; | ||
26 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
27 | struct lockdep_map dep_map; | ||
28 | #endif | ||
29 | }; | ||
30 | |||
31 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
32 | # define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname } | ||
33 | #else | ||
34 | # define __RWSEM_DEP_MAP_INIT(lockname) | ||
35 | #endif | ||
36 | |||
37 | #define __RWSEM_INITIALIZER(name) \ | ||
38 | { RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, LIST_HEAD_INIT((name).wait_list) \ | ||
39 | __RWSEM_DEP_MAP_INIT(name) } | ||
40 | |||
41 | #define DECLARE_RWSEM(name) \ | ||
42 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | ||
43 | |||
44 | extern void __init_rwsem(struct rw_semaphore *sem, const char *name, | ||
45 | struct lock_class_key *key); | ||
46 | |||
47 | #define init_rwsem(sem) \ | ||
48 | do { \ | ||
49 | static struct lock_class_key __key; \ | ||
50 | \ | ||
51 | __init_rwsem((sem), #sem, &__key); \ | ||
52 | } while (0) | ||
53 | |||
54 | extern void __down_read(struct rw_semaphore *sem); | ||
55 | extern int __down_read_trylock(struct rw_semaphore *sem); | ||
56 | extern void __down_write(struct rw_semaphore *sem); | ||
57 | extern int __down_write_trylock(struct rw_semaphore *sem); | ||
58 | extern void __up_read(struct rw_semaphore *sem); | ||
59 | extern void __up_write(struct rw_semaphore *sem); | ||
60 | extern void __downgrade_write(struct rw_semaphore *sem); | ||
61 | |||
62 | static inline void __down_write_nested(struct rw_semaphore *sem, int subclass) | ||
63 | { | ||
64 | __down_write(sem); | ||
65 | } | ||
66 | |||
67 | static inline int rwsem_atomic_update(int delta, struct rw_semaphore *sem) | ||
68 | { | ||
69 | return atomic_add_return(delta, (atomic_t *)(&sem->count)); | ||
70 | } | ||
71 | |||
72 | static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem) | ||
73 | { | ||
74 | atomic_add(delta, (atomic_t *)(&sem->count)); | ||
75 | } | ||
76 | |||
77 | static inline int rwsem_is_locked(struct rw_semaphore *sem) | ||
78 | { | ||
79 | return (sem->count != 0); | ||
80 | } | ||
81 | |||
82 | #endif /* __KERNEL__ */ | ||
83 | |||
84 | #endif /* _SPARC64_RWSEM_H */ | ||