1 // SPDX-License-Identifier: GPL-2.0-only
2 #ifndef __LINUX_RWLOCK_RT_H
3 #define __LINUX_RWLOCK_RT_H
5 #ifndef __LINUX_SPINLOCK_RT_H
6 #error Do not #include directly. Use <linux/spinlock.h>.
9 #ifdef CONFIG_DEBUG_LOCK_ALLOC
10 extern void __rt_rwlock_init(rwlock_t
*rwlock
, const char *name
,
11 struct lock_class_key
*key
);
13 static inline void __rt_rwlock_init(rwlock_t
*rwlock
, char *name
,
14 struct lock_class_key
*key
)
19 #define rwlock_init(rwl) \
21 static struct lock_class_key __key; \
23 init_rwbase_rt(&(rwl)->rwbase); \
24 __rt_rwlock_init(rwl, #rwl, &__key); \
27 extern void rt_read_lock(rwlock_t
*rwlock
) __acquires(rwlock
);
28 extern int rt_read_trylock(rwlock_t
*rwlock
);
29 extern void rt_read_unlock(rwlock_t
*rwlock
) __releases(rwlock
);
30 extern void rt_write_lock(rwlock_t
*rwlock
) __acquires(rwlock
);
31 extern void rt_write_lock_nested(rwlock_t
*rwlock
, int subclass
) __acquires(rwlock
);
32 extern int rt_write_trylock(rwlock_t
*rwlock
);
33 extern void rt_write_unlock(rwlock_t
*rwlock
) __releases(rwlock
);
35 static __always_inline
void read_lock(rwlock_t
*rwlock
)
40 static __always_inline
void read_lock_bh(rwlock_t
*rwlock
)
46 static __always_inline
void read_lock_irq(rwlock_t
*rwlock
)
51 #define read_lock_irqsave(lock, flags) \
53 typecheck(unsigned long, flags); \
58 #define read_trylock(lock) __cond_lock(lock, rt_read_trylock(lock))
60 static __always_inline
void read_unlock(rwlock_t
*rwlock
)
62 rt_read_unlock(rwlock
);
65 static __always_inline
void read_unlock_bh(rwlock_t
*rwlock
)
67 rt_read_unlock(rwlock
);
71 static __always_inline
void read_unlock_irq(rwlock_t
*rwlock
)
73 rt_read_unlock(rwlock
);
76 static __always_inline
void read_unlock_irqrestore(rwlock_t
*rwlock
,
79 rt_read_unlock(rwlock
);
82 static __always_inline
void write_lock(rwlock_t
*rwlock
)
84 rt_write_lock(rwlock
);
87 #ifdef CONFIG_DEBUG_LOCK_ALLOC
88 static __always_inline
void write_lock_nested(rwlock_t
*rwlock
, int subclass
)
90 rt_write_lock_nested(rwlock
, subclass
);
93 #define write_lock_nested(lock, subclass) rt_write_lock(((void)(subclass), (lock)))
96 static __always_inline
void write_lock_bh(rwlock_t
*rwlock
)
99 rt_write_lock(rwlock
);
102 static __always_inline
void write_lock_irq(rwlock_t
*rwlock
)
104 rt_write_lock(rwlock
);
107 #define write_lock_irqsave(lock, flags) \
109 typecheck(unsigned long, flags); \
110 rt_write_lock(lock); \
114 #define write_trylock(lock) __cond_lock(lock, rt_write_trylock(lock))
116 #define write_trylock_irqsave(lock, flags) \
120 typecheck(unsigned long, flags); \
122 __locked = write_trylock(lock); \
126 static __always_inline
void write_unlock(rwlock_t
*rwlock
)
128 rt_write_unlock(rwlock
);
131 static __always_inline
void write_unlock_bh(rwlock_t
*rwlock
)
133 rt_write_unlock(rwlock
);
137 static __always_inline
void write_unlock_irq(rwlock_t
*rwlock
)
139 rt_write_unlock(rwlock
);
142 static __always_inline
void write_unlock_irqrestore(rwlock_t
*rwlock
,
145 rt_write_unlock(rwlock
);
148 #define rwlock_is_contended(lock) (((void)(lock), 0))
150 #endif /* __LINUX_RWLOCK_RT_H */