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

« back to all changes in this revision

Viewing changes to include/linux/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:
11
11
 
12
12
#include <linux/types.h>
13
13
#include <linux/kernel.h>
 
14
#include <linux/list.h>
 
15
#include <linux/spinlock.h>
 
16
 
14
17
#include <asm/system.h>
15
18
#include <asm/atomic.h>
16
19
 
19
22
#ifdef CONFIG_RWSEM_GENERIC_SPINLOCK
20
23
#include <linux/rwsem-spinlock.h> /* use a generic implementation */
21
24
#else
22
 
#include <asm/rwsem.h> /* use an arch-specific implementation */
23
 
#endif
 
25
/* All arch specific implementations share the same struct */
 
26
struct rw_semaphore {
 
27
        long                    count;
 
28
        spinlock_t              wait_lock;
 
29
        struct list_head        wait_list;
 
30
#ifdef CONFIG_DEBUG_LOCK_ALLOC
 
31
        struct lockdep_map      dep_map;
 
32
#endif
 
33
};
 
34
 
 
35
extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem);
 
36
extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem);
 
37
extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *);
 
38
extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
 
39
 
 
40
/* Include the arch specific part */
 
41
#include <asm/rwsem.h>
 
42
 
 
43
/* In all implementations count != 0 means locked */
 
44
static inline int rwsem_is_locked(struct rw_semaphore *sem)
 
45
{
 
46
        return sem->count != 0;
 
47
}
 
48
 
 
49
#endif
 
50
 
 
51
/* Common initializer macros and functions */
 
52
 
 
53
#ifdef CONFIG_DEBUG_LOCK_ALLOC
 
54
# define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname }
 
55
#else
 
56
# define __RWSEM_DEP_MAP_INIT(lockname)
 
57
#endif
 
58
 
 
59
#define __RWSEM_INITIALIZER(name) \
 
60
        { RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED(name.wait_lock),   \
 
61
          LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) }
 
62
 
 
63
#define DECLARE_RWSEM(name) \
 
64
        struct rw_semaphore name = __RWSEM_INITIALIZER(name)
 
65
 
 
66
extern void __init_rwsem(struct rw_semaphore *sem, const char *name,
 
67
                         struct lock_class_key *key);
 
68
 
 
69
#define init_rwsem(sem)                                         \
 
70
do {                                                            \
 
71
        static struct lock_class_key __key;                     \
 
72
                                                                \
 
73
        __init_rwsem((sem), #sem, &__key);                      \
 
74
} while (0)
24
75
 
25
76
/*
26
77
 * lock for reading