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

« back to all changes in this revision

Viewing changes to arch/xtensa/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:
17
17
#error "Please don't include <asm/rwsem.h> directly, use <linux/rwsem.h> instead."
18
18
#endif
19
19
 
20
 
#include <linux/list.h>
21
 
#include <linux/spinlock.h>
22
 
#include <asm/atomic.h>
23
 
#include <asm/system.h>
24
 
 
25
 
/*
26
 
 * the semaphore definition
27
 
 */
28
 
struct rw_semaphore {
29
 
        signed long             count;
30
20
#define RWSEM_UNLOCKED_VALUE            0x00000000
31
21
#define RWSEM_ACTIVE_BIAS               0x00000001
32
22
#define RWSEM_ACTIVE_MASK               0x0000ffff
33
23
#define RWSEM_WAITING_BIAS              (-0x00010000)
34
24
#define RWSEM_ACTIVE_READ_BIAS          RWSEM_ACTIVE_BIAS
35
25
#define RWSEM_ACTIVE_WRITE_BIAS         (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS)
36
 
        spinlock_t              wait_lock;
37
 
        struct list_head        wait_list;
38
 
};
39
 
 
40
 
#define __RWSEM_INITIALIZER(name) \
41
 
        { RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, \
42
 
          LIST_HEAD_INIT((name).wait_list) }
43
 
 
44
 
#define DECLARE_RWSEM(name)             \
45
 
        struct rw_semaphore name = __RWSEM_INITIALIZER(name)
46
 
 
47
 
extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem);
48
 
extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem);
49
 
extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem);
50
 
extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
51
 
 
52
 
static inline void init_rwsem(struct rw_semaphore *sem)
53
 
{
54
 
        sem->count = RWSEM_UNLOCKED_VALUE;
55
 
        spin_lock_init(&sem->wait_lock);
56
 
        INIT_LIST_HEAD(&sem->wait_list);
57
 
}
58
26
 
59
27
/*
60
28
 * lock for reading
160
128
        return atomic_add_return(delta, (atomic_t *)(&sem->count));
161
129
}
162
130
 
163
 
static inline int rwsem_is_locked(struct rw_semaphore *sem)
164
 
{
165
 
        return (sem->count != 0);
166
 
}
167
 
 
168
131
#endif  /* _XTENSA_RWSEM_H */