~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to arch/powerpc/include/asm/rwsem.h

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 * by Paul Mackerras <paulus@samba.org>.
14
14
 */
15
15
 
16
 
#include <linux/list.h>
17
 
#include <linux/spinlock.h>
18
 
#include <asm/atomic.h>
19
 
#include <asm/system.h>
20
 
 
21
16
/*
22
17
 * the semaphore definition
23
18
 */
33
28
#define RWSEM_ACTIVE_READ_BIAS          RWSEM_ACTIVE_BIAS
34
29
#define RWSEM_ACTIVE_WRITE_BIAS         (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS)
35
30
 
36
 
struct rw_semaphore {
37
 
        long                    count;
38
 
        spinlock_t              wait_lock;
39
 
        struct list_head        wait_list;
40
 
#ifdef CONFIG_DEBUG_LOCK_ALLOC
41
 
        struct lockdep_map      dep_map;
42
 
#endif
43
 
};
44
 
 
45
 
#ifdef CONFIG_DEBUG_LOCK_ALLOC
46
 
# define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname }
47
 
#else
48
 
# define __RWSEM_DEP_MAP_INIT(lockname)
49
 
#endif
50
 
 
51
 
#define __RWSEM_INITIALIZER(name)                               \
52
 
{                                                               \
53
 
        RWSEM_UNLOCKED_VALUE,                                   \
54
 
        __SPIN_LOCK_UNLOCKED((name).wait_lock),                 \
55
 
        LIST_HEAD_INIT((name).wait_list)                        \
56
 
        __RWSEM_DEP_MAP_INIT(name)                              \
57
 
}
58
 
 
59
 
#define DECLARE_RWSEM(name)             \
60
 
        struct rw_semaphore name = __RWSEM_INITIALIZER(name)
61
 
 
62
 
extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem);
63
 
extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem);
64
 
extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem);
65
 
extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
66
 
 
67
 
extern void __init_rwsem(struct rw_semaphore *sem, const char *name,
68
 
                         struct lock_class_key *key);
69
 
 
70
 
#define init_rwsem(sem)                                 \
71
 
        do {                                            \
72
 
                static struct lock_class_key __key;     \
73
 
                                                        \
74
 
                __init_rwsem((sem), #sem, &__key);      \
75
 
        } while (0)
76
 
 
77
31
/*
78
32
 * lock for reading
79
33
 */
174
128
        return atomic_long_add_return(delta, (atomic_long_t *)&sem->count);
175
129
}
176
130
 
177
 
static inline int rwsem_is_locked(struct rw_semaphore *sem)
178
 
{
179
 
        return sem->count != 0;
180
 
}
181
 
 
182
131
#endif  /* __KERNEL__ */
183
132
#endif  /* _ASM_POWERPC_RWSEM_H */