GNU Linux-libre 5.4.241-gnu1
[releases.git] / include / linux / mmap_lock.h
1 #ifndef _LINUX_MMAP_LOCK_H
2 #define _LINUX_MMAP_LOCK_H
3
4 static inline void mmap_init_lock(struct mm_struct *mm)
5 {
6         init_rwsem(&mm->mmap_sem);
7 }
8
9 static inline void mmap_write_lock(struct mm_struct *mm)
10 {
11         down_write(&mm->mmap_sem);
12 }
13
14 static inline int mmap_write_lock_killable(struct mm_struct *mm)
15 {
16         return down_write_killable(&mm->mmap_sem);
17 }
18
19 static inline bool mmap_write_trylock(struct mm_struct *mm)
20 {
21         return down_write_trylock(&mm->mmap_sem) != 0;
22 }
23
24 static inline void mmap_write_unlock(struct mm_struct *mm)
25 {
26         up_write(&mm->mmap_sem);
27 }
28
29 static inline void mmap_write_downgrade(struct mm_struct *mm)
30 {
31         downgrade_write(&mm->mmap_sem);
32 }
33
34 static inline void mmap_read_lock(struct mm_struct *mm)
35 {
36         down_read(&mm->mmap_sem);
37 }
38
39 static inline int mmap_read_lock_killable(struct mm_struct *mm)
40 {
41         return down_read_killable(&mm->mmap_sem);
42 }
43
44 static inline bool mmap_read_trylock(struct mm_struct *mm)
45 {
46         return down_read_trylock(&mm->mmap_sem) != 0;
47 }
48
49 static inline void mmap_read_unlock(struct mm_struct *mm)
50 {
51         up_read(&mm->mmap_sem);
52 }
53
54 #endif /* _LINUX_MMAP_LOCK_H */